Merge pull request #97 from filecoin-project/fix/connect-miners

connect miners in a full mesh.
This commit is contained in:
vyzo 2020-07-03 13:03:30 +03:00 committed by GitHub
commit 6c14fdaca7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -278,6 +278,23 @@ func PrepareMiner(t *TestEnvironment) (*LotusMiner, error) {
} }
t.SyncClient.MustPublish(ctx, MinersAddrsTopic, MinerAddressesMsg{addrinfo, actoraddress}) t.SyncClient.MustPublish(ctx, MinersAddrsTopic, MinerAddressesMsg{addrinfo, actoraddress})
t.RecordMessage("connecting to all other miners")
// connect to all other miners.
minerCh := make(chan *MinerAddressesMsg, 16)
sctx, cancel := context.WithCancel(ctx)
defer cancel()
t.SyncClient.MustSubscribe(sctx, MinersAddrsTopic, minerCh)
for i := 0; i < t.IntParam("miners"); i++ {
if miner := <-minerCh; miner.ActorAddr != actoraddress {
err := n.FullApi.NetConnect(ctx, miner.PeerAddr)
if err != nil {
return nil, fmt.Errorf("failed to connect to miner %s on: %v", miner.ActorAddr, miner.PeerAddr)
}
t.RecordMessage("connected to miner %s on %v", miner.ActorAddr, miner.PeerAddr)
}
}
t.RecordMessage("waiting for all nodes to be ready") t.RecordMessage("waiting for all nodes to be ready")
t.SyncClient.MustSignalAndWait(ctx, StateReady, t.TestInstanceCount) t.SyncClient.MustSignalAndWait(ctx, StateReady, t.TestInstanceCount)