Skip to content

Commit

Permalink
Merge pull request #2192 from OffchainLabs/fix-arbblockhash-pendingblock
Browse files Browse the repository at this point in the history
Add test to verify if arbBlockHash on pending block returns latest
  • Loading branch information
ganeshvanahalli committed Mar 18, 2024
2 parents 5d67b59 + 86e2ae7 commit f8a598c
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 24 deletions.
2 changes: 1 addition & 1 deletion go-ethereum
53 changes: 53 additions & 0 deletions system_tests/pendingblock_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
// Copyright 2021-2022, Offchain Labs, Inc.
// For license information, see https://github.com/nitro/blob/master/LICENSE

package arbtest

import (
"context"
"testing"
"time"

"github.com/offchainlabs/nitro/solgen/go/mocksgen"
)

func TestPendingBlockTimeAndNumberAdvance(t *testing.T) {
t.Parallel()
ctx, cancel := context.WithCancel(context.Background())
defer cancel()

builder := NewNodeBuilder(ctx).DefaultConfig(t, true)
cleanup := builder.Build(t)
defer cleanup()

auth := builder.L2Info.GetDefaultTransactOpts("Faucet", ctx)

_, _, testTimeAndNr, err := mocksgen.DeployPendingBlkTimeAndNrAdvanceCheck(&auth, builder.L2.Client)
Require(t, err)

time.Sleep(1 * time.Second)

_, err = testTimeAndNr.IsAdvancing(&auth)
Require(t, err)
}

func TestPendingBlockArbBlockHashReturnsLatest(t *testing.T) {
t.Parallel()
ctx, cancel := context.WithCancel(context.Background())
defer cancel()

builder := NewNodeBuilder(ctx).DefaultConfig(t, true)
cleanup := builder.Build(t)
defer cleanup()

auth := builder.L2Info.GetDefaultTransactOpts("Faucet", ctx)

_, _, pendingBlk, err := mocksgen.DeployPendingBlkTimeAndNrAdvanceCheck(&auth, builder.L2.Client)
Require(t, err)

header, err := builder.L2.Client.HeaderByNumber(ctx, nil)
Require(t, err)

_, err = pendingBlk.CheckArbBlockHashReturnsLatest(&auth, header.Hash())
Require(t, err)
}
22 changes: 0 additions & 22 deletions system_tests/rpc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@ import (
"context"
"path/filepath"
"testing"
"time"

"github.com/ethereum/go-ethereum/ethclient"
"github.com/offchainlabs/nitro/solgen/go/mocksgen"
)

func TestIpcRpc(t *testing.T) {
Expand All @@ -27,23 +25,3 @@ func TestIpcRpc(t *testing.T) {
_, err := ethclient.Dial(ipcPath)
Require(t, err)
}

func TestPendingBlockTimeAndNumberAdvance(t *testing.T) {
t.Parallel()
ctx, cancel := context.WithCancel(context.Background())
defer cancel()

builder := NewNodeBuilder(ctx).DefaultConfig(t, true)
cleanup := builder.Build(t)
defer cleanup()

auth := builder.L2Info.GetDefaultTransactOpts("Faucet", ctx)

_, _, testTimeAndNr, err := mocksgen.DeployPendingBlkTimeAndNrAdvanceCheck(&auth, builder.L2.Client)
Require(t, err)

time.Sleep(1 * time.Second)

_, err = testTimeAndNr.IsAdvancing(&auth)
Require(t, err)
}

0 comments on commit f8a598c

Please sign in to comment.