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

feat(test): Big improvements in test #418

Closed
wants to merge 28 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
276c1cc
feat: start docker for test
alexshliu Sep 26, 2023
21d67e9
feat: test
alexshliu Sep 27, 2023
80c8153
feat: finish docker build
alexshliu Sep 27, 2023
7ec3241
feat: docker L1/L2 image
alexshliu Sep 28, 2023
b91f436
Merge branch 'main' into test
alexshliu Sep 28, 2023
ed38b87
delete useless code
alexshliu Sep 28, 2023
ad253d4
feat: merge some testcase code
alexshliu Sep 28, 2023
8c90ef2
feat: merge suite.go code
alexshliu Sep 28, 2023
5d7db55
feat: change init order
alexshliu Sep 29, 2023
e02e2b3
feat: change some vars locations
alexshliu Sep 29, 2023
ff1cb76
fix: optimize code
alexshliu Sep 29, 2023
1fc6307
feat: tests pass
alexshliu Sep 29, 2023
32f4e94
feat: something need more test
alexshliu Sep 29, 2023
16d078f
feat: prepare for meger
alexshliu Sep 29, 2023
f9a21cd
Merge branch 'main' into test
alexshliu Sep 29, 2023
10aada4
feat: test pass
alexshliu Sep 29, 2023
9d83af1
feat: need more test
alexshliu Sep 29, 2023
792a6dc
feat: split rpc helper function
alexshliu Sep 30, 2023
eceb691
feat: shutdown fake prover
alexshliu Sep 30, 2023
c032a18
feat: big step
alexshliu Sep 30, 2023
b24c972
feat: all test pass
alexshliu Oct 1, 2023
f1c81fc
Merge branch 'main' into test
alexshliu Oct 1, 2023
e3f54e2
feat: some optimize
alexshliu Oct 1, 2023
2ae4549
fix: fix lint issue
alexshliu Oct 1, 2023
98919d1
feat: pull image before test
alexshliu Oct 1, 2023
3e14af5
feat: try to use -p=2 to run test
alexshliu Oct 1, 2023
cc8ff01
feat: try to use -p=1 to run test
alexshliu Oct 1, 2023
89c1497
feat: do not limit -p flag
alexshliu Oct 1, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,9 @@ lint:
&& golangci-lint run

test:
@TAIKO_MONO_DIR=${TAIKO_MONO_DIR} \
COMPILE_PROTOCOL=${COMPILE_PROTOCOL} \
PACKAGE=${PACKAGE} \
RUN_TESTS=true \
./integration_test/entrypoint.sh
docker pull ghcr.io/foundry-rs/foundry:latest \
&& docker pull gcr.io/evmchain/taiko-geth:taiko \
&& go test ./... -coverprofile=coverage.out -covermode=atomic -timeout=300s

dev_net:
@TAIKO_MONO_DIR=${TAIKO_MONO_DIR} \
Expand Down
36 changes: 21 additions & 15 deletions driver/anchor_tx_constructor/anchor_tx_constructor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,37 +3,46 @@ package anchorTxConstructor
import (
"context"
"math/big"
"os"
"testing"

"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/crypto"
"github.com/stretchr/testify/suite"
"github.com/taikoxyz/taiko-client/pkg/rpc"
"github.com/taikoxyz/taiko-client/testutils"
"github.com/taikoxyz/taiko-client/testutils/helper"
)

type AnchorTxConstructorTestSuite struct {
testutils.ClientTestSuite
l1Height *big.Int
l1Hash common.Hash
c *AnchorTxConstructor
l1Height *big.Int
l1Hash common.Hash
c *AnchorTxConstructor
rpcClient *rpc.Client
}

func (s *AnchorTxConstructorTestSuite) SetupTest() {
s.ClientTestSuite.SetupTest()
s.rpcClient = helper.NewWsRpcClient(&s.ClientTestSuite)

c, err := New(
s.RpcClient,
common.HexToAddress(os.Getenv("L1_SIGNAL_SERVICE_CONTRACT_ADDRESS")),
s.rpcClient,
s.L1.TaikoL1SignalService,
)
s.Nil(err)
head, err := s.RpcClient.L1.BlockByNumber(context.Background(), nil)
head, err := s.rpcClient.L1.BlockByNumber(context.Background(), nil)
s.Nil(err)
s.l1Height = head.Number()
s.l1Hash = head.Hash()
s.c = c
}

func (s *AnchorTxConstructorTestSuite) TearDownTest() {
s.rpcClient.Close()
s.ClientTestSuite.TearDownTest()
}

func (s *AnchorTxConstructorTestSuite) TestGasLimit() {
s.Greater(s.c.GasLimit(), uint64(0))
}
Expand All @@ -45,13 +54,10 @@ func (s *AnchorTxConstructorTestSuite) TestAssembleAnchorTx() {
}

