You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

399 lines
11 KiB

cleanup: Reduce and normalize import path aliasing. (#6975) The code in the Tendermint repository makes heavy use of import aliasing. This is made necessary by our extensive reuse of common base package names, and by repetition of similar names across different subdirectories. Unfortunately we have not been very consistent about which packages we alias in various circumstances, and the aliases we use vary. In the spirit of the advice in the style guide and https://github.com/golang/go/wiki/CodeReviewComments#imports, his change makes an effort to clean up and normalize import aliasing. This change makes no API or behavioral changes. It is a pure cleanup intended o help make the code more readable to developers (including myself) trying to understand what is being imported where. Only unexported names have been modified, and the changes were generated and applied mechanically with gofmt -r and comby, respecting the lexical and syntactic rules of Go. Even so, I did not fix every inconsistency. Where the changes would be too disruptive, I left it alone. The principles I followed in this cleanup are: - Remove aliases that restate the package name. - Remove aliases where the base package name is unambiguous. - Move overly-terse abbreviations from the import to the usage site. - Fix lexical issues (remove underscores, remove capitalization). - Fix import groupings to more closely match the style guide. - Group blank (side-effecting) imports and ensure they are commented. - Add aliases to multiple imports with the same base package name.
3 years ago
cleanup: Reduce and normalize import path aliasing. (#6975) The code in the Tendermint repository makes heavy use of import aliasing. This is made necessary by our extensive reuse of common base package names, and by repetition of similar names across different subdirectories. Unfortunately we have not been very consistent about which packages we alias in various circumstances, and the aliases we use vary. In the spirit of the advice in the style guide and https://github.com/golang/go/wiki/CodeReviewComments#imports, his change makes an effort to clean up and normalize import aliasing. This change makes no API or behavioral changes. It is a pure cleanup intended o help make the code more readable to developers (including myself) trying to understand what is being imported where. Only unexported names have been modified, and the changes were generated and applied mechanically with gofmt -r and comby, respecting the lexical and syntactic rules of Go. Even so, I did not fix every inconsistency. Where the changes would be too disruptive, I left it alone. The principles I followed in this cleanup are: - Remove aliases that restate the package name. - Remove aliases where the base package name is unambiguous. - Move overly-terse abbreviations from the import to the usage site. - Fix lexical issues (remove underscores, remove capitalization). - Fix import groupings to more closely match the style guide. - Group blank (side-effecting) imports and ensure they are commented. - Add aliases to multiple imports with the same base package name.
3 years ago
blockchain: Reorg reactor (#3561) * go routines in blockchain reactor * Added reference to the go routine diagram * Initial commit * cleanup * Undo testing_logger change, committed by mistake * Fix the test loggers * pulled some fsm code into pool.go * added pool tests * changes to the design added block requests under peer moved the request trigger in the reactor poolRoutine, triggered now by a ticker in general moved everything required for making block requests smarter in the poolRoutine added a simple map of heights to keep track of what will need to be requested next added a few more tests * send errors to FSM in a different channel than blocks send errors (RemovePeer) from switch on a different channel than the one receiving blocks renamed channels added more pool tests * more pool tests * lint errors * more tests * more tests * switch fast sync to new implementation * fixed data race in tests * cleanup * finished fsm tests * address golangci comments :) * address golangci comments :) * Added timeout on next block needed to advance * updating docs and cleanup * fix issue in test from previous cleanup * cleanup * Added termination scenarios, tests and more cleanup * small fixes to adr, comments and cleanup * Fix bug in sendRequest() If we tried to send a request to a peer not present in the switch, a missing continue statement caused the request to be blackholed in a peer that was removed and never retried. While this bug was manifesting, the reactor kept asking for other blocks that would be stored and never consumed. Added the number of unconsumed blocks in the math for requesting blocks ahead of current processing height so eventually there will be no more blocks requested until the already received ones are consumed. * remove bpPeer's didTimeout field * Use distinct err codes for peer timeout and FSM timeouts * Don't allow peers to update with lower height * review comments from Ethan and Zarko * some cleanup, renaming, comments * Move block execution in separate goroutine * Remove pool's numPending * review comments * fix lint, remove old blockchain reactor and duplicates in fsm tests * small reorg around peer after review comments * add the reactor spec * verify block only once * review comments * change to int for max number of pending requests * cleanup and godoc * Add configuration flag fast sync version * golangci fixes * fix config template * move both reactor versions under blockchain * cleanup, golint, renaming stuff * updated documentation, fixed more golint warnings * integrate with behavior package * sync with master * gofmt * add changelog_pending entry * move to improvments * suggestion to changelog entry
5 years ago
cleanup: Reduce and normalize import path aliasing. (#6975) The code in the Tendermint repository makes heavy use of import aliasing. This is made necessary by our extensive reuse of common base package names, and by repetition of similar names across different subdirectories. Unfortunately we have not been very consistent about which packages we alias in various circumstances, and the aliases we use vary. In the spirit of the advice in the style guide and https://github.com/golang/go/wiki/CodeReviewComments#imports, his change makes an effort to clean up and normalize import aliasing. This change makes no API or behavioral changes. It is a pure cleanup intended o help make the code more readable to developers (including myself) trying to understand what is being imported where. Only unexported names have been modified, and the changes were generated and applied mechanically with gofmt -r and comby, respecting the lexical and syntactic rules of Go. Even so, I did not fix every inconsistency. Where the changes would be too disruptive, I left it alone. The principles I followed in this cleanup are: - Remove aliases that restate the package name. - Remove aliases where the base package name is unambiguous. - Move overly-terse abbreviations from the import to the usage site. - Fix lexical issues (remove underscores, remove capitalization). - Fix import groupings to more closely match the style guide. - Group blank (side-effecting) imports and ensure they are commented. - Add aliases to multiple imports with the same base package name.
3 years ago
cleanup: Reduce and normalize import path aliasing. (#6975) The code in the Tendermint repository makes heavy use of import aliasing. This is made necessary by our extensive reuse of common base package names, and by repetition of similar names across different subdirectories. Unfortunately we have not been very consistent about which packages we alias in various circumstances, and the aliases we use vary. In the spirit of the advice in the style guide and https://github.com/golang/go/wiki/CodeReviewComments#imports, his change makes an effort to clean up and normalize import aliasing. This change makes no API or behavioral changes. It is a pure cleanup intended o help make the code more readable to developers (including myself) trying to understand what is being imported where. Only unexported names have been modified, and the changes were generated and applied mechanically with gofmt -r and comby, respecting the lexical and syntactic rules of Go. Even so, I did not fix every inconsistency. Where the changes would be too disruptive, I left it alone. The principles I followed in this cleanup are: - Remove aliases that restate the package name. - Remove aliases where the base package name is unambiguous. - Move overly-terse abbreviations from the import to the usage site. - Fix lexical issues (remove underscores, remove capitalization). - Fix import groupings to more closely match the style guide. - Group blank (side-effecting) imports and ensure they are commented. - Add aliases to multiple imports with the same base package name.
3 years ago
cleanup: Reduce and normalize import path aliasing. (#6975) The code in the Tendermint repository makes heavy use of import aliasing. This is made necessary by our extensive reuse of common base package names, and by repetition of similar names across different subdirectories. Unfortunately we have not been very consistent about which packages we alias in various circumstances, and the aliases we use vary. In the spirit of the advice in the style guide and https://github.com/golang/go/wiki/CodeReviewComments#imports, his change makes an effort to clean up and normalize import aliasing. This change makes no API or behavioral changes. It is a pure cleanup intended o help make the code more readable to developers (including myself) trying to understand what is being imported where. Only unexported names have been modified, and the changes were generated and applied mechanically with gofmt -r and comby, respecting the lexical and syntactic rules of Go. Even so, I did not fix every inconsistency. Where the changes would be too disruptive, I left it alone. The principles I followed in this cleanup are: - Remove aliases that restate the package name. - Remove aliases where the base package name is unambiguous. - Move overly-terse abbreviations from the import to the usage site. - Fix lexical issues (remove underscores, remove capitalization). - Fix import groupings to more closely match the style guide. - Group blank (side-effecting) imports and ensure they are commented. - Add aliases to multiple imports with the same base package name.
3 years ago
cleanup: Reduce and normalize import path aliasing. (#6975) The code in the Tendermint repository makes heavy use of import aliasing. This is made necessary by our extensive reuse of common base package names, and by repetition of similar names across different subdirectories. Unfortunately we have not been very consistent about which packages we alias in various circumstances, and the aliases we use vary. In the spirit of the advice in the style guide and https://github.com/golang/go/wiki/CodeReviewComments#imports, his change makes an effort to clean up and normalize import aliasing. This change makes no API or behavioral changes. It is a pure cleanup intended o help make the code more readable to developers (including myself) trying to understand what is being imported where. Only unexported names have been modified, and the changes were generated and applied mechanically with gofmt -r and comby, respecting the lexical and syntactic rules of Go. Even so, I did not fix every inconsistency. Where the changes would be too disruptive, I left it alone. The principles I followed in this cleanup are: - Remove aliases that restate the package name. - Remove aliases where the base package name is unambiguous. - Move overly-terse abbreviations from the import to the usage site. - Fix lexical issues (remove underscores, remove capitalization). - Fix import groupings to more closely match the style guide. - Group blank (side-effecting) imports and ensure they are commented. - Add aliases to multiple imports with the same base package name.
3 years ago
  1. package blocksync
  2. import (
  3. "context"
  4. "os"
  5. "testing"
  6. "time"
  7. "github.com/fortytw2/leaktest"
  8. "github.com/stretchr/testify/require"
  9. dbm "github.com/tendermint/tm-db"
  10. abciclient "github.com/tendermint/tendermint/abci/client"
  11. abci "github.com/tendermint/tendermint/abci/types"
  12. "github.com/tendermint/tendermint/config"
  13. "github.com/tendermint/tendermint/internal/consensus"
  14. "github.com/tendermint/tendermint/internal/mempool/mock"
  15. "github.com/tendermint/tendermint/internal/p2p"
  16. "github.com/tendermint/tendermint/internal/p2p/p2ptest"
  17. "github.com/tendermint/tendermint/internal/proxy"
  18. sm "github.com/tendermint/tendermint/internal/state"
  19. sf "github.com/tendermint/tendermint/internal/state/test/factory"
  20. "github.com/tendermint/tendermint/internal/store"
  21. "github.com/tendermint/tendermint/internal/test/factory"
  22. "github.com/tendermint/tendermint/libs/log"
  23. bcproto "github.com/tendermint/tendermint/proto/tendermint/blocksync"
  24. "github.com/tendermint/tendermint/types"
  25. )
  26. type reactorTestSuite struct {
  27. network *p2ptest.Network
  28. logger log.Logger
  29. nodes []types.NodeID
  30. reactors map[types.NodeID]*Reactor
  31. app map[types.NodeID]proxy.AppConns
  32. blockSyncChannels map[types.NodeID]*p2p.Channel
  33. peerChans map[types.NodeID]chan p2p.PeerUpdate
  34. peerUpdates map[types.NodeID]*p2p.PeerUpdates
  35. blockSync bool
  36. }
  37. func setup(
  38. ctx context.Context,
  39. t *testing.T,
  40. genDoc *types.GenesisDoc,
  41. privVal types.PrivValidator,
  42. maxBlockHeights []int64,
  43. chBuf uint,
  44. ) *reactorTestSuite {
  45. t.Helper()
  46. var cancel context.CancelFunc
  47. ctx, cancel = context.WithCancel(ctx)
  48. numNodes := len(maxBlockHeights)
  49. require.True(t, numNodes >= 1,
  50. "must specify at least one block height (nodes)")
  51. rts := &reactorTestSuite{
  52. logger: log.TestingLogger().With("module", "block_sync", "testCase", t.Name()),
  53. network: p2ptest.MakeNetwork(ctx, t, p2ptest.NetworkOptions{NumNodes: numNodes}),
  54. nodes: make([]types.NodeID, 0, numNodes),
  55. reactors: make(map[types.NodeID]*Reactor, numNodes),
  56. app: make(map[types.NodeID]proxy.AppConns, numNodes),
  57. blockSyncChannels: make(map[types.NodeID]*p2p.Channel, numNodes),
  58. peerChans: make(map[types.NodeID]chan p2p.PeerUpdate, numNodes),
  59. peerUpdates: make(map[types.NodeID]*p2p.PeerUpdates, numNodes),
  60. blockSync: true,
  61. }
  62. chDesc := &p2p.ChannelDescriptor{ID: BlockSyncChannel, MessageType: new(bcproto.Message)}
  63. rts.blockSyncChannels = rts.network.MakeChannelsNoCleanup(ctx, t, chDesc)
  64. i := 0
  65. for nodeID := range rts.network.Nodes {
  66. rts.addNode(ctx, t, nodeID, genDoc, privVal, maxBlockHeights[i])
  67. i++
  68. }
  69. t.Cleanup(func() {
  70. cancel()
  71. for _, nodeID := range rts.nodes {
  72. if rts.reactors[nodeID].IsRunning() {
  73. rts.reactors[nodeID].Wait()
  74. rts.app[nodeID].Wait()
  75. require.False(t, rts.reactors[nodeID].IsRunning())
  76. }
  77. }
  78. })
  79. t.Cleanup(leaktest.Check(t))
  80. return rts
  81. }
  82. func (rts *reactorTestSuite) addNode(
  83. ctx context.Context,
  84. t *testing.T,
  85. nodeID types.NodeID,
  86. genDoc *types.GenesisDoc,
  87. privVal types.PrivValidator,
  88. maxBlockHeight int64,
  89. ) {
  90. t.Helper()
  91. logger := log.TestingLogger()
  92. rts.nodes = append(rts.nodes, nodeID)
  93. rts.app[nodeID] = proxy.NewAppConns(abciclient.NewLocalCreator(&abci.BaseApplication{}), logger, proxy.NopMetrics())
  94. require.NoError(t, rts.app[nodeID].Start(ctx))
  95. blockDB := dbm.NewMemDB()
  96. stateDB := dbm.NewMemDB()
  97. stateStore := sm.NewStore(stateDB)
  98. blockStore := store.NewBlockStore(blockDB)
  99. state, err := sm.MakeGenesisState(genDoc)
  100. require.NoError(t, err)
  101. require.NoError(t, stateStore.Save(state))
  102. blockExec := sm.NewBlockExecutor(
  103. stateStore,
  104. log.TestingLogger(),
  105. rts.app[nodeID].Consensus(),
  106. mock.Mempool{},
  107. sm.EmptyEvidencePool{},
  108. blockStore,
  109. )
  110. for blockHeight := int64(1); blockHeight <= maxBlockHeight; blockHeight++ {
  111. lastCommit := types.NewCommit(blockHeight-1, 0, types.BlockID{}, nil)
  112. if blockHeight > 1 {
  113. lastBlockMeta := blockStore.LoadBlockMeta(blockHeight - 1)
  114. lastBlock := blockStore.LoadBlock(blockHeight - 1)
  115. vote, err := factory.MakeVote(
  116. ctx,
  117. privVal,
  118. lastBlock.Header.ChainID, 0,
  119. lastBlock.Header.Height, 0, 2,
  120. lastBlockMeta.BlockID,
  121. time.Now(),
  122. )
  123. require.NoError(t, err)
  124. lastCommit = types.NewCommit(
  125. vote.Height,
  126. vote.Round,
  127. lastBlockMeta.BlockID,
  128. []types.CommitSig{vote.CommitSig()},
  129. )
  130. }
  131. thisBlock, err := sf.MakeBlock(state, blockHeight, lastCommit)
  132. require.NoError(t, err)
  133. thisParts, err := thisBlock.MakePartSet(types.BlockPartSizeBytes)
  134. require.NoError(t, err)
  135. blockID := types.BlockID{Hash: thisBlock.Hash(), PartSetHeader: thisParts.Header()}
  136. state, err = blockExec.ApplyBlock(ctx, state, blockID, thisBlock)
  137. require.NoError(t, err)
  138. blockStore.SaveBlock(thisBlock, thisParts, lastCommit)
  139. }
  140. rts.peerChans[nodeID] = make(chan p2p.PeerUpdate)
  141. rts.peerUpdates[nodeID] = p2p.NewPeerUpdates(rts.peerChans[nodeID], 1)
  142. rts.network.Nodes[nodeID].PeerManager.Register(ctx, rts.peerUpdates[nodeID])
  143. chCreator := func(ctx context.Context, chdesc *p2p.ChannelDescriptor) (*p2p.Channel, error) {
  144. return rts.blockSyncChannels[nodeID], nil
  145. }
  146. rts.reactors[nodeID], err = NewReactor(
  147. ctx,
  148. rts.logger.With("nodeID", nodeID),
  149. state.Copy(),
  150. blockExec,
  151. blockStore,
  152. nil,
  153. chCreator,
  154. rts.peerUpdates[nodeID],
  155. rts.blockSync,
  156. consensus.NopMetrics(),
  157. nil, // eventbus, can be nil
  158. )
  159. require.NoError(t, err)
  160. require.NoError(t, rts.reactors[nodeID].Start(ctx))
  161. require.True(t, rts.reactors[nodeID].IsRunning())
  162. }
  163. func (rts *reactorTestSuite) start(ctx context.Context, t *testing.T) {
  164. t.Helper()
  165. rts.network.Start(ctx, t)
  166. require.Len(t,
  167. rts.network.RandomNode().PeerManager.Peers(),
  168. len(rts.nodes)-1,
  169. "network does not have expected number of nodes")
  170. }
  171. func TestReactor_AbruptDisconnect(t *testing.T) {
  172. ctx, cancel := context.WithCancel(context.Background())
  173. defer cancel()
  174. cfg, err := config.ResetTestRoot(t.TempDir(), "block_sync_reactor_test")
  175. require.NoError(t, err)
  176. defer os.RemoveAll(cfg.RootDir)
  177. valSet, privVals := factory.ValidatorSet(ctx, t, 1, 30)
  178. genDoc := factory.GenesisDoc(cfg, time.Now(), valSet.Validators, nil)
  179. maxBlockHeight := int64(64)
  180. rts := setup(ctx, t, genDoc, privVals[0], []int64{maxBlockHeight, 0}, 0)
  181. require.Equal(t, maxBlockHeight, rts.reactors[rts.nodes[0]].store.Height())
  182. rts.start(ctx, t)
  183. secondaryPool := rts.reactors[rts.nodes[1]].pool
  184. require.Eventually(
  185. t,
  186. func() bool {
  187. height, _, _ := secondaryPool.GetStatus()
  188. return secondaryPool.MaxPeerHeight() > 0 && height > 0 && height < 10
  189. },
  190. 10*time.Second,
  191. 10*time.Millisecond,
  192. "expected node to be partially synced",
  193. )
  194. // Remove synced node from the syncing node which should not result in any
  195. // deadlocks or race conditions within the context of poolRoutine.
  196. rts.peerChans[rts.nodes[1]] <- p2p.PeerUpdate{
  197. Status: p2p.PeerStatusDown,
  198. NodeID: rts.nodes[0],
  199. }
  200. rts.network.Nodes[rts.nodes[1]].PeerManager.Disconnected(ctx, rts.nodes[0])
  201. }
  202. func TestReactor_SyncTime(t *testing.T) {
  203. ctx, cancel := context.WithCancel(context.Background())
  204. defer cancel()
  205. cfg, err := config.ResetTestRoot(t.TempDir(), "block_sync_reactor_test")
  206. require.NoError(t, err)
  207. defer os.RemoveAll(cfg.RootDir)
  208. valSet, privVals := factory.ValidatorSet(ctx, t, 1, 30)
  209. genDoc := factory.GenesisDoc(cfg, time.Now(), valSet.Validators, nil)
  210. maxBlockHeight := int64(101)
  211. rts := setup(ctx, t, genDoc, privVals[0], []int64{maxBlockHeight, 0}, 0)
  212. require.Equal(t, maxBlockHeight, rts.reactors[rts.nodes[0]].store.Height())
  213. rts.start(ctx, t)
  214. require.Eventually(
  215. t,
  216. func() bool {
  217. return rts.reactors[rts.nodes[1]].GetRemainingSyncTime() > time.Nanosecond &&
  218. rts.reactors[rts.nodes[1]].pool.getLastSyncRate() > 0.001
  219. },
  220. 10*time.Second,
  221. 10*time.Millisecond,
  222. "expected node to be partially synced",
  223. )
  224. }
  225. func TestReactor_NoBlockResponse(t *testing.T) {
  226. ctx, cancel := context.WithCancel(context.Background())
  227. defer cancel()
  228. cfg, err := config.ResetTestRoot(t.TempDir(), "block_sync_reactor_test")
  229. require.NoError(t, err)
  230. defer os.RemoveAll(cfg.RootDir)
  231. valSet, privVals := factory.ValidatorSet(ctx, t, 1, 30)
  232. genDoc := factory.GenesisDoc(cfg, time.Now(), valSet.Validators, nil)
  233. maxBlockHeight := int64(65)
  234. rts := setup(ctx, t, genDoc, privVals[0], []int64{maxBlockHeight, 0}, 0)
  235. require.Equal(t, maxBlockHeight, rts.reactors[rts.nodes[0]].store.Height())
  236. rts.start(ctx, t)
  237. testCases := []struct {
  238. height int64
  239. existent bool
  240. }{
  241. {maxBlockHeight + 2, false},
  242. {10, true},
  243. {1, true},
  244. {100, false},
  245. }
  246. secondaryPool := rts.reactors[rts.nodes[1]].pool
  247. require.Eventually(
  248. t,
  249. func() bool { return secondaryPool.MaxPeerHeight() > 0 && secondaryPool.IsCaughtUp() },
  250. 10*time.Second,
  251. 10*time.Millisecond,
  252. "expected node to be fully synced",
  253. )
  254. for _, tc := range testCases {
  255. block := rts.reactors[rts.nodes[1]].store.LoadBlock(tc.height)
  256. if tc.existent {
  257. require.True(t, block != nil)
  258. } else {
  259. require.Nil(t, block)
  260. }
  261. }
  262. }
  263. func TestReactor_BadBlockStopsPeer(t *testing.T) {
  264. // Ultimately, this should be refactored to be less integration test oriented
  265. // and more unit test oriented by simply testing channel sends and receives.
  266. // See: https://github.com/tendermint/tendermint/issues/6005
  267. t.SkipNow()
  268. ctx, cancel := context.WithCancel(context.Background())
  269. defer cancel()
  270. cfg, err := config.ResetTestRoot(t.TempDir(), "block_sync_reactor_test")
  271. require.NoError(t, err)
  272. defer os.RemoveAll(cfg.RootDir)
  273. maxBlockHeight := int64(48)
  274. valSet, privVals := factory.ValidatorSet(ctx, t, 1, 30)
  275. genDoc := factory.GenesisDoc(cfg, time.Now(), valSet.Validators, nil)
  276. rts := setup(ctx, t, genDoc, privVals[0], []int64{maxBlockHeight, 0, 0, 0, 0}, 1000)
  277. require.Equal(t, maxBlockHeight, rts.reactors[rts.nodes[0]].store.Height())
  278. rts.start(ctx, t)
  279. require.Eventually(
  280. t,
  281. func() bool {
  282. caughtUp := true
  283. for _, id := range rts.nodes[1 : len(rts.nodes)-1] {
  284. if rts.reactors[id].pool.MaxPeerHeight() == 0 || !rts.reactors[id].pool.IsCaughtUp() {
  285. caughtUp = false
  286. }
  287. }
  288. return caughtUp
  289. },
  290. 10*time.Minute,
  291. 10*time.Millisecond,
  292. "expected all nodes to be fully synced",
  293. )
  294. for _, id := range rts.nodes[:len(rts.nodes)-1] {
  295. require.Len(t, rts.reactors[id].pool.peers, 3)
  296. }
  297. // Mark testSuites[3] as an invalid peer which will cause newSuite to disconnect
  298. // from this peer.
  299. //
  300. // XXX: This causes a potential race condition.
  301. // See: https://github.com/tendermint/tendermint/issues/6005
  302. valSet, otherPrivVals := factory.ValidatorSet(ctx, t, 1, 30)
  303. otherGenDoc := factory.GenesisDoc(cfg, time.Now(), valSet.Validators, nil)
  304. newNode := rts.network.MakeNode(ctx, t, p2ptest.NodeOptions{
  305. MaxPeers: uint16(len(rts.nodes) + 1),
  306. MaxConnected: uint16(len(rts.nodes) + 1),
  307. })
  308. rts.addNode(ctx, t, newNode.NodeID, otherGenDoc, otherPrivVals[0], maxBlockHeight)
  309. // add a fake peer just so we do not wait for the consensus ticker to timeout
  310. rts.reactors[newNode.NodeID].pool.SetPeerRange("00ff", 10, 10)
  311. // wait for the new peer to catch up and become fully synced
  312. require.Eventually(
  313. t,
  314. func() bool {
  315. return rts.reactors[newNode.NodeID].pool.MaxPeerHeight() > 0 && rts.reactors[newNode.NodeID].pool.IsCaughtUp()
  316. },
  317. 10*time.Minute,
  318. 10*time.Millisecond,
  319. "expected new node to be fully synced",
  320. )
  321. require.Eventuallyf(
  322. t,
  323. func() bool { return len(rts.reactors[newNode.NodeID].pool.peers) < len(rts.nodes)-1 },
  324. 10*time.Minute,
  325. 10*time.Millisecond,
  326. "invalid number of peers; expected < %d, got: %d",
  327. len(rts.nodes)-1,
  328. len(rts.reactors[newNode.NodeID].pool.peers),
  329. )
  330. }