Skip to content

Commit 55aec5e

Browse files
author
Jason Yellick
committed
[FAB-1564] Create policies mock infrastructure
https://jira.hyperledger.org/browse/FAB-1564 This is the first in a series of three patch sets to add broadcast filtering by signature, this one introduces the mock testing infrastructure that will be necessary to test the signature filter. Change-Id: Ifb5e37b43117c21ae6df47241d618b61c1c33b7e Signed-off-by: Jason Yellick <[email protected]>
1 parent 01de0e4 commit 55aec5e

File tree

2 files changed

+74
-0
lines changed

2 files changed

+74
-0
lines changed

orderer/mocks/policies/policies.go

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
Copyright IBM Corp. 2016 All Rights Reserved.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package policies
18+
19+
import (
20+
"github.com/hyperledger/fabric/common/policies"
21+
cb "github.com/hyperledger/fabric/protos/common"
22+
)
23+
24+
// Policy is a mock implementation of the policies.Policy interface
25+
type Policy struct {
26+
Err error
27+
}
28+
29+
// Evaluate returns the Err set in Policy
30+
func (p *Policy) Evaluate(signatureSet []*cb.SignedData) error {
31+
return p.Err
32+
}
33+
34+
// Manager is a mock implementation of the policies.Manager interface
35+
type Manager struct {
36+
// Policy is returned as the output to GetPolicy
37+
Policy *Policy
38+
}
39+
40+
// GetPolicy returns the value of Manager.Policy and whether it was nil or not
41+
func (m *Manager) GetPolicy(id string) (policies.Policy, bool) {
42+
return m.Policy, m.Policy != nil
43+
}
+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*
2+
Copyright IBM Corp. 2016 All Rights Reserved.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package policies
18+
19+
import (
20+
"testing"
21+
22+
"github.com/hyperledger/fabric/common/policies"
23+
)
24+
25+
func TestPolicyManagerInterface(t *testing.T) {
26+
_ = policies.Manager(&Manager{})
27+
}
28+
29+
func TestPolicyInterface(t *testing.T) {
30+
_ = policies.Policy(&Policy{})
31+
}

0 commit comments

Comments
 (0)