Skip to content

Commit

Permalink
fix: signal test
Browse files Browse the repository at this point in the history
Signed-off-by: gfanton <[email protected]>
  • Loading branch information
gfanton committed Oct 10, 2023
1 parent 010cda3 commit 308edfa
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions tm2/pkg/bft/node/node_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,28 +111,32 @@ func TestNodeDelayedStart(t *testing.T) {
func TestNodeFirstBlockSignal(t *testing.T) {
config := cfg.ResetTestRoot("node_node_test")
defer os.RemoveAll(config.RootDir)
now := tmtime.Now()

// create & start node
// Create & start node
n, err := DefaultNewNode(config, log.TestingLogger())
require.NoError(t, err)

// add a small delay to genesis time
n.GenesisDoc().GenesisTime = now.Add(time.Second)
require.NoError(t, err)
// Assert that blockstore is 0 before waiting for the first block
require.Equal(t, int64(0), n.BlockStore().Height())

// Assert that first block signal is not alreay received
select {
case <-n.FirstBlockReceived():
require.FailNow(t, "firstblock signal should not be close before starting the node")
default: // ok
}

err = n.Start()
require.NoError(t, err)

defer n.Stop()

select {
case <-n.FirstBlockReceived():
case <-time.After(time.Second * 6):
case <-n.FirstBlockReceived(): // ready
case <-time.After(time.Second):
require.FailNow(t, "timeout while waiting for first block signal")
}

// Check that blockstore have at last 1 height size.
// Check that blockstore have at last 1 height size
require.GreaterOrEqual(t, n.BlockStore().Height(), int64(1))
}

Expand Down

0 comments on commit 308edfa

Please sign in to comment.