Skip to content

Commit

Permalink
tests(swamp): make fraud proof broadcasting test go
Browse files Browse the repository at this point in the history
  • Loading branch information
Wondertan committed Oct 6, 2022
1 parent e6ea8ee commit 290c64d
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions nodebuilder/tests/fraud_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,17 +56,18 @@ func TestFraudProofBroadcasting(t *testing.T) {
subscr, err := full.FraudServ.Subscribe(fraud.BadEncoding)
require.NoError(t, err)

_, err = subscr.Proof(ctx)
p, err := subscr.Proof(ctx)
require.NoError(t, err)

// Since GetByHeight is a blocking operation for headers that is not received, we
// should set a timeout because all daser/syncer are stopped at this point
newCtx, cancel := context.WithTimeout(context.Background(), time.Millisecond*500)
// rework this after https://github.com/celestiaorg/celestia-node/issues/427
t.Cleanup(cancel)

_, err = full.HeaderServ.GetByHeight(newCtx, 25)
require.Equal(t, 20, int(p.Height()))

// This is an obscure way to check if the Syncer was stopped.
// If we cannot get a height header within a timeframe it means the syncer was stopped
// FIXME: Eventually, this should be a check on service registry managing and keeping
// lifecycles of each Module.
syncCtx, syncCancel := context.WithTimeout(context.Background(), time.Millisecond*600)
_, err = full.HeaderServ.GetByHeight(syncCtx, 100)
require.ErrorIs(t, err, context.DeadlineExceeded)
syncCancel()

require.NoError(t, full.Stop(ctx))
require.NoError(t, sw.RemoveNode(full, node.Full))
Expand All @@ -93,7 +94,7 @@ Steps:
7. Wait until LN will be connected to FN and fetch a fraud proof.
*/
func TestFraudProofSyncing(t *testing.T) {
sw := swamp.NewSwamp(t, swamp.WithBlockTime(time.Millisecond*100))
sw := swamp.NewSwamp(t, swamp.WithBlockTime(time.Millisecond*300))

const defaultTimeInterval = time.Second * 5

Expand Down

0 comments on commit 290c64d

Please sign in to comment.