Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
hamdiallam committed Jan 16, 2025
1 parent 2586607 commit 0e2e1c6
Show file tree
Hide file tree
Showing 8 changed files with 1,253 additions and 3,298 deletions.
2 changes: 1 addition & 1 deletion Justfile
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ calculate-artifact-url:
echo "https://storage.googleapis.com/oplabs-contract-artifacts/artifacts-v1-$checksum.tar.gz"
generate-monorepo-bindings: install-abigen
./scripts/generate-bindings.sh -u $(just calculate-artifact-url) -n CrossL2Inbox,L2ToL2CrossDomainMessenger,L1BlockInterop,OptimismSuperchainERC20,SuperchainWETH,SuperchainTokenBridge -o ./bindings
./scripts/generate-bindings.sh -u $(just calculate-artifact-url) -n CrossL2Inbox,L2ToL2CrossDomainMessenger,L1BlockInterop,SuperchainERC20,SuperchainWETH,SuperchainTokenBridge -o ./bindings

generate-genesis: build-contracts
go run ./genesis/cmd/main.go --monorepo-artifacts $(just calculate-artifact-url) --periphery-artifacts ./contracts/out --outdir ./genesis/generated
Expand Down
1,755 changes: 0 additions & 1,755 deletions bindings/OptimismSuperchainERC20.go

This file was deleted.

1,237 changes: 1,237 additions & 0 deletions bindings/SuperchainERC20.go

Large diffs are not rendered by default.

1,516 changes: 0 additions & 1,516 deletions bindings/l2nativesuperchainerc20.go

This file was deleted.

9 changes: 0 additions & 9 deletions bindings/l2tol2crossdomainmessenger.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion bindings/parsedabi.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ func MustParseABI(abiStr string) *abi.ABI {
}

var SimpleStorageParsedABI = MustParseABI(SimpleStorageMetaData.ABI)
var L2NativeSuperchainERC20ParseABI = MustParseABI(L2NativeSuperchainERC20MetaData.ABI)

var CrossL2InboxParsedABI = MustParseABI(CrossL2InboxMetaData.ABI)
var L1BlockInteropParsedABI = MustParseABI(L1BlockInteropMetaData.ABI)
Expand Down
3 changes: 2 additions & 1 deletion interop/indexer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ var header = types.Header{
Number: big.NewInt(int64(blockNumber)),
Time: timestamp,
}
var block = types.NewBlock(&header, nil, nil, types.TrieHasher((*trie.StackTrie)(nil)))

var block = types.NewBlock(&header, nil, nil, types.TrieHasher((*trie.StackTrie)(nil)), types.DefaultBlockConfig)

