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

Commit

Permalink
feat: update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
davidtaikocha committed May 2, 2024
1 parent 1f2faa2 commit d84c845
Showing 1 changed file with 61 additions and 0 deletions.
61 changes: 61 additions & 0 deletions proposer/proposer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"testing"
"time"

"github.com/ethereum-optimism/optimism/op-service/eth"
"github.com/ethereum-optimism/optimism/op-service/txmgr"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/math"
Expand All @@ -17,6 +18,7 @@ import (
"github.com/stretchr/testify/suite"

"github.com/taikoxyz/taiko-client/bindings"
"github.com/taikoxyz/taiko-client/bindings/encoding"
"github.com/taikoxyz/taiko-client/driver/chain_syncer/beaconsync"
"github.com/taikoxyz/taiko-client/driver/chain_syncer/blob"
"github.com/taikoxyz/taiko-client/driver/state"
Expand All @@ -25,6 +27,7 @@ import (
"github.com/taikoxyz/taiko-client/internal/utils"
"github.com/taikoxyz/taiko-client/pkg/jwt"
"github.com/taikoxyz/taiko-client/pkg/rpc"
builder "github.com/taikoxyz/taiko-client/proposer/transaction_builder"
)

type ProposerTestSuite struct {
Expand Down Expand Up @@ -135,6 +138,64 @@ func parseTxs(client *rpc.Client, event *bindings.TaikoL1ClientBlockProposed) (t
var txs types.Transactions
return txs, rlp.DecodeBytes(txListBytes, &txs)
}
func (s *ProposerTestSuite) TestProposeTxLists() {
p := s.p
ctx := p.ctx
cfg := s.p.Config

txBuilder := builder.NewBlobTransactionBuilder(
p.rpc,
p.L1ProposerPrivKey,
p.proverSelector,
p.Config.L1BlockBuilderTip,
cfg.TaikoL1Address,
cfg.L2SuggestedFeeRecipient,
cfg.AssignmentHookAddress,
cfg.ProposeBlockTxGasLimit,
cfg.ExtraData,
)

emptyTxListBytes, err := rlp.EncodeToBytes(types.Transactions{})
s.Nil(err)
txListsBytes := [][]byte{emptyTxListBytes}
txCandidates := make([]txmgr.TxCandidate, len(txListsBytes))
for i, txListBytes := range txListsBytes {
compressedTxListBytes, err := utils.Compress(txListBytes)
if err != nil {
log.Warn("Failed to compress transactions list", "index", i, "error", err)
break
}

candidate, err := txBuilder.Build(
p.ctx,
p.tierFees,
p.IncludeParentMetaHash,
compressedTxListBytes,
)
if err != nil {
log.Warn("Failed to build TaikoL1.proposeBlock transaction", "error", err)
break
}

// trigger the error
candidate.Blobs = []*eth.Blob{}
candidate.GasLimit = 10000000

txCandidates[i] = *candidate
}

var errors []error
for _, txCandidate := range txCandidates {
receipt, err := p.txmgr.Send(ctx, txCandidate)
s.Nil(err)
errors = append(errors, encoding.TryParsingCustomErrorFromReceipt(ctx, p.rpc.L1, p.proposerAddress, receipt))
}

// confirm errors handled
for _, err := range errors {
s.Equal("L1_BLOB_NOT_AVAILABLE", err.Error())
}
}

func (s *ProposerTestSuite) getLatestProposedTxs(
n int,
Expand Down

0 comments on commit d84c845

Please sign in to comment.