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.

404 lines
12 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
6 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/eventbus"
  15. "github.com/tendermint/tendermint/internal/mempool/mock"
  16. "github.com/tendermint/tendermint/internal/p2p"
  17. "github.com/tendermint/tendermint/internal/p2p/p2ptest"
  18. "github.com/tendermint/tendermint/internal/proxy"
  19. sm "github.com/tendermint/tendermint/internal/state"
  20. sf "github.com/tendermint/tendermint/internal/state/test/factory"
  21. "github.com/tendermint/tendermint/internal/store"
  22. "github.com/tendermint/tendermint/internal/test/factory"
  23. "github.com/tendermint/tendermint/libs/log"
  24. bcproto "github.com/tendermint/tendermint/proto/tendermint/blocksync"
  25. "github.com/tendermint/tendermint/types"
  26. )
  27. type reactorTestSuite struct {
  28. network *p2ptest.Network
  29. logger log.Logger
  30. nodes []types.NodeID
  31. reactors map[types.NodeID]*Reactor
  32. app map[types.NodeID]abciclient.Client
  33. blockSyncChannels map[types.NodeID]*p2p.Channel
  34. peerChans map[types.NodeID]chan p2p.PeerUpdate
  35. peerUpdates map[types.NodeID]*p2p.PeerUpdates
  36. blockSync bool
  37. }
  38. func setup(
  39. ctx context.Context,
  40. t *testing.T,
  41. genDoc *types.GenesisDoc,
  42. privVal types.PrivValidator,
  43. maxBlockHeights []int64,
  44. chBuf uint,
  45. ) *reactorTestSuite {
  46. t.Helper()
  47. var cancel context.CancelFunc
  48. ctx, cancel = context.WithCancel(ctx)
  49. numNodes := len(maxBlockHeights)
  50. require.True(t, numNodes >= 1,
  51. "must specify at least one block height (nodes)")
  52. rts := &reactorTestSuite{
  53. logger: log.TestingLogger().With("module", "block_sync", "testCase", t.Name()),
  54. network: p2ptest.MakeNetwork(ctx, t, p2ptest.NetworkOptions{NumNodes: numNodes}),
  55. nodes: make([]types.NodeID, 0, numNodes),
  56. reactors: make(map[types.NodeID]*Reactor, numNodes),
  57. app: make(map[types.NodeID]abciclient.Client, numNodes),
  58. blockSyncChannels: make(map[types.NodeID]*p2p.Channel, numNodes),
  59. peerChans: make(map[types.NodeID]chan p2p.PeerUpdate, numNodes),
  60. peerUpdates: make(map[types.NodeID]*p2p.PeerUpdates, numNodes),
  61. blockSync: true,
  62. }
  63. chDesc := &p2p.ChannelDescriptor{ID: BlockSyncChannel, MessageType: new(bcproto.Message)}
  64. rts.blockSyncChannels = rts.network.MakeChannelsNoCleanup(ctx, t, chDesc)
  65. i := 0
  66. for nodeID := range rts.network.Nodes {
  67. rts.addNode(ctx, t, nodeID, genDoc, privVal, maxBlockHeights[i])
  68. i++
  69. }
  70. t.Cleanup(func() {
  71. cancel()
  72. for _, nodeID := range rts.nodes {
  73. if rts.reactors[nodeID].IsRunning() {
  74. rts.reactors[nodeID].Wait()
  75. rts.app[nodeID].Wait()
  76. require.False(t, rts.reactors[nodeID].IsRunning())
  77. }
  78. }
  79. })
  80. t.Cleanup(leaktest.Check(t))
  81. return rts
  82. }
  83. func (rts *reactorTestSuite) addNode(
  84. ctx context.Context,
  85. t *testing.T,
  86. nodeID types.NodeID,
  87. genDoc *types.GenesisDoc,
  88. privVal types.PrivValidator,
  89. maxBlockHeight int64,
  90. ) {
  91. t.Helper()
  92. logger := log.TestingLogger()
  93. rts.nodes = append(rts.nodes, nodeID)
  94. rts.app[nodeID] = proxy.New(abciclient.NewLocalClient(logger, &abci.BaseApplication{}), logger, proxy.NopMetrics())
  95. require.NoError(t, rts.app[nodeID].Start(ctx))
  96. blockDB := dbm.NewMemDB()
  97. stateDB := dbm.NewMemDB()
  98. stateStore := sm.NewStore(stateDB)
  99. blockStore := store.NewBlockStore(blockDB)
  100. state, err := sm.MakeGenesisState(genDoc)
  101. require.NoError(t, err)
  102. require.NoError(t, stateStore.Save(state))
  103. eventbus := eventbus.NewDefault(logger)
  104. require.NoError(t, eventbus.Start(ctx))
  105. blockExec := sm.NewBlockExecutor(
  106. stateStore,
  107. log.TestingLogger(),
  108. rts.app[nodeID],
  109. mock.Mempool{},
  110. sm.EmptyEvidencePool{},
  111. blockStore,
  112. eventbus,
  113. )
  114. for blockHeight := int64(1); blockHeight <= maxBlockHeight; blockHeight++ {
  115. lastCommit := types.NewCommit(blockHeight-1, 0, types.BlockID{}, nil)
  116. if blockHeight > 1 {
  117. lastBlockMeta := blockStore.LoadBlockMeta(blockHeight - 1)
  118. lastBlock := blockStore.LoadBlock(blockHeight - 1)
  119. vote, err := factory.MakeVote(
  120. ctx,
  121. privVal,
  122. lastBlock.Header.ChainID, 0,
  123. lastBlock.Header.Height, 0, 2,
  124. lastBlockMeta.BlockID,
  125. time.Now(),
  126. )
  127. require.NoError(t, err)
  128. lastCommit = types.NewCommit(
  129. vote.Height,
  130. vote.Round,
  131. lastBlockMeta.BlockID,
  132. []types.CommitSig{vote.CommitSig()},
  133. )
  134. }
  135. thisBlock, err := sf.MakeBlock(state, blockHeight, lastCommit)
  136. require.NoError(t, err)
  137. thisParts, err := thisBlock.MakePartSet(types.BlockPartSizeBytes)
  138. require.NoError(t, err)
  139. blockID := types.BlockID{Hash: thisBlock.Hash(), PartSetHeader: thisParts.Header()}
  140. state, err = blockExec.ApplyBlock(ctx, state, blockID, thisBlock)
  141. require.NoError(t, err)
  142. blockStore.SaveBlock(thisBlock, thisParts, lastCommit)
  143. }
  144. rts.peerChans[nodeID] = make(chan p2p.PeerUpdate)
  145. rts.peerUpdates[nodeID] = p2p.NewPeerUpdates(rts.peerChans[nodeID], 1)
  146. rts.network.Nodes[nodeID].PeerManager.Register(ctx, rts.peerUpdates[nodeID])
  147. chCreator := func(ctx context.Context, chdesc *p2p.ChannelDescriptor) (*p2p.Channel, error) {
  148. return rts.blockSyncChannels[nodeID], nil
  149. }
  150. rts.reactors[nodeID], err = NewReactor(
  151. ctx,
  152. rts.logger.With("nodeID", nodeID),
  153. stateStore,
  154. blockExec,
  155. blockStore,
  156. nil,
  157. chCreator,
  158. rts.peerUpdates[nodeID],
  159. rts.blockSync,
  160. consensus.NopMetrics(),
  161. nil, // eventbus, can be nil
  162. )
  163. require.NoError(t, err)
  164. require.NoError(t, rts.reactors[nodeID].Start(ctx))
  165. require.True(t, rts.reactors[nodeID].IsRunning())
  166. }
  167. func (rts *reactorTestSuite) start(ctx context.Context, t *testing.T) {
  168. t.Helper()
  169. rts.network.Start(ctx, t)
  170. require.Len(t,
  171. rts.network.RandomNode().PeerManager.Peers(),
  172. len(rts.nodes)-1,
  173. "network does not have expected number of nodes")
  174. }
  175. func TestReactor_AbruptDisconnect(t *testing.T) {
  176. ctx, cancel := context.WithCancel(context.Background())
  177. defer cancel()
  178. cfg, err := config.ResetTestRoot(t.TempDir(), "block_sync_reactor_test")
  179. require.NoError(t, err)
  180. defer os.RemoveAll(cfg.RootDir)
  181. valSet, privVals := factory.ValidatorSet(ctx, t, 1, 30)
  182. genDoc := factory.GenesisDoc(cfg, time.Now(), valSet.Validators, nil)
  183. maxBlockHeight := int64(64)
  184. rts := setup(ctx, t, genDoc, privVals[0], []int64{maxBlockHeight, 0}, 0)
  185. require.Equal(t, maxBlockHeight, rts.reactors[rts.nodes[0]].store.Height())
  186. rts.start(ctx, t)
  187. secondaryPool := rts.reactors[rts.nodes[1]].pool
  188. require.Eventually(
  189. t,
  190. func() bool {
  191. height, _, _ := secondaryPool.GetStatus()
  192. return secondaryPool.MaxPeerHeight() > 0 && height > 0 && height < 10
  193. },
  194. 10*time.Second,
  195. 10*time.Millisecond,
  196. "expected node to be partially synced",
  197. )
  198. // Remove synced node from the syncing node which should not result in any
  199. // deadlocks or race conditions within the context of poolRoutine.
  200. rts.peerChans[rts.nodes[1]] <- p2p.PeerUpdate{
  201. Status: p2p.PeerStatusDown,
  202. NodeID: rts.nodes[0],
  203. }
  204. rts.network.Nodes[rts.nodes[1]].PeerManager.Disconnected(ctx, rts.nodes[0])
  205. }
  206. func TestReactor_SyncTime(t *testing.T) {
  207. ctx, cancel := context.WithCancel(context.Background())
  208. defer cancel()
  209. cfg, err := config.ResetTestRoot(t.TempDir(), "block_sync_reactor_test")
  210. require.NoError(t, err)
  211. defer os.RemoveAll(cfg.RootDir)
  212. valSet, privVals := factory.ValidatorSet(ctx, t, 1, 30)
  213. genDoc := factory.GenesisDoc(cfg, time.Now(), valSet.Validators, nil)
  214. maxBlockHeight := int64(101)
  215. rts := setup(ctx, t, genDoc, privVals[0], []int64{maxBlockHeight, 0}, 0)
  216. require.Equal(t, maxBlockHeight, rts.reactors[rts.nodes[0]].store.Height())
  217. rts.start(ctx, t)
  218. require.Eventually(
  219. t,
  220. func() bool {
  221. return rts.reactors[rts.nodes[1]].GetRemainingSyncTime() > time.Nanosecond &&
  222. rts.reactors[rts.nodes[1]].pool.getLastSyncRate() > 0.001
  223. },
  224. 10*time.Second,
  225. 10*time.Millisecond,
  226. "expected node to be partially synced",
  227. )
  228. }
  229. func TestReactor_NoBlockResponse(t *testing.T) {
  230. ctx, cancel := context.WithCancel(context.Background())
  231. defer cancel()
  232. cfg, err := config.ResetTestRoot(t.TempDir(), "block_sync_reactor_test")
  233. require.NoError(t, err)
  234. defer os.RemoveAll(cfg.RootDir)
  235. valSet, privVals := factory.ValidatorSet(ctx, t, 1, 30)
  236. genDoc := factory.GenesisDoc(cfg, time.Now(), valSet.Validators, nil)
  237. maxBlockHeight := int64(65)
  238. rts := setup(ctx, t, genDoc, privVals[0], []int64{maxBlockHeight, 0}, 0)
  239. require.Equal(t, maxBlockHeight, rts.reactors[rts.nodes[0]].store.Height())
  240. rts.start(ctx, t)
  241. testCases := []struct {
  242. height int64
  243. existent bool
  244. }{
  245. {maxBlockHeight + 2, false},
  246. {10, true},
  247. {1, true},
  248. {100, false},
  249. }
  250. secondaryPool := rts.reactors[rts.nodes[1]].pool
  251. require.Eventually(
  252. t,
  253. func() bool { return secondaryPool.MaxPeerHeight() > 0 && secondaryPool.IsCaughtUp() },
  254. 10*time.Second,
  255. 10*time.Millisecond,
  256. "expected node to be fully synced",
  257. )
  258. for _, tc := range testCases {
  259. block := rts.reactors[rts.nodes[1]].store.LoadBlock(tc.height)
  260. if tc.existent {
  261. require.True(t, block != nil)
  262. } else {
  263. require.Nil(t, block)
  264. }
  265. }
  266. }
  267. func TestReactor_BadBlockStopsPeer(t *testing.T) {
  268. // Ultimately, this should be refactored to be less integration test oriented
  269. // and more unit test oriented by simply testing channel sends and receives.
  270. // See: https://github.com/tendermint/tendermint/issues/6005
  271. t.SkipNow()
  272. ctx, cancel := context.WithCancel(context.Background())
  273. defer cancel()
  274. cfg, err := config.ResetTestRoot(t.TempDir(), "block_sync_reactor_test")
  275. require.NoError(t, err)
  276. defer os.RemoveAll(cfg.RootDir)
  277. maxBlockHeight := int64(48)
  278. valSet, privVals := factory.ValidatorSet(ctx, t, 1, 30)
  279. genDoc := factory.GenesisDoc(cfg, time.Now(), valSet.Validators, nil)
  280. rts := setup(ctx, t, genDoc, privVals[0], []int64{maxBlockHeight, 0, 0, 0, 0}, 1000)
  281. require.Equal(t, maxBlockHeight, rts.reactors[rts.nodes[0]].store.Height())
  282. rts.start(ctx, t)
  283. require.Eventually(
  284. t,
  285. func() bool {
  286. caughtUp := true
  287. for _, id := range rts.nodes[1 : len(rts.nodes)-1] {
  288. if rts.reactors[id].pool.MaxPeerHeight() == 0 || !rts.reactors[id].pool.IsCaughtUp() {
  289. caughtUp = false
  290. }
  291. }
  292. return caughtUp
  293. },
  294. 10*time.Minute,
  295. 10*time.Millisecond,
  296. "expected all nodes to be fully synced",
  297. )
  298. for _, id := range rts.nodes[:len(rts.nodes)-1] {
  299. require.Len(t, rts.reactors[id].pool.peers, 3)
  300. }
  301. // Mark testSuites[3] as an invalid peer which will cause newSuite to disconnect
  302. // from this peer.
  303. //
  304. // XXX: This causes a potential race condition.
  305. // See: https://github.com/tendermint/tendermint/issues/6005
  306. valSet, otherPrivVals := factory.ValidatorSet(ctx, t, 1, 30)
  307. otherGenDoc := factory.GenesisDoc(cfg, time.Now(), valSet.Validators, nil)
  308. newNode := rts.network.MakeNode(ctx, t, p2ptest.NodeOptions{
  309. MaxPeers: uint16(len(rts.nodes) + 1),
  310. MaxConnected: uint16(len(rts.nodes) + 1),
  311. })
  312. rts.addNode(ctx, t, newNode.NodeID, otherGenDoc, otherPrivVals[0], maxBlockHeight)
  313. // add a fake peer just so we do not wait for the consensus ticker to timeout
  314. rts.reactors[newNode.NodeID].pool.SetPeerRange("00ff", 10, 10)
  315. // wait for the new peer to catch up and become fully synced
  316. require.Eventually(
  317. t,
  318. func() bool {
  319. return rts.reactors[newNode.NodeID].pool.MaxPeerHeight() > 0 && rts.reactors[newNode.NodeID].pool.IsCaughtUp()
  320. },
  321. 10*time.Minute,
  322. 10*time.Millisecond,
  323. "expected new node to be fully synced",
  324. )
  325. require.Eventuallyf(
  326. t,
  327. func() bool { return len(rts.reactors[newNode.NodeID].pool.peers) < len(rts.nodes)-1 },
  328. 10*time.Minute,
  329. 10*time.Millisecond,
  330. "invalid number of peers; expected < %d, got: %d",
  331. len(rts.nodes)-1,
  332. len(rts.reactors[newNode.NodeID].pool.peers),
  333. )
  334. }