diff --git a/catchup/fetcher_test.go b/catchup/fetcher_test.go index 8c5cd2aae1..43ad7bc06e 100644 --- a/catchup/fetcher_test.go +++ b/catchup/fetcher_test.go @@ -256,6 +256,11 @@ func (p *testUnicastPeer) RoutingAddr() []byte { } func (p *testUnicastPeer) Request(ctx context.Context, tag protocol.Tag, topics network.Topics) (resp *network.Response, e error) { + select { + case <-ctx.Done(): + return resp, ctx.Err() + default: + } responseChannel := make(chan *network.Response, 1) p.responseChannels[0] = responseChannel diff --git a/ledger/catchpointfilewriter_test.go b/ledger/catchpointfilewriter_test.go index 7ffcd7b0d0..05874a53aa 100644 --- a/ledger/catchpointfilewriter_test.go +++ b/ledger/catchpointfilewriter_test.go @@ -849,6 +849,11 @@ func TestFullCatchpointWriter(t *testing.T) { // another approach is to modify the test and craft round numbers, // and make the ledger to generate catchpoint itself when it is time func testCatchpointFlushRound(l *Ledger) (basics.Round, basics.Round) { + // Ensure all blocks are persisted to the block DB before flushing trackers. + // Without this, LatestCommitted() may return a stale round if the blockQueue + // syncer hasn't finished yet. + l.WaitForCommit(l.Latest()) + // Clear the timer to ensure a flush l.trackers.mu.Lock() l.trackers.lastFlushTime = time.Time{} @@ -1036,6 +1041,7 @@ func TestCatchpointAfterTxns(t *testing.T) { catchpointDataFilePath := filepath.Join(tempDir, t.Name()+".data") catchpointFilePath := filepath.Join(tempDir, t.Name()+".catchpoint.tar.gz") + testCatchpointFlushRound(dl.validator) cph := testWriteCatchpoint(t, config.Consensus[proto], dl.validator.trackerDB(), catchpointDataFilePath, catchpointFilePath, 0, 0) require.EqualValues(t, 3, cph.TotalChunks) @@ -1052,6 +1058,7 @@ func TestCatchpointAfterTxns(t *testing.T) { dl.fullBlock(&newacctpay) // Write and read back in, and ensure even the last effect exists. + testCatchpointFlushRound(dl.validator) cph = testWriteCatchpoint(t, config.Consensus[proto], dl.validator.trackerDB(), catchpointDataFilePath, catchpointFilePath, 0, 0) require.EqualValues(t, cph.TotalChunks, 3) // Still only 3 chunks, as last was in a recent block @@ -1068,6 +1075,7 @@ func TestCatchpointAfterTxns(t *testing.T) { dl.fullBlock(pay.Noted(strconv.Itoa(i))) } + testCatchpointFlushRound(dl.validator) cph = testWriteCatchpoint(t, config.Consensus[proto], dl.validator.trackerDB(), catchpointDataFilePath, catchpointFilePath, 0, 0) require.EqualValues(t, cph.TotalChunks, 4) diff --git a/network/wsNetwork_test.go b/network/wsNetwork_test.go index 73b54c7d94..e0731f6d20 100644 --- a/network/wsNetwork_test.go +++ b/network/wsNetwork_test.go @@ -340,6 +340,7 @@ func setupWebsocketNetworkABwithLogger(t *testing.T, countTarget int, log loggin readyTimeout := time.NewTimer(5 * time.Second) waitReady(t, netA, readyTimeout.C) t.Log("a ready") + readyTimeout.Reset(5 * time.Second) waitReady(t, netB, readyTimeout.C) t.Log("b ready") diff --git a/test/e2e-go/cli/goal/expect/catchpointCatchupTest.exp b/test/e2e-go/cli/goal/expect/catchpointCatchupTest.exp index 7ba924f99d..9d0f3a8d8b 100644 --- a/test/e2e-go/cli/goal/expect/catchpointCatchupTest.exp +++ b/test/e2e-go/cli/goal/expect/catchpointCatchupTest.exp @@ -180,7 +180,7 @@ if { [catch { ::AlgorandGoal::StartNode $TEST_ROOT_DIR/Node False $WEBPROXY_LISTEN_ADDRESS # once the node is started we can clear the ::GLOBAL_TEST_ALGO_DIR, so that shutdown would be done as a network. - set ::GLOBAL_TEST_ALGO_DIR "" + unset ::GLOBAL_TEST_ALGO_DIR ::AlgorandGoal::WaitForRound $CATCHPOINT_ROUND $TEST_ROOT_DIR/Node