Skip to content

Commit edddd1e

Browse files
committed
[FAB-6736] ServiceDiscovery: Endorsement descriptors
This change set implements an endorsement descriptor builder for simple policies (where each peer satisfies only 1 principal, such as endorsement policies that are comprised only of Member roles). Tests have been added for a code coverage of 100%. Change-Id: I86bf653337a47eba6708f4d6dee631bfb36fa954 Signed-off-by: yacovm <yacovm@il.ibm.com>
1 parent ced4490 commit edddd1e

File tree

4 files changed

+737
-0
lines changed

4 files changed

+737
-0
lines changed

common/chaincode/metadata.go

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*
2+
Copyright IBM Corp. All Rights Reserved.
3+
4+
SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
package chaincode
8+
9+
import "github.com/hyperledger/fabric/protos/gossip"
10+
11+
// InstalledChaincode defines metadata about an installed chaincode
12+
type InstalledChaincode struct {
13+
Name string
14+
Version string
15+
Id []byte
16+
}
17+
18+
// InstantiatedChaincode defines channel-scoped metadata of a chaincode
19+
type InstantiatedChaincode struct {
20+
Name string
21+
Version string
22+
Policy []byte
23+
Id []byte
24+
}
25+
26+
// InstantiatedChaincodes defines an aggregation of InstantiatedChaincodes
27+
type InstantiatedChaincodes []InstantiatedChaincode
28+
29+
// ToChaincodes converts this InstantiatedChaincodes to a slice of gossip.Chaincodes
30+
func (ccs InstantiatedChaincodes) ToChaincodes() []*gossip.Chaincode {
31+
var res []*gossip.Chaincode
32+
for _, cc := range ccs {
33+
res = append(res, &gossip.Chaincode{
34+
Name: cc.Name,
35+
Version: cc.Version,
36+
})
37+
}
38+
return res
39+
}

common/chaincode/metadata_test.go

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*
2+
Copyright IBM Corp. All Rights Reserved.
3+
4+
SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
package chaincode
8+
9+
import (
10+
"testing"
11+
12+
"github.com/hyperledger/fabric/protos/gossip"
13+
"github.com/stretchr/testify/assert"
14+
)
15+
16+
func TestToChaincodes(t *testing.T) {
17+
ccs := InstantiatedChaincodes{
18+
{
19+
Name: "foo",
20+
Version: "1.0",
21+
},
22+
}
23+
assert.Equal(t, []*gossip.Chaincode{
24+
{Name: "foo", Version: "1.0"},
25+
}, ccs.ToChaincodes())
26+
}

0 commit comments

Comments
 (0)