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

Commit

Permalink
fix: fix some test bug
Browse files Browse the repository at this point in the history
  • Loading branch information
alexshliu committed Sep 22, 2023
1 parent 6a0f588 commit b5d4938
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 40 deletions.
6 changes: 3 additions & 3 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,21 @@ func main() {
Flags: driverFlags,
Usage: "Starts the driver software",
Description: "Taiko driver software",
Action: startServer,
Action: startApp,
},
{
Name: proposerCmd,
Flags: proposerFlags,
Usage: "Starts the proposer software",
Description: "Taiko proposer software",
Action: startServer,
Action: startApp,
},
{
Name: proverCmd,
Flags: proverFlags,
Usage: "Starts the prover software",
Description: "Taiko prover software",
Action: startServer,
Action: startApp,
},
}

Expand Down
2 changes: 1 addition & 1 deletion cmd/subcmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (

var s node.Service

func startServer(c *cli.Context) error {
func startApp(c *cli.Context) error {
ctx, ctxClose := context.WithCancel(context.Background())
defer func() { ctxClose() }()

Expand Down
23 changes: 12 additions & 11 deletions driver/chain_syncer/calldata/syncer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,26 +27,25 @@ type CalldataSyncerTestSuite struct {

func (s *CalldataSyncerTestSuite) SetupTest() {
s.ClientTestSuite.SetupTest()

state, err := state.New(context.Background(), s.RpcClient)
s.Nil(err)
ctx := context.Background()
state, err := state.New(ctx, s.RpcClient)
s.NoError(err)

syncer, err := NewSyncer(
context.Background(),
ctx,
s.RpcClient,
state,
beaconsync.NewSyncProgressTracker(s.RpcClient.L2, 1*time.Hour),
common.HexToAddress(os.Getenv("L1_SIGNAL_SERVICE_CONTRACT_ADDRESS")),
)
s.Nil(err)
s.NoError(err)
s.s = syncer

prop := new(proposer.Proposer)
l1ProposerPrivKey, err := crypto.ToECDSA(common.Hex2Bytes(os.Getenv("L1_PROPOSER_PRIVATE_KEY")))
s.Nil(err)
s.NoError(err)
proposeInterval := 1024 * time.Hour // No need to periodically propose transactions list in unit tests

s.Nil(proposer.New(context.Background(), prop, (&proposer.Config{
cfg := &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")),
Expand All @@ -61,9 +60,11 @@ func (s *CalldataSyncerTestSuite) SetupTest() {
BlockProposalFee: big.NewInt(1000),
BlockProposalFeeIterations: 3,
BlockProposalFeeIncreasePercentage: common.Big2,
})))

s.p = prop
}
ep, err := proposer.GetEndpointFromProposerConfig(ctx, cfg)
s.NoError(err)
s.p, err = proposer.New(context.Background(), ep, cfg)
s.NoError(err)
}

func (s *CalldataSyncerTestSuite) TestCancelNewSyncer() {
Expand Down
19 changes: 10 additions & 9 deletions driver/chain_syncer/chain_syncer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ type ChainSyncerTestSuite struct {

func (s *ChainSyncerTestSuite) SetupTest() {
s.ClientTestSuite.SetupTest()

state, err := state.New(context.Background(), s.RpcClient)
s.Nil(err)
ctx := context.Background()
state, err := state.New(ctx, s.RpcClient)
s.NoError(err)

syncer, err := New(
context.Background(),
ctx,
s.RpcClient,
state,
false,
Expand All @@ -42,12 +42,11 @@ 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.New(context.Background(), prop, (&proposer.Config{
cfg := &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")),
Expand All @@ -62,9 +61,11 @@ func (s *ChainSyncerTestSuite) SetupTest() {
BlockProposalFee: big.NewInt(1000),
BlockProposalFeeIterations: 3,
BlockProposalFeeIncreasePercentage: common.Big2,
})))

s.p = prop
}
ep, err := proposer.GetEndpointFromProposerConfig(ctx, cfg)
s.NoError(err)
s.p, err = proposer.New(ctx, ep, cfg)
s.NoError(err)
}

func (s *ChainSyncerTestSuite) TestGetInnerSyncers() {
Expand Down
27 changes: 14 additions & 13 deletions prover/proof_submitter/valid_proof_submitter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func (s *ProofSubmitterTestSuite) SetupTest() {
s.ClientTestSuite.SetupTest()

l1ProverPrivKey, err := crypto.ToECDSA(common.Hex2Bytes(os.Getenv("L1_PROVER_PRIVATE_KEY")))
s.Nil(err)
s.NoError(err)

s.validProofCh = make(chan *proofProducer.ProofWithHeader, 1024)
s.invalidProofCh = make(chan *proofProducer.ProofWithHeader, 1024)
Expand All @@ -54,30 +54,29 @@ func (s *ProofSubmitterTestSuite) SetupTest() {
10*time.Second,
nil,
)
s.Nil(err)

s.NoError(err)
ctx := context.Background()
// Init calldata syncer
testState, err := state.New(context.Background(), s.RpcClient)
s.Nil(err)
testState, err := state.New(ctx, s.RpcClient)
s.NoError(err)

tracker := beaconsync.NewSyncProgressTracker(s.RpcClient.L2, 30*time.Second)

s.calldataSyncer, err = calldata.NewSyncer(
context.Background(),
ctx,
s.RpcClient,
testState,
tracker,
common.HexToAddress(os.Getenv("L1_SIGNAL_SERVICE_CONTRACT_ADDRESS")),
)
s.Nil(err)
s.NoError(err)

// Init proposer
prop := new(proposer.Proposer)
l1ProposerPrivKey, err := crypto.ToECDSA(common.Hex2Bytes(os.Getenv("L1_PROPOSER_PRIVATE_KEY")))
s.Nil(err)
s.NoError(err)
proposeInterval := 1024 * time.Hour // No need to periodically propose transactions list in unit tests

s.Nil(proposer.New(context.Background(), prop, (&proposer.Config{
cfg := &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")),
Expand All @@ -92,9 +91,11 @@ func (s *ProofSubmitterTestSuite) SetupTest() {
BlockProposalFee: big.NewInt(1000),
BlockProposalFeeIterations: 3,
BlockProposalFeeIncreasePercentage: common.Big2,
})))

s.proposer = prop
}
ep, err := proposer.GetEndpointFromProposerConfig(ctx, cfg)
s.NoError(err)
s.proposer, err = proposer.New(ctx, ep, cfg)
s.NoError(err)
}

func (s *ProofSubmitterTestSuite) TestValidProofSubmitterRequestProofDeadlineExceeded() {
Expand Down
5 changes: 2 additions & 3 deletions prover/prover_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ func (s *ProverTestSuite) TestInitError() {
ctx, cancel := context.WithCancel(context.Background())
cancel()
l1ProverPrivKey, err := crypto.ToECDSA(common.Hex2Bytes(os.Getenv("L1_PROVER_PRIVATE_KEY")))
s.Nil(err)
s.NoError(err)

// Error should be "context canceled", instead is "Dial ethclient error:"
cfg := &Config{
Expand All @@ -149,8 +149,7 @@ func (s *ProverTestSuite) TestInitError() {
CheckProofWindowExpiredInterval: 5 * time.Second,
ProveUnassignedBlocks: true,
}
ep, err := GetEndpointFromProverConfig(ctx, cfg)
_, err = New(ctx, ep, cfg)
_, err = GetEndpointFromProverConfig(ctx, cfg)
s.ErrorContains(err, "dial tcp:")
}

Expand Down

0 comments on commit b5d4938

Please sign in to comment.