Skip to content

Commit

Permalink
fix waitForSequencer usage
Browse files Browse the repository at this point in the history
  • Loading branch information
rachel-bousfield committed May 3, 2024
1 parent 9831b4a commit 18d70df
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 10 deletions.
30 changes: 24 additions & 6 deletions system_tests/program_norace_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,26 @@ import (
"github.com/offchainlabs/nitro/util/testhelpers"
)

func blockIsEmpty(block *types.Block) bool {
for _, tx := range block.Transactions() {
if tx.Type() != types.ArbitrumInternalTxType {
return false
}
}
return true
}

func nonEmptyBlockHeight(t *testing.T, builder *NodeBuilder) uint64 {
latestBlock, err := builder.L2.Client.BlockByNumber(builder.ctx, nil)
Require(t, err)
for blockIsEmpty(latestBlock) {
prior := arbmath.BigSubByUint(latestBlock.Number(), 1)
latestBlock, err = builder.L2.Client.BlockByNumber(builder.ctx, prior)
Require(t, err)
}
return latestBlock.NumberU64()
}

// used in program test
func validateBlocks(
t *testing.T, start uint64, jit bool, builder *NodeBuilder,
Expand All @@ -34,9 +54,7 @@ func validateBlocks(
start = 1
}

blockHeight, err := builder.L2.Client.BlockNumber(builder.ctx)
Require(t, err)

blockHeight := nonEmptyBlockHeight(t, builder)
blocks := []uint64{}
for i := start; i <= blockHeight; i++ {
blocks = append(blocks, i)
Expand All @@ -50,18 +68,18 @@ func validateBlockRange(
builder *NodeBuilder,
) {
ctx := builder.ctx
waitForSequencer(t, builder, arbmath.MaxInt(blocks...))
blockHeight, err := builder.L2.Client.BlockNumber(ctx)
Require(t, err)

// validate everything
if jit {
blockHeight := nonEmptyBlockHeight(t, builder)
blocks = []uint64{}
for i := uint64(1); i <= blockHeight; i++ {
blocks = append(blocks, i)
}
}

waitForSequencer(t, builder, arbmath.MaxInt(blocks...))

success := true
wasmModuleRoot := currentRootModule(t)
for _, block := range blocks {
Expand Down
6 changes: 2 additions & 4 deletions system_tests/program_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -930,7 +930,7 @@ func testMemory(t *testing.T, jit bool) {
validateBlocks(t, 3, jit, builder)
t.Skip("Succeeded up to here. Diagnose tests with larger numbers of blocks later.")
}
/*// check edge case where memory doesn't require `pay_for_memory_grow`
// check edge case where memory doesn't require `pay_for_memory_grow`
tx = l2info.PrepareTxTo("Owner", &growFixed, 1e9, nil, args)
ensure(tx, l2client.SendTransaction(ctx, tx))

Expand Down Expand Up @@ -965,9 +965,7 @@ func testMemory(t *testing.T, jit bool) {
} else {
expectFailure(memWrite, args, nil)
}
}*/
_ = memWrite
_ = growFixed
}

validateBlocks(t, 3, jit, builder)
}
Expand Down

0 comments on commit 18d70df

Please sign in to comment.