Skip to content

Commit

Permalink
add comments
Browse files Browse the repository at this point in the history
  • Loading branch information
vgonkivs committed Sep 28, 2023
1 parent 555ee1e commit 8a60421
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions nodebuilder/tests/fraud_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ func TestFraudProofHandling(t *testing.T) {
getCancel()

require.NoError(t, err)
require.NotNil(t, proofs)
require.Len(t, proofs, 1)
require.True(t, proofs[0].Type() == byzantine.BadEncoding)
// This is an obscure way to check if the Syncer was stopped.
Expand All @@ -121,8 +120,16 @@ func TestFraudProofHandling(t *testing.T) {
// lifecycles of each Module.
// 6.
attempts := 0
timeOut := blockTime * 5
// random height after befp.height
height := uint64(15)
// initial timeout is set to 5 sec, as we are targeting the height=15,
// blockTime=1 sec, expected befp height=10
timeOut := blockTime * 5

// during befp validation the node can still receive headers and it mostly depends on
// the operating system or hardware(e.g. on macOS tests is working 100% time with a single height=15,
// and on the Linux VM sometimes the last height is 17-18). So, lets give a chance for our befp validator to check
// the fraud proof and stop the syncer.
for attempts < 5 {
syncCtx, syncCancel := context.WithTimeout(context.Background(), timeOut)
_, err = full.HeaderServ.WaitForHeight(syncCtx, height)
Expand All @@ -134,9 +141,8 @@ func TestFraudProofHandling(t *testing.T) {
timeOut = blockTime
height++
}

require.NotNil(t, err)
require.ErrorIs(t, err, context.DeadlineExceeded)

// 7.
cfg = nodebuilder.DefaultConfig(node.Light)
cfg.Header.TrustedPeers = append(cfg.Header.TrustedPeers, addrs[0].String())
Expand Down

0 comments on commit 8a60421

Please sign in to comment.