var sentMessage = &L2ToL2Message{
Destination: destinationChainID,
Expand Down
28 changes: 13 additions & 15 deletions supersim_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package supersim

import (
"context"
"math"
"math/big"
"strings"
"sync"
Expand All @@ -23,7 +24,7 @@ import (
"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/common/math"
gethmath "github.com/ethereum/go-ethereum/common/math"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/ethclient"
Expand Down Expand Up @@ -213,7 +214,7 @@ func TestStartup(t *testing.T) {
l2Client, err := rpc.Dial(chain.Endpoint())
require.NoError(t, err)

var chainId math.HexOrDecimal64
var chainId gethmath.HexOrDecimal64
require.NoError(t, l2Client.CallContext(context.Background(), &chainId, "eth_chainId"))
require.Equal(t, chain.Config().ChainID, uint64(chainId))

Expand All @@ -224,7 +225,7 @@ func TestStartup(t *testing.T) {
l1Client, err := rpc.Dial(testSuite.Supersim.Orchestrator.L1Chain().Endpoint())
require.NoError(t, err)

var chainId math.HexOrDecimal64
var chainId gethmath.HexOrDecimal64
require.NoError(t, l1Client.CallContext(context.Background(), &chainId, "eth_chainId"))
require.Equal(t, testSuite.Supersim.Orchestrator.L1Chain().Config().ChainID, uint64(chainId))

Expand Down Expand Up @@ -489,7 +490,7 @@ func TestBatchJsonRpcRequestErrorHandling(t *testing.T) {
require.NoError(t, err)

// Create a bad executing message that will throw an error using CrossL2Inbox
executeMessageNonce, err := testSuite.DestEthClient.PendingNonceAt(context.Background(), fromAddress)
nonce, err := testSuite.DestEthClient.PendingNonceAt(context.Background(), fromAddress)
require.NoError(t, err)
initiatingMessageBlockHeader, err := testSuite.SourceEthClient.HeaderByNumber(context.Background(), initiatingMessageTxReceipt.BlockNumber)
require.NoError(t, err)
Expand All @@ -501,17 +502,17 @@ func TestBatchJsonRpcRequestErrorHandling(t *testing.T) {
Timestamp: new(big.Int).Sub(new(big.Int).SetUint64(initiatingMessageBlockHeader.Time), big.NewInt(1)),
ChainId: testSuite.SourceChainID,
}
executeMessageCallData, err := bindings.CrossL2InboxParsedABI.Pack("executeMessage", identifier, fromAddress, initiatingMessageLog.Data)
validateMessageCallData, err := bindings.CrossL2InboxParsedABI.Pack("validateMessage", identifier, initiatingMessageLog.Data)
require.NoError(t, err)
executeMessageTx := types.NewTransaction(executeMessageNonce, predeploys.CrossL2InboxAddr, big.NewInt(0), gasLimit, gasPrice, executeMessageCallData)
validateMessageTx := types.NewTransaction(nonce, predeploys.CrossL2InboxAddr, big.NewInt(0), gasLimit, gasPrice, validateMessageCallData)
require.NoError(t, err)
executeMessageSignedTx, err := types.SignTx(executeMessageTx, types.NewEIP155Signer(testSuite.DestChainID), privateKey)
validateMessageSignedTx, err := types.SignTx(validateMessageTx, types.NewEIP155Signer(testSuite.DestChainID), privateKey)
require.NoError(t, err)
executeMessageTxData, err := executeMessageSignedTx.MarshalBinary()
validateMessageTxData, err := validateMessageSignedTx.MarshalBinary()
require.NoError(t, err)
var chainIdError error
var sendRawTxError error
elems := []rpc.BatchElem{{Method: "eth_chainId", Result: new(hexutil.Uint64), Error: chainIdError}, {Method: "eth_sendRawTransaction", Args: []interface{}{hexutil.Encode(executeMessageTxData)}, Result: new(string), Error: sendRawTxError}}
elems := []rpc.BatchElem{{Method: "eth_chainId", Result: new(hexutil.Uint64), Error: chainIdError}, {Method: "eth_sendRawTransaction", Args: []interface{}{hexutil.Encode(validateMessageTxData)}, Result: new(string), Error: sendRawTxError}}

require.NoError(t, testSuite.DestEthClient.Client().BatchCallContext(context.Background(), elems))
require.Nil(t, elems[0].Error)
Expand Down Expand Up @@ -581,7 +582,6 @@ func TestInteropInvariantCheckFailsBadLogIndex(t *testing.T) {

privateKey, err := testSuite.DevKeys.Secret(devkeys.UserKey(0))
require.NoError(t, err)
fromAddress := crypto.PubkeyToAddress(privateKey.PublicKey)

l2ToL2CrossDomainMessenger, err := bindings.NewL2ToL2CrossDomainMessenger(predeploys.L2toL2CrossDomainMessengerAddr, testSuite.SourceEthClient)
require.NoError(t, err)
Expand Down Expand Up @@ -624,7 +624,7 @@ func TestInteropInvariantCheckFailsBadLogIndex(t *testing.T) {
require.NoError(t, err)

// Should fail because the block number is incorrect
_, err = crossL2Inbox.ExecuteMessage(transactor, identifier, fromAddress, initiatingMessageLog.Data)
_, err = crossL2Inbox.ValidateMessage(transactor, identifier, crypto.Keccak256Hash(initiatingMessageLog.Data))
require.Error(t, err)
}

Expand All @@ -634,7 +634,6 @@ func TestInteropInvariantCheckBadBlockNumber(t *testing.T) {

privateKey, err := testSuite.DevKeys.Secret(devkeys.UserKey(0))
require.NoError(t, err)
fromAddress := crypto.PubkeyToAddress(privateKey.PublicKey)

l2ToL2CrossDomainMessenger, err := bindings.NewL2ToL2CrossDomainMessenger(predeploys.L2toL2CrossDomainMessengerAddr, testSuite.SourceEthClient)
require.NoError(t, err)
Expand Down Expand Up @@ -677,7 +676,7 @@ func TestInteropInvariantCheckBadBlockNumber(t *testing.T) {
require.NoError(t, err)

// Should fail because the block number is incorrect
_, err = crossL2Inbox.ExecuteMessage(transactor, identifier, fromAddress, initiatingMessageLog.Data)
_, err = crossL2Inbox.ValidateMessage(transactor, identifier, crypto.Keccak256Hash(initiatingMessageLog.Data))
require.Error(t, err)
}

Expand All @@ -687,7 +686,6 @@ func TestInteropInvariantCheckBadBlockTimestamp(t *testing.T) {

privateKey, err := testSuite.DevKeys.Secret(devkeys.UserKey(0))
require.NoError(t, err)
fromAddress := crypto.PubkeyToAddress(privateKey.PublicKey)

l2ToL2CrossDomainMessenger, err := bindings.NewL2ToL2CrossDomainMessenger(predeploys.L2toL2CrossDomainMessengerAddr, testSuite.SourceEthClient)
require.NoError(t, err)
Expand Down Expand Up @@ -729,7 +727,7 @@ func TestInteropInvariantCheckBadBlockTimestamp(t *testing.T) {
require.NoError(t, err)

// Should fail because the block timestamp is incorrect
_, err = crossL2Inbox.ExecuteMessage(transactor, identifier, fromAddress, initiatingMessageLog.Data)
_, err = crossL2Inbox.ValidateMessage(transactor, identifier, crypto.Keccak256Hash(initiatingMessageLog.Data))
require.Error(t, err)
}

Expand Down

0 comments on commit 0e2e1c6

Please sign in to comment.