From 7e63197e977270ef90391e62fe09c54f34907d5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Kripalani?= Date: Thu, 2 Jul 2020 22:49:59 +0100 Subject: [PATCH] connect miners in a full mesh. --- lotus-soup/testkit/role_miner.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/lotus-soup/testkit/role_miner.go b/lotus-soup/testkit/role_miner.go index c5a8897ed..5313b0fd9 100644 --- a/lotus-soup/testkit/role_miner.go +++ b/lotus-soup/testkit/role_miner.go @@ -278,6 +278,23 @@ func PrepareMiner(t *TestEnvironment) (*LotusMiner, error) { } 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.SyncClient.MustSignalAndWait(ctx, StateReady, t.TestInstanceCount)