Skip to content

Commit

Permalink
chore: add the multiple messages per transaction test
Browse files Browse the repository at this point in the history
  • Loading branch information
rach-id committed Oct 14, 2024
1 parent 0fdc0ab commit c5071a3
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions app/test/prepare_proposal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package app_test

import (
"crypto/rand"
blobtypes "github.com/celestiaorg/celestia-app/v3/x/blob/types"
blobtx "github.com/celestiaorg/go-square/v2/tx"
"strings"
"testing"
"time"
Expand Down Expand Up @@ -309,6 +311,26 @@ func TestPrepareProposalCappingNumberOfMessages(t *testing.T) {
accountIndex++
}

multiPFBsPerTxs := make([][]byte, 0, numberOfPFBs)
numberOfMsgsPerTx := 10
for i := 0; i < numberOfPFBs; i++ {
msgs := make([]sdk.Msg, 0)
blobs := make([]*share.Blob, 0)
for j := 0; j < numberOfMsgsPerTx; j++ {
blob, err := share.NewBlob(share.RandomNamespace(), randomBytes, 1, accs[accountIndex].GetAddress().Bytes())
require.NoError(t, err)
msg, err := blobtypes.NewMsgPayForBlobs(addrs[accountIndex].String(), appconsts.LatestVersion, blob)
msgs = append(msgs, msg)
blobs = append(blobs, blob)
}
txBytes, err := signers[accountIndex].CreateTx(msgs, user.SetGasLimit(2549760000), user.SetFee(10000))
require.NoError(t, err)
blobTx, err := blobtx.MarshalBlobTx(txBytes, blobs...)
require.NoError(t, err)
multiPFBsPerTxs = append(multiPFBsPerTxs, blobTx)
accountIndex++
}

numberOfMsgSends := appconsts.NonPFBTransactionCap + 500
msgSendTxs := make([][]byte, 0, numberOfMsgSends)
for i := 0; i < numberOfMsgSends; i++ {
Expand All @@ -333,6 +355,11 @@ func TestPrepareProposalCappingNumberOfMessages(t *testing.T) {
inputTransactions: pfbTxs[:appconsts.PFBTransactionCap+50],
expectedTransactions: pfbTxs[:appconsts.PFBTransactionCap],
},
{
name: "capping only PFB transactions with multiple messages",
inputTransactions: multiPFBsPerTxs[:appconsts.PFBTransactionCap],
expectedTransactions: multiPFBsPerTxs[:appconsts.PFBTransactionCap/numberOfMsgsPerTx],
},
{
name: "capping only msg send transactions",
inputTransactions: msgSendTxs[:appconsts.NonPFBTransactionCap+50],
Expand Down

0 comments on commit c5071a3

Please sign in to comment.