func TestPeerGroupResolverPolicy3(t *testing.T) {
	signedBy, identities, err := GetPolicies(org1, org2, org3, org4, org5)
	if err != nil {
		panic(err)
	}
	sigPolicyEnv := &common.SignaturePolicyEnvelope{
		Version: 0,
		Rule: NewNOutOfPolicy(2,
			NewNOutOfPolicy(1,
				signedBy[o1],
				signedBy[o2],
			),
			NewNOutOfPolicy(1,
				signedBy[o3],
				signedBy[o4],
				signedBy[o5],
			),
		),
		Identities: identities,
	}
	expected := []PeerGroup{
		pg(p1, p5), pg(p1, p6), pg(p1, p7), pg(p1, p8), pg(p1, p9), pg(p1, p10), pg(p1, p11), pg(p1, p12),
		pg(p2, p5), pg(p2, p6), pg(p2, p7), pg(p2, p8), pg(p2, p9), pg(p2, p10), pg(p2, p11), pg(p2, p12),
		pg(p3, p5), pg(p3, p6), pg(p3, p7), pg(p3, p8), pg(p3, p9), pg(p3, p10), pg(p3, p11), pg(p3, p12),
		pg(p4, p5), pg(p4, p6), pg(p4, p7), pg(p4, p8), pg(p4, p9), pg(p4, p10), pg(p4, p11), pg(p4, p12),
	}
	testPeerGroupResolver(t, sigPolicyEnv, retrievePeersByMSPid, expected)
}
2 of [(1 of [1,2]),(1 of [3,4,5])]
package pgresolver
import (
	"testing"
	sdkApi "github.com/hyperledger/fabric-sdk-go/api/apifabclient"
	mocks "github.com/hyperledger/fabric-sdk-go/pkg/fabric-client/mocks"
	common "github.com/hyperledger/fabric-sdk-go/third_party/github.com/hyperledger/fabric/protos/common"
)
const (
	org1  = "Org1MSP"
	org2  = "Org2MSP"
	org3  = "Org3MSP"
	org4  = "Org4MSP"
	org5  = "Org5MSP"
	org6  = "Org6MSP"
	org7  = "Org7MSP"
	org8  = "Org8MSP"
	org9  = "Org9MSP"
	org10 = "Org10MSP"
)
var p1 = peer("peer1")
var p2 = peer("peer2")
var p3 = peer("peer3")
var p4 = peer("peer4")
var p5 = peer("peer5")
var p6 = peer("peer6")
var p7 = peer("peer7")
var p8 = peer("peer8")
var p9 = peer("peer9")
var p10 = peer("peer10")
var p11 = peer("peer11")
var p12 = peer("peer12")
var peersByMSPID = map[string][]sdkApi.Peer{
	org1: peers(p1, p2),
	org2: peers(p3, p4),
	org3: peers(p5, p6, p7),
	org4: peers(p8, p9, p10),
	org5: peers(p11, p12),
}
var configImp = mocks.NewMockConfig()
const (
	o1 = iota
	o2
	o3
	o4
	o5
)
func TestPeerGroupResolverPolicyNoAvailablePeers(t *testing.T) {
	signedBy, identities, err := GetPolicies(org1)
	if err != nil {
		panic(err)
	}
	sigPolicyEnv := &common.SignaturePolicyEnvelope{
		Version: 0, Rule: signedBy[o1], Identities: identities,
	}
	expected := []PeerGroup{}
	testPeerGroupResolver(
		t, sigPolicyEnv,
		func(mspID string) []sdkApi.Peer {
			return nil
		},
		expected)
}
func TestPeerGroupResolverPolicy1(t *testing.T) {
	signedBy, identities, err := GetPolicies(org1, org2, org3, org4)
	if err != nil {
		panic(err)
	}
	sigPolicyEnv := &common.SignaturePolicyEnvelope{
		Version: 0,
		Rule: NewNOutOfPolicy(1,
			NewNOutOfPolicy(2,
				signedBy[o1],
				signedBy[o2],
			),
			NewNOutOfPolicy(2,
				signedBy[o1],
				signedBy[o3],
				signedBy[o4],
			),
		),
		Identities: identities,
	}
	expected := []PeerGroup{
		pg(p1, p3), pg(p1, p4), pg(p2, p3), pg(p2, p4),
		pg(p1, p5), pg(p1, p6), pg(p1, p7), pg(p2, p5), pg(p2, p6), pg(p2, p7),
		pg(p1, p8), pg(p1, p9), pg(p1, p10), pg(p2, p8), pg(p2, p9), pg(p2, p10),
		pg(p5, p8), pg(p5, p9), pg(p5, p10), pg(p6, p8), pg(p6, p9), pg(p6, p10), pg(p7, p8), pg(p7, p9), pg(p7, p10),
	}
	testPeerGroupResolver(t, sigPolicyEnv, retrievePeersByMSPid, expected)
}
func TestPeerGroupResolverPolicy2(t *testing.T) {
	signedBy, identities, err := GetPolicies(org1, org2, org3, org4, org5)
	if err != nil {
		panic(err)
	}
	sigPolicyEnv := &common.SignaturePolicyEnvelope{
		Version: 0,
		Rule: NewNOutOfPolicy(1,
			NewNOutOfPolicy(2,
				signedBy[o1],
				signedBy[o2],
			),
			NewNOutOfPolicy(3,
				signedBy[o3],
				signedBy[o4],
				signedBy[o5],
			),
		),
		Identities: identities,
	}
	expected := []PeerGroup{
		pg(p1, p3), pg(p1, p4), pg(p2, p3), pg(p2, p4),
		pg(p5, p8, p11), pg(p5, p8, p12), pg(p5, p9, p11), pg(p5, p9, p12), pg(p5, p10, p11), pg(p5, p10, p12),
		pg(p6, p8, p11), pg(p6, p8, p12), pg(p6, p9, p11), pg(p6, p9, p12), pg(p6, p10, p11), pg(p6, p10, p12),
		pg(p7, p8, p11), pg(p7, p8, p12), pg(p7, p9, p11), pg(p7, p9, p12), pg(p7, p10, p11), pg(p7, p10, p12),
	}
	testPeerGroupResolver(t, sigPolicyEnv, retrievePeersByMSPid, expected)
}