func (s *AnchorTxConstructorTestSuite) TestNewAnchorTransactor() {
goldenTouchAddress, err := s.RpcClient.TaikoL2.GOLDENTOUCHADDRESS(nil)
goldenTouchAddress, err := s.rpcClient.TaikoL2.GOLDENTOUCHADDRESS(nil)
s.Nil(err)

c, err := New(
s.RpcClient,
common.HexToAddress(os.Getenv("L1_SIGNAL_SERVICE_CONTRACT_ADDRESS")),
)
c, err := New(s.rpcClient, s.L1.TaikoL1SignalService)
s.Nil(err)

opts, err := c.transactOpts(context.Background(), common.Big1, common.Big256)
Expand All @@ -74,7 +80,7 @@ func (s *AnchorTxConstructorTestSuite) TestCancelCtxTransactOpts() {
func (s *AnchorTxConstructorTestSuite) TestSign() {
// Payload 1
hash := hexutil.MustDecode("0x44943399d1507f3ce7525e9be2f987c3db9136dc759cb7f92f742154196868b9")
signatureBytes := testutils.SignatureFromRSV(
signatureBytes := helper.SignatureFromRSV(
"0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798",
"0x782a1e70872ecc1a9f740dd445664543f8b7598c94582720bca9a8c48d6a4766",
1,
Expand All @@ -89,7 +95,7 @@ func (s *AnchorTxConstructorTestSuite) TestSign() {

// Payload 2
hash = hexutil.MustDecode("0x663d210fa6dba171546498489de1ba024b89db49e21662f91bf83cdffe788820")
signatureBytes = testutils.SignatureFromRSV(
signatureBytes = helper.SignatureFromRSV(
"0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798",
"0x568130fab1a3a9e63261d4278a7e130588beb51f27de7c20d0258d38a85a27ff",
1,
Expand All @@ -104,7 +110,7 @@ func (s *AnchorTxConstructorTestSuite) TestSign() {
}

func (s *AnchorTxConstructorTestSuite) TestSignShortHash() {
rand := testutils.RandomHash().Bytes()
rand := helper.RandomHash().Bytes()
hash := rand[:len(rand)-2]
_, err := s.c.signTxPayload(hash)
s.ErrorContains(err, "hash is required to be exactly 32 bytes")
Expand Down
16 changes: 12 additions & 4 deletions driver/chain_syncer/beaconsync/progress_tracker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,26 @@ import (
"github.com/ethereum/go-ethereum"
"github.com/ethereum/go-ethereum/common"
"github.com/stretchr/testify/suite"
"github.com/taikoxyz/taiko-client/pkg/rpc"
"github.com/taikoxyz/taiko-client/testutils"
"github.com/taikoxyz/taiko-client/testutils/helper"
)

type BeaconSyncProgressTrackerTestSuite struct {
testutils.ClientTestSuite
t *SyncProgressTracker
t *SyncProgressTracker
rpcClient *rpc.Client
}

func (s *BeaconSyncProgressTrackerTestSuite) SetupTest() {
s.ClientTestSuite.SetupTest()
s.rpcClient = helper.NewWsRpcClient(&s.ClientTestSuite)
s.t = NewSyncProgressTracker(s.rpcClient.L2, 30*time.Second)
}

s.t = NewSyncProgressTracker(s.RpcClient.L2, 30*time.Second)
func (s *BeaconSyncProgressTrackerTestSuite) TearDownTest() {
s.rpcClient.Close()
s.ClientTestSuite.TearDownTest()
}

func (s *BeaconSyncProgressTrackerTestSuite) TestSyncProgressed() {
Expand Down Expand Up @@ -58,7 +66,7 @@ func (s *BeaconSyncProgressTrackerTestSuite) TestTrack() {

// Triggered
ctx, cancel = context.WithCancel(context.Background())
s.t.UpdateMeta(common.Big256, common.Big256, testutils.RandomHash())
s.t.UpdateMeta(common.Big256, common.Big256, helper.RandomHash())
go s.t.Track(ctx)
time.Sleep(syncProgressCheckInterval + 5*time.Second)
cancel()
Expand Down Expand Up @@ -101,7 +109,7 @@ func (s *BeaconSyncProgressTrackerTestSuite) TestLastSyncedVerifiedBlockHash() {
common.HexToHash("0x0000000000000000000000000000000000000000000000000000000000000000"),
s.t.LastSyncedVerifiedBlockHash(),
)
randomHash := testutils.RandomHash()
randomHash := helper.RandomHash()
s.t.lastSyncedVerifiedBlockHash = randomHash
s.Equal(randomHash, s.t.LastSyncedVerifiedBlockHash())
}
Expand Down
8 changes: 3 additions & 5 deletions driver/chain_syncer/calldata/syncer.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,8 @@ import (
txListValidator "github.com/taikoxyz/taiko-client/pkg/tx_list_validator"
)

var (
// Brecht recommends to hardcore 79, may be unrequired as proof system changes
defaultMaxTxPerBlock = uint64(79)
)
// Brecht recommends to hardcore 79, may be unrequired as proof system changes
var defaultMaxTxPerBlock = uint64(79)

// Syncer responsible for letting the L2 execution engine catching up with protocol's latest
// pending block through deriving L1 calldata.
Expand Down Expand Up @@ -141,7 +139,7 @@ func (s *Syncer) onBlockProposed(
}

if !s.progressTracker.Triggered() {
// Check whteher we need to reorg the L2 chain at first.
// Check whether we need to reorg the L2 chain at first.
// 1. Last verified block
var (
reorged bool
Expand Down
Loading
Loading