Skip to content

Commit

Permalink
flakiness: remove follower node TestSyncRoundWithRemake
Browse files Browse the repository at this point in the history
  • Loading branch information
Zeph Grunschlag committed May 23, 2023
1 parent 1abbd50 commit e481f47
Showing 1 changed file with 0 additions and 79 deletions.
79 changes: 0 additions & 79 deletions node/follower_node_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ package node
import (
"context"
"testing"
"time"

"github.com/sirupsen/logrus"
"github.com/sirupsen/logrus/hooks/test"
Expand Down Expand Up @@ -152,84 +151,6 @@ func TestDevModeWarning(t *testing.T) {
require.Contains(t, foundEntry.Message, "Follower running on a devMode network. Must submit txns to a different node.")
}

// TestSyncRoundWithRemake extends TestSyncRound to simulate starting and stopping the network
func TestSyncRoundWithRemake(t *testing.T) {
partitiontest.PartitionTest(t)
t.Parallel()

maxAcctLookback := uint64(10)

followNode, tempDir := remakeableFollowNode(t, "", maxAcctLookback)
addBlock := func(round basics.Round) {
b := bookkeeping.Block{
BlockHeader: bookkeeping.BlockHeader{
GenesisHash: followNode.ledger.GenesisHash(),
Round: round,
RewardsState: bookkeeping.RewardsState{
RewardsRate: 0,
RewardsPool: poolAddr,
FeeSink: sinkAddr,
},
},
}
b.CurrentProtocol = protocol.ConsensusCurrentVersion
err := followNode.Ledger().AddBlock(b, agreement.Certificate{})
require.NoError(t, err)

status, err := followNode.Status()
require.NoError(t, err)
require.Equal(t, round, status.LastRound)
}

// Part I. redo TestSyncRound
// main differences are:
// * cfg.DisableNetworking = true
// * cfg.MaxAcctLookback = 10 (instead of 4)

addBlock(basics.Round(1))

dbRound := uint64(followNode.Ledger().LatestTrackerCommitted())
// Sync Round should be initialized to the ledger's dbRound + 1
require.Equal(t, dbRound+1, followNode.GetSyncRound())
// Set a new sync round
require.NoError(t, followNode.SetSyncRound(dbRound+11))
// Ensure it is persisted
require.Equal(t, dbRound+11, followNode.GetSyncRound())
// Unset the sync round and make sure get returns 0
followNode.UnsetSyncRound()
require.Equal(t, uint64(0), followNode.GetSyncRound())

// Part II. fast forward and then remake the node

newRound := basics.Round(2 * maxAcctLookback)
for i := basics.Round(2); i <= newRound; i++ {
addBlock(i)
}

followNode, _ = remakeableFollowNode(t, tempDir, maxAcctLookback)

// Wait for follower to catch up. This rarely is needed, but can happen
// and cause flakey test failures. Timing out can still occur, but is less
// likely than the being caught behind a few rounds.
var status *StatusReport
require.Eventually(t, func() bool {
st, err := followNode.Status()
require.NoError(t, err)
if st.LastRound >= newRound {
status = &st
return true
}
return false
}, 20*time.Second, 500*time.Millisecond, "failed to reach newRound within the allowed time")

require.Equal(t, newRound, status.LastRound)

// syncRound should be at
// newRound - maxAcctLookback + 1 = maxAcctLookback + 1
syncRound := followNode.GetSyncRound()
require.Equal(t, uint64(maxAcctLookback+1), syncRound)
}

func TestFastCatchupResume(t *testing.T) {
partitiontest.PartitionTest(t)
t.Parallel()
Expand Down

0 comments on commit e481f47

Please sign in to comment.