Skip to content

Commit

Permalink
Changes based on PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
amsanghi committed Jun 21, 2023
1 parent 37ff4e7 commit bc8e7bb
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions system_tests/block_validator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,16 @@ import (
"time"

"github.com/ethereum/go-ethereum"
"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/core/vm"

"github.com/offchainlabs/nitro/arbnode"
"github.com/offchainlabs/nitro/arbos/l2pricing"
"github.com/offchainlabs/nitro/solgen/go/mocksgen"
"github.com/offchainlabs/nitro/solgen/go/precompilesgen"
"github.com/offchainlabs/nitro/util/arbmath"
)

type workloadType uint
Expand Down Expand Up @@ -60,6 +63,7 @@ func testBlockValidatorSimple(t *testing.T, dasModeString string, workloadLoops

perTransfer := big.NewInt(1e12)

var simple *mocksgen.Simple
if workload != upgradeArbOs {
for i := 0; i < workloadLoops; i++ {
var tx *types.Transaction
Expand Down Expand Up @@ -108,6 +112,16 @@ func testBlockValidatorSimple(t *testing.T, dasModeString string, workloadLoops
}
} else {
auth := l2info.GetDefaultTransactOpts("Owner", ctx)
// deploy a test contract
var err error
_, _, simple, err = mocksgen.DeploySimple(&auth, l2client)
Require(t, err, "could not deploy contract")

difficulty, err := simple.GetBlockDifficulty(&bind.CallOpts{})
Require(t, err)
if !arbmath.BigEquals(difficulty, common.Big1) {
Fatal(t, "Expected difficulty to be 1 but got:", difficulty)
}
// make auth a chain owner
arbDebug, err := precompilesgen.NewArbDebug(common.HexToAddress("0xff"), l2client)
Require(t, err)
Expand All @@ -122,6 +136,12 @@ func testBlockValidatorSimple(t *testing.T, dasModeString string, workloadLoops
_, err = EnsureTxSucceeded(ctx, l2client, tx)
Require(t, err)

difficulty, err = simple.GetBlockDifficulty(&bind.CallOpts{})
Require(t, err)
if !arbmath.BigEquals(difficulty, common.Big1) {
Fatal(t, "Expected difficulty to be 1 but got:", difficulty)
}

tx = l2info.PrepareTxTo("Owner", nil, l2info.TransferGas, perTransfer, []byte{byte(vm.PUSH0)})
err = l2client.SendTransaction(ctx, tx)
Require(t, err)
Expand Down Expand Up @@ -157,6 +177,13 @@ func testBlockValidatorSimple(t *testing.T, dasModeString string, workloadLoops
Fatal(t, "Unexpected balance:", l2balance)
}
}
if workload == upgradeArbOs {
difficulty, err := simple.GetBlockDifficulty(&bind.CallOpts{})
Require(t, err)
if !arbmath.BigEquals(difficulty, common.Big1) {
Fatal(t, "Expected difficulty to be 1 but got:", difficulty)
}
}

lastBlock, err := l2clientB.BlockByNumber(ctx, nil)
Require(t, err)
Expand Down

0 comments on commit bc8e7bb

Please sign in to comment.