Skip to content
This repository has been archived by the owner on May 11, 2024. It is now read-only.

Commit

Permalink
test: more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
davidtaikocha committed Oct 29, 2023
1 parent 5d866fb commit 4532acb
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions bindings/encoding/input_test.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
package encoding

import (
"context"
"math/big"
"math/rand"
"os"
"testing"

"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/crypto"
"github.com/ethereum/go-ethereum/ethclient"
"github.com/stretchr/testify/require"
"github.com/taikoxyz/taiko-client/bindings"
)

func TestEncodeEvidence(t *testing.T) {
Expand Down Expand Up @@ -65,4 +71,40 @@ func TestUnpackTxListBytes(t *testing.T) {
),
)
require.ErrorContains(t, err, "no method with id")

cli, err := ethclient.Dial(os.Getenv("L1_NODE_WS_ENDPOINT"))
require.Nil(t, err)

chainID, err := cli.ChainID(context.Background())
require.Nil(t, err)

taikoL1, err := bindings.NewTaikoL1Client(
common.HexToAddress(os.Getenv("TAIKO_L1_ADDRESS")),
cli,
)
require.Nil(t, err)

l1ProposerPrivKey, err := crypto.ToECDSA(common.Hex2Bytes(os.Getenv("L1_PROPOSER_PRIVATE_KEY")))
require.Nil(t, err)

opts, err := bind.NewKeyedTransactorWithChainID(l1ProposerPrivKey, chainID)
require.Nil(t, err)

opts.NoSend = true
opts.GasLimit = randomHash().Big().Uint64()

txListBytes := randomBytes(1024)

tx, err := taikoL1.ProposeBlock(
opts,
randomHash(),
[32]byte(randomHash().Bytes()),
randomBytes(32),
txListBytes,
)
require.Nil(t, err)

b, err := UnpackTxListBytes(tx.Data())
require.Nil(t, err)
require.Equal(t, txListBytes, b)
}

0 comments on commit 4532acb

Please sign in to comment.