From 809e8def862fdfa792061a448f952747f1af4d3c Mon Sep 17 00:00:00 2001 From: Mission Liao Date: Fri, 11 Jan 2019 12:58:30 +0800 Subject: syncer: fix issues when switching to core.Consensus (#418) - when confirmed blocks passed to core.Consensus aren't continuous in position in some chain, the pulling would skip those missing blocks. - fix: when some block is missing, avoid adding it and all blocks after it to core.Consensus. - we need to avoid the receive channel of network module full. - fix: during switching to core.Consensus, we need to launch a dummy receiver to receive from receive channel of network module. - fix: between the period during core.Consensus created and before running, a dummy receiver is also required to receive from receive channel of network module. --- integration_test/consensus_test.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'integration_test') diff --git a/integration_test/consensus_test.go b/integration_test/consensus_test.go index 99de7c9..fc6bb47 100644 --- a/integration_test/consensus_test.go +++ b/integration_test/consensus_test.go @@ -367,8 +367,8 @@ func (s *ConsensusTestSuite) TestSync() { } // Clean syncNode's network receive channel, or it might exceed the limit // and block other go routines. - dummyReceiverCtxCancel := test.LaunchDummyReceiver( - context.Background(), syncNode.network) + dummyReceiverCtxCancel, dummyFinished := utils.LaunchDummyReceiver( + context.Background(), syncNode.network.ReceiveChan(), nil) ReachAlive: for { // Check if any error happened or sleep for a period of time. @@ -390,6 +390,7 @@ ReachAlive: } } dummyReceiverCtxCancel() + <-dummyFinished break } // Initiate Syncer. @@ -456,7 +457,8 @@ ReachAlive: stoppedNode.con.Stop() stoppedNode.con = nil fmt.Println("one node stopped", stoppedNode.ID) - test.LaunchDummyReceiver(runnerCtx, stoppedNode.network) + utils.LaunchDummyReceiver( + runnerCtx, stoppedNode.network.ReceiveChan(), nil) continue } if pos.Round < untilRound { -- cgit v1.2.3