Skip to content

Commit

Permalink
[FAB-10968] Fix race in discovery integration test
Browse files Browse the repository at this point in the history
Moved the testPeers variable initialization to be
inside the Main function, since it is anyway should
be written only once as all tests operate on the same
directory of channel artifacts.

Change-Id: Ie07be90e1d456dd62abd92d41631df0aab89933e
Signed-off-by: yacovm <[email protected]>
  • Loading branch information
yacovm committed Jul 14, 2018
1 parent 40b6969 commit 6e9ad4b
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions discovery/test/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,14 @@ func TestMain(m *testing.M) {
return
}

peerDirPrefix := filepath.Join(testdir, "crypto-config", "peerOrganizations")
testPeers = testPeerSet{
newPeer(peerDirPrefix, "Org1MSP", 1, 0),
newPeer(peerDirPrefix, "Org1MSP", 1, 1),
newPeer(peerDirPrefix, "Org2MSP", 2, 0),
newPeer(peerDirPrefix, "Org2MSP", 2, 1),
}

rc := m.Run()
os.RemoveAll(testdir)
gexec.CleanupBuildArtifacts()
Expand Down Expand Up @@ -405,14 +413,6 @@ func createSupport(t *testing.T, dir string, lc *lifeCycle) *support {
assert.NoError(t, err)
acl := discacl.NewDiscoverySupport(channelVerifier, org1AdminPolicy, chConfig)

peerDirPrefix := filepath.Join(dir, "crypto-config", "peerOrganizations")
testPeers = testPeerSet{
newPeer(peerDirPrefix, "Org1MSP", 1, 0),
newPeer(peerDirPrefix, "Org1MSP", 1, 1),
newPeer(peerDirPrefix, "Org2MSP", 2, 0),
newPeer(peerDirPrefix, "Org2MSP", 2, 1),
}

gSup := &mocks.GossipSupport{}
gSup.On("ChannelExists", "mychannel").Return(true)
gSup.On("PeersOfChannel", gcommon.ChainID("mychannel")).Return(testPeers.toStateInfoSet())
Expand Down

0 comments on commit 6e9ad4b

Please sign in to comment.