Skip to content

Commit

Permalink
fix stubPublisher in express_lane_service_test.go
Browse files Browse the repository at this point in the history
  • Loading branch information
ganeshvanahalli committed Dec 27, 2024
1 parent 8cacbb2 commit 77df3c7
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 18 deletions.
8 changes: 2 additions & 6 deletions execution/gethexec/express_lane_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -361,14 +361,10 @@ func (es *expressLaneService) sequenceExpressLaneSubmission(
if err := es.transactionPublisher.PublishTimeboostedTransaction(
ctx,
nextMsg.Transaction,
msg.Options,
nextMsg.Options,
); err != nil {
txHash := common.Hash{}
if nextMsg.Transaction != nil {
txHash = nextMsg.Transaction.Hash()
}
// If the tx fails we return an error with all the necessary info for the controller to successfully try again
return fmt.Errorf("express lane transaction of sequence number: %d and transaction hash: %v, failed with an error: %w", nextMsg.SequenceNumber, txHash, err)
return fmt.Errorf("express lane transaction of sequence number: %d and transaction hash: %v, failed with an error: %w", nextMsg.SequenceNumber, nextMsg.Transaction.Hash(), err)
}
// Increase the global round sequence number.
control.sequence += 1
Expand Down
26 changes: 14 additions & 12 deletions execution/gethexec/express_lane_service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -297,8 +297,10 @@ func makeStubPublisher(els *expressLaneService) *stubPublisher {
}
}

var emptyTx = types.NewTransaction(0, common.MaxAddress, big.NewInt(0), 0, big.NewInt(0), nil)

func (s *stubPublisher) PublishTimeboostedTransaction(parentCtx context.Context, tx *types.Transaction, options *arbitrum_types.ConditionalOptions) error {
if tx == nil {
if tx.Hash() != emptyTx.Hash() {
return errors.New("oops, bad tx")
}
control, _ := s.els.roundControl.Get(0)
Expand Down Expand Up @@ -369,23 +371,23 @@ func Test_expressLaneService_sequenceExpressLaneSubmission_outOfOrder(t *testing
messages := []*timeboost.ExpressLaneSubmission{
{
SequenceNumber: 10,
Transaction: &types.Transaction{},
Transaction: emptyTx,
},
{
SequenceNumber: 5,
Transaction: &types.Transaction{},
Transaction: emptyTx,
},
{
SequenceNumber: 1,
Transaction: &types.Transaction{},
Transaction: emptyTx,
},
{
SequenceNumber: 4,
Transaction: &types.Transaction{},
Transaction: emptyTx,
},
{
SequenceNumber: 2,
Transaction: &types.Transaction{},
Transaction: emptyTx,
},
}
for _, msg := range messages {
Expand All @@ -396,7 +398,7 @@ func Test_expressLaneService_sequenceExpressLaneSubmission_outOfOrder(t *testing
require.Equal(t, 2, len(stubPublisher.publishedTxOrder))
require.Equal(t, 3, len(els.messagesBySequenceNumber)) // Processed txs are deleted

err := els.sequenceExpressLaneSubmission(ctx, &timeboost.ExpressLaneSubmission{SequenceNumber: 3, Transaction: &types.Transaction{}})
err := els.sequenceExpressLaneSubmission(ctx, &timeboost.ExpressLaneSubmission{SequenceNumber: 3, Transaction: emptyTx})
require.NoError(t, err)
require.Equal(t, 5, len(stubPublisher.publishedTxOrder))
}
Expand All @@ -417,23 +419,23 @@ func Test_expressLaneService_sequenceExpressLaneSubmission_erroredTx(t *testing.
messages := []*timeboost.ExpressLaneSubmission{
{
SequenceNumber: 1,
Transaction: &types.Transaction{},
Transaction: emptyTx,
},
{
SequenceNumber: 3,
Transaction: &types.Transaction{},
Transaction: emptyTx,
},
{
SequenceNumber: 2,
Transaction: nil,
Transaction: types.NewTransaction(0, common.MaxAddress, big.NewInt(0), 0, big.NewInt(0), []byte{1}),
},
{
SequenceNumber: 2,
Transaction: &types.Transaction{},
Transaction: emptyTx,
},
}
for _, msg := range messages {
if msg.Transaction == nil {
if msg.Transaction.Hash() != emptyTx.Hash() {
err := els.sequenceExpressLaneSubmission(ctx, msg)
require.ErrorContains(t, err, "oops, bad tx")
} else {
Expand Down

0 comments on commit 77df3c7

Please sign in to comment.