@@ -44,6 +44,7 @@ var conf = Config{
44
44
PullPeerNum : 3 ,
45
45
PullInterval : time .Second ,
46
46
RequestStateInfoInterval : time .Millisecond * 100 ,
47
+ Identity : api .PeerIdentityType ("pkiIDInOrg1" ),
47
48
}
48
49
49
50
func init () {
@@ -197,8 +198,7 @@ func (ga *gossipAdapterMock) ValidateStateInfoMessage(msg *proto.SignedGossipMes
197
198
}
198
199
199
200
func (ga * gossipAdapterMock ) OrgByPeerIdentity (identity api.PeerIdentityType ) api.OrgIdentityType {
200
- args := ga .Called (identity )
201
- return args .Get (0 ).(api.OrgIdentityType )
201
+ return ga .GetOrgOfPeer (common .PKIidType (identity ))
202
202
}
203
203
204
204
func (ga * gossipAdapterMock ) GetOrgOfPeer (PKIIID common.PKIidType ) api.OrgIdentityType {
@@ -217,6 +217,9 @@ func configureAdapter(adapter *gossipAdapterMock, members ...discovery.NetworkMe
217
217
adapter .On ("GetOrgOfPeer" , pkiIDInOrg1ButNotEligible ).Return (orgInChannelA )
218
218
adapter .On ("GetOrgOfPeer" , pkiIDinOrg2 ).Return (orgNotInChannelA )
219
219
adapter .On ("GetOrgOfPeer" , mock .Anything ).Return (api .OrgIdentityType (nil ))
220
+ adapter .On ("OrgByPeerIdentity" , mock .Anything ).Run (func (args mock.Arguments ) {
221
+ fmt .Println (args .Get (0 ))
222
+ })
220
223
}
221
224
222
225
func TestChannelPeriodicalPublishStateInfo (t * testing.T ) {
@@ -815,6 +818,35 @@ func TestChannelReconfigureChannel(t *testing.T) {
815
818
}
816
819
}
817
820
821
+ func TestChannelNoAnchorPeers (t * testing.T ) {
822
+ t .Parallel ()
823
+
824
+ // Scenario: We got a join channel message with no anchor peers
825
+ // In this case, we should be in the channel
826
+
827
+ cs := & cryptoService {}
828
+ adapter := new (gossipAdapterMock )
829
+ configureAdapter (adapter , discovery.NetworkMember {PKIid : pkiIDInOrg1 })
830
+
831
+ adapter .On ("GetConf" ).Return (conf )
832
+ adapter .On ("GetMembership" ).Return ([]discovery.NetworkMember {})
833
+ adapter .On ("OrgByPeerIdentity" , api .PeerIdentityType (orgInChannelA )).Return (orgInChannelA )
834
+ adapter .On ("GetOrgOfPeer" , pkiIDInOrg1 ).Return (orgInChannelA )
835
+ adapter .On ("GetOrgOfPeer" , pkiIDinOrg2 ).Return (orgNotInChannelA )
836
+
837
+ jcm := & joinChanMsg {
838
+ anchorPeers : func () []api.AnchorPeer {
839
+ return []api.AnchorPeer {}
840
+ },
841
+ getTS : func () time.Time {
842
+ return time .Now ().Add (time .Millisecond * 100 )
843
+ },
844
+ }
845
+
846
+ gc := NewGossipChannel (cs , channelA , adapter , api .JoinChannelMessage (jcm ))
847
+ assert .True (t , gc .IsOrgInChannel (orgInChannelA ))
848
+ }
849
+
818
850
func TestChannelGetPeers (t * testing.T ) {
819
851
t .Parallel ()
820
852
0 commit comments