From 7f1d3281031c156fc1434569ce2ee7156d460350 Mon Sep 17 00:00:00 2001 From: RogerLamTd Date: Tue, 8 Aug 2023 10:07:16 -0400 Subject: [PATCH] comments --- driver/chain_syncer/chain_syncer_test.go | 37 ++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/driver/chain_syncer/chain_syncer_test.go b/driver/chain_syncer/chain_syncer_test.go index 91c083581..d5cc77647 100644 --- a/driver/chain_syncer/chain_syncer_test.go +++ b/driver/chain_syncer/chain_syncer_test.go @@ -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() { @@ -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() { @@ -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)) }