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

Commit

Permalink
test: update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
davidtaikocha committed Apr 4, 2024
1 parent b285248 commit 7715fc4
Show file tree
Hide file tree
Showing 11 changed files with 34 additions and 42 deletions.
1 change: 0 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ jobs:
with:
repository: taikoxyz/taiko-mono
path: ${{ env.TAIKO_MONO_DIR }}
ref: revert_change

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
Expand Down
7 changes: 7 additions & 0 deletions driver/chain_syncer/calldata/syncer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"github.com/taikoxyz/taiko-client/driver/state"
"github.com/taikoxyz/taiko-client/internal/testutils"
"github.com/taikoxyz/taiko-client/internal/utils"
"github.com/taikoxyz/taiko-client/pkg/jwt"
"github.com/taikoxyz/taiko-client/pkg/rpc"
"github.com/taikoxyz/taiko-client/proposer"
)
Expand Down Expand Up @@ -189,10 +190,16 @@ func (s *CalldataSyncerTestSuite) initProposer() {
l1ProposerPrivKey, err := crypto.ToECDSA(common.FromHex(os.Getenv("L1_PROPOSER_PRIVATE_KEY")))
s.Nil(err)

jwtSecret, err := jwt.ParseSecretFromFile(os.Getenv("JWT_SECRET"))
s.Nil(err)
s.NotEmpty(jwtSecret)

s.Nil(prop.InitFromConfig(context.Background(), &proposer.Config{
ClientConfig: &rpc.ClientConfig{
L1Endpoint: os.Getenv("L1_NODE_WS_ENDPOINT"),
L2Endpoint: os.Getenv("L2_EXECUTION_ENGINE_WS_ENDPOINT"),
L2EngineEndpoint: os.Getenv("L2_EXECUTION_ENGINE_AUTH_ENDPOINT"),
JwtSecret: string(jwtSecret),
TaikoL1Address: common.HexToAddress(os.Getenv("TAIKO_L1_ADDRESS")),
TaikoL2Address: common.HexToAddress(os.Getenv("TAIKO_L2_ADDRESS")),
TaikoTokenAddress: common.HexToAddress(os.Getenv("TAIKO_TOKEN_ADDRESS")),
Expand Down
6 changes: 6 additions & 0 deletions driver/driver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -287,13 +287,19 @@ func (s *DriverTestSuite) TestL1Current() {
func (s *DriverTestSuite) InitProposer() {
p := new(proposer.Proposer)

jwtSecret, err := jwt.ParseSecretFromFile(os.Getenv("JWT_SECRET"))
s.Nil(err)
s.NotEmpty(jwtSecret)

l1ProposerPrivKey, err := crypto.ToECDSA(common.FromHex(os.Getenv("L1_PROPOSER_PRIVATE_KEY")))
s.Nil(err)

s.Nil(p.InitFromConfig(context.Background(), &proposer.Config{
ClientConfig: &rpc.ClientConfig{
L1Endpoint: os.Getenv("L1_NODE_WS_ENDPOINT"),
L2Endpoint: os.Getenv("L2_EXECUTION_ENGINE_WS_ENDPOINT"),
L2EngineEndpoint: os.Getenv("L2_EXECUTION_ENGINE_AUTH_ENDPOINT"),
JwtSecret: string(jwtSecret),
TaikoL1Address: common.HexToAddress(os.Getenv("TAIKO_L1_ADDRESS")),
TaikoL2Address: common.HexToAddress(os.Getenv("TAIKO_L2_ADDRESS")),
TaikoTokenAddress: common.HexToAddress(os.Getenv("TAIKO_TOKEN_ADDRESS")),
Expand Down
2 changes: 1 addition & 1 deletion internal/docker/nodes/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ services:

l2_execution_engine:
container_name: l2_node
image: gcr.io/evmchain/taiko-geth:sha-840bcff
image: gcr.io/evmchain/taiko-geth:taiko
restart: unless-stopped
pull_policy: always
volumes:
Expand Down
17 changes: 6 additions & 11 deletions internal/testutils/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,10 @@ func (s *ClientTestSuite) ProposeInvalidTxListBytes(proposer Proposer) {
s.Nil(proposer.ProposeTxList(context.Background(), invalidTxListBytes, 1))
}

func (s *ClientTestSuite) proposeEmptyBlockOp(ctx context.Context, proposer Proposer) error {
func (s *ClientTestSuite) proposeEmptyBlockOp(ctx context.Context, proposer Proposer) {
emptyTxListBytes, err := rlp.EncodeToBytes(types.Transactions{})
if err != nil {
return err
}
if err = proposer.ProposeTxList(ctx, emptyTxListBytes, 0); err != nil {
return err
}
return nil
s.Nil(err)
s.Nil(proposer.ProposeTxList(ctx, emptyTxListBytes, 0))
}

func (s *ClientTestSuite) ProposeAndInsertEmptyBlocks(
Expand Down Expand Up @@ -72,7 +67,7 @@ func (s *ClientTestSuite) ProposeAndInsertEmptyBlocks(
s.ProposeInvalidTxListBytes(proposer)

// Random bytes txList
s.Nil(s.proposeEmptyBlockOp(context.Background(), proposer))
s.proposeEmptyBlockOp(context.Background(), proposer)

events = append(events, []*bindings.TaikoL1ClientBlockProposed{<-sink, <-sink, <-sink}...)

Expand Down Expand Up @@ -314,8 +309,8 @@ func SignatureFromRSV(r, s string, v byte) []byte {
return append(append(hexutil.MustDecode(r), hexutil.MustDecode(s)...), v)
}

// MakeDynamicTx creates a dynamic transaction, used for tests.
func MakeDynamicTx(
// SendDynamicFeeTx sends a dynamic transaction, used for tests.
func SendDynamicFeeTx(
client *rpc.EthClient,
priv *ecdsa.PrivateKey,
to *common.Address,
Expand Down
8 changes: 4 additions & 4 deletions pkg/rpc/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ func (c *EngineClient) ExchangeTransitionConfiguration(
return result, nil
}

// TxPoolContent fetches the transaction pool content from the L2 execution engine.
func (c *EngineClient) TxPoolContent(
ctx context.Context,
beneficiary common.Address,
Expand All @@ -111,8 +112,8 @@ func (c *EngineClient) TxPoolContent(
timeoutCtx, cancel := context.WithTimeout(ctx, defaultTimeout)
defer cancel()

result := make([]*miner.PreBuiltTxList, 0)
err := c.CallContext(
var result []*miner.PreBuiltTxList
if err := c.CallContext(
timeoutCtx,
&result,
"taikoAuth_txPoolContent",
Expand All @@ -122,8 +123,7 @@ func (c *EngineClient) TxPoolContent(
maxBytesPerTxList,
locals,
maxTransactionsLists,
)
if err != nil {
); err != nil {
return nil, err
}
return result, nil
Expand Down
6 changes: 4 additions & 2 deletions pkg/rpc/methods.go
Original file line number Diff line number Diff line change
Expand Up @@ -267,12 +267,14 @@ func (c *Client) GetPoolContent(
}

return c.L2Engine.TxPoolContent(
ctxWithTimeout, beneficiary,
ctxWithTimeout,
beneficiary,
baseFeeInfo.Basefee,
uint64(blockMaxGasLimit),
maxBytesPerTxList,
localsArg,
maxTransactionsLists)
maxTransactionsLists,
)
}

// L2AccountNonce fetches the nonce of the given L2 account at a specified height.
Expand Down
21 changes: 0 additions & 21 deletions pkg/rpc/methods_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,27 +115,6 @@ func TestWaitTillL2ExecutionEngineSyncedContextErr(t *testing.T) {
require.ErrorContains(t, err, "context canceled")
}

func TestGetPoolContentValid(t *testing.T) {
client := newTestClient(t)
configs, err := client.TaikoL1.GetConfig(&bind.CallOpts{Context: context.Background()})
require.Nil(t, err)
goldenTouchAddress, err := client.TaikoL2.GOLDENTOUCHADDRESS(nil)
require.Nil(t, err)
gasLimit := configs.BlockMaxGasLimit

txPools := []common.Address{goldenTouchAddress}

_, err2 := client.GetPoolContent(
context.Background(),
goldenTouchAddress,
gasLimit,
BlockMaxTxListBytes,
txPools,
4,
)
require.Nil(t, err2)
}

// randomHash generates a random blob of data and returns it as a hash.
func randomHash() common.Hash {
var hash common.Hash
Expand Down
4 changes: 2 additions & 2 deletions proposer/proposer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ func (s *ProposerTestSuite) TestProposeOpNoEmptyBlock() {
var err error
for i := 0; i < batchSize; i++ {
to := common.BytesToAddress(testutils.RandomBytes(32))
_, err = testutils.MakeDynamicTx(s.RPCClient.L2, s.TestAddrPrivKey, &to, nil, nil)
_, err = testutils.SendDynamicFeeTx(s.RPCClient.L2, s.TestAddrPrivKey, &to, nil, nil)
s.Nil(err)
}

Expand Down Expand Up @@ -272,7 +272,7 @@ func (s *ProposerTestSuite) TestProposeOp() {
}()

to := common.BytesToAddress(testutils.RandomBytes(20))
_, err = testutils.MakeDynamicTx(s.RPCClient.L2, s.TestAddrPrivKey, &to, nil, nil)
_, err = testutils.SendDynamicFeeTx(s.RPCClient.L2, s.TestAddrPrivKey, &to, nil, nil)
s.Nil(err)

s.Nil(s.p.ProposeOp(context.Background()))
Expand Down
2 changes: 2 additions & 0 deletions prover/event_handler/transition_proved_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ func (s *EventHandlerTestSuite) SetupTest() {
ClientConfig: &rpc.ClientConfig{
L1Endpoint: os.Getenv("L1_NODE_WS_ENDPOINT"),
L2Endpoint: os.Getenv("L2_EXECUTION_ENGINE_WS_ENDPOINT"),
L2EngineEndpoint: os.Getenv("L2_EXECUTION_ENGINE_AUTH_ENDPOINT"),
JwtSecret: string(jwtSecret),
TaikoL1Address: common.HexToAddress(os.Getenv("TAIKO_L1_ADDRESS")),
TaikoL2Address: common.HexToAddress(os.Getenv("TAIKO_L2_ADDRESS")),
TaikoTokenAddress: common.HexToAddress(os.Getenv("TAIKO_TOKEN_ADDRESS")),
Expand Down
2 changes: 2 additions & 0 deletions prover/prover_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ func (s *ProverTestSuite) SetupTest() {
ClientConfig: &rpc.ClientConfig{
L1Endpoint: os.Getenv("L1_NODE_WS_ENDPOINT"),
L2Endpoint: os.Getenv("L2_EXECUTION_ENGINE_WS_ENDPOINT"),
L2EngineEndpoint: os.Getenv("L2_EXECUTION_ENGINE_AUTH_ENDPOINT"),
JwtSecret: string(jwtSecret),
TaikoL1Address: common.HexToAddress(os.Getenv("TAIKO_L1_ADDRESS")),
TaikoL2Address: common.HexToAddress(os.Getenv("TAIKO_L2_ADDRESS")),
TaikoTokenAddress: common.HexToAddress(os.Getenv("TAIKO_TOKEN_ADDRESS")),
Expand Down

0 comments on commit 7715fc4

Please sign in to comment.