Skip to content

Commit

Permalink
test: Update calldata test with ontake checks
Browse files Browse the repository at this point in the history
  • Loading branch information
Hyodar committed Oct 31, 2024
1 parent cfbc3e7 commit a2a0d63
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ func (b *CalldataTransactionBuilder) BuildLegacy(
// If the current proposer wants to include the parent meta hash, then fetch it from the protocol.
var (
parentMetaHash = [32]byte{}
err error
)
if includeParentMetaHash {
if parentMetaHash, err = getParentMetaHash(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,29 @@ package builder

import (
"context"
"math/big"

"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/taikoxyz/taiko-mono/packages/taiko-client/pkg/rpc"
)

func (s *TransactionBuilderTestSuite) TestBuildCalldata() {
tx, err := s.calldataTxBuilder.BuildLegacy(context.Background(), false, []byte{1})
state, err := rpc.GetProtocolStateVariables(s.RPCClient.TaikoL1, &bind.CallOpts{Context: context.Background()})
s.Nil(err)
s.Nil(tx.Blobs)

_, err = s.calldataTxBuilder.BuildOntake(context.Background(), [][]byte{{1}, {2}})
s.Error(err, "ontake transaction builder is not supported before ontake fork")
if s.chainConfig.IsOntake(new(big.Int).SetUint64(state.B.NumBlocks)) {
tx, err := s.calldataTxBuilder.BuildOntake(context.Background(), [][]byte{{1}, {2}})
s.Nil(err)
s.Nil(tx.Blobs)

_, err = s.calldataTxBuilder.BuildLegacy(context.Background(), false, []byte{1})
s.Error(err, "legacy transaction builder is not supported after ontake fork")
} else {
tx, err := s.calldataTxBuilder.BuildLegacy(context.Background(), false, []byte{1})
s.Nil(err)
s.Nil(tx.Blobs)

_, err = s.calldataTxBuilder.BuildOntake(context.Background(), [][]byte{{1}, {2}})
s.Error(err, "ontake transaction builder is not supported before ontake fork")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ type TransactionBuilderTestSuite struct {
testutils.ClientTestSuite
calldataTxBuilder *CalldataTransactionBuilder
blobTxBuiler *BlobTransactionBuilder
chainConfig *config.ChainConfig
}

func (s *TransactionBuilderTestSuite) SetupTest() {
Expand Down Expand Up @@ -50,6 +51,7 @@ func (s *TransactionBuilderTestSuite) SetupTest() {
"test",
chainConfig,
)
s.chainConfig = chainConfig
}

func (s *TransactionBuilderTestSuite) TestGetParentMetaHash() {
Expand Down

0 comments on commit a2a0d63

Please sign in to comment.