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

Commit

Permalink
comments
Browse files Browse the repository at this point in the history
  • Loading branch information
RogerLamTd committed Aug 8, 2023
1 parent c804c3e commit 7f1d328
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions driver/chain_syncer/chain_syncer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,17 @@ import (
"time"

"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/crypto"
"github.com/stretchr/testify/suite"
"github.com/taikoxyz/taiko-client/driver/state"
"github.com/taikoxyz/taiko-client/proposer"
"github.com/taikoxyz/taiko-client/testutils"
)

type ChainSyncerTestSuite struct {
testutils.ClientTestSuite
s *L2ChainSyncer
p testutils.Proposer
}

func (s *ChainSyncerTestSuite) SetupTest() {
Expand All @@ -33,6 +36,24 @@ func (s *ChainSyncerTestSuite) SetupTest() {
)
s.Nil(err)
s.s = syncer

prop := new(proposer.Proposer)
l1ProposerPrivKey, err := crypto.ToECDSA(common.Hex2Bytes(os.Getenv("L1_PROPOSER_PRIVATE_KEY")))
s.Nil(err)
proposeInterval := 1024 * time.Hour // No need to periodically propose transactions list in unit tests
s.Nil(proposer.InitFromConfig(context.Background(), prop, (&proposer.Config{
L1Endpoint: os.Getenv("L1_NODE_WS_ENDPOINT"),
L2Endpoint: os.Getenv("L2_EXECUTION_ENGINE_WS_ENDPOINT"),
TaikoL1Address: common.HexToAddress(os.Getenv("TAIKO_L1_ADDRESS")),
TaikoL2Address: common.HexToAddress(os.Getenv("TAIKO_L2_ADDRESS")),
L1ProposerPrivKey: l1ProposerPrivKey,
L2SuggestedFeeRecipient: common.HexToAddress(os.Getenv("L2_SUGGESTED_FEE_RECIPIENT")),
ProposeInterval: &proposeInterval,
MaxProposedTxListsPerEpoch: 1,
WaitReceiptTimeout: 10 * time.Second,
})))

s.p = prop
}

func (s *ChainSyncerTestSuite) TestGetInnerSyncers() {
Expand All @@ -48,9 +69,25 @@ func (s *ChainSyncerTestSuite) TestSync() {

// func (s *ChainSyncerTestSuite) TestSyncTriggerBeaconSync() {
// s.s.p2pSyncVerifiedBlocks = true
// NOTE: need to increase the verified block as one of the conditions to trigger
// needBeaconSyncTriggered()
// s.s.state.setLatestVerifiedBlockHash(common.Hash{})
// }

// func (s *ChainSyncerTestSuite) TestAheadOfProtocolVerifiedHead2() {
// testutils.ProposeAndInsertEmptyBlocks(&s.ClientTestSuite, s.p, s.s.calldataSyncer)
// head, err := s.RpcClient.L2.HeaderByNumber(context.Background(), nil)
// s.Nil(err)
// // NOTE: verify the block so that the state returns a value > 0
// // s.Nil(s.s.state.VerifyL2Block(context.Background(), head.Number, head.Hash()))
// tx, err := s.s.rpc.TaikoL1.VerifyBlocks(nil, common.Big1)
// s.Nil(err)
// fmt.Printf("tx: %v\n", tx.Hash().Hex())
// fmt.Printf("L1HeaderByNumber head: %v\n", head.Number)
// fmt.Printf("LatestVerifiedBlock number: %v\n", s.s.state.GetLatestVerifiedBlock().ID.Uint64())
// fmt.Printf("LatestL2Head Number: %v\n", s.s.state.GetL2Head().Number)
// }

func TestChainSyncerTestSuite(t *testing.T) {
suite.Run(t, new(ChainSyncerTestSuite))
}
Expand Down

0 comments on commit 7f1d328

Please sign in to comment.