Skip to content

Commit

Permalink
testing: add extra tests to ensure we remove txs correctly (#1345)
Browse files Browse the repository at this point in the history
Addresses: #1102
  • Loading branch information
cmwaters authored Feb 7, 2023
1 parent a138c19 commit 580d186
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions app/write_square_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,50 @@ func Test_finalizeLayout(t *testing.T) {
),
expectedIndexes: [][]uint32{{4}, {6, 8}, {5}},
},
{
// no blob txs should make it in the square
squareSize: 2,
nonreserveStart: 4,
blobTxs: generateBlobTxsWithNIDs(
t,
[][]byte{ns1, ns2, ns3},
[][]int{{1000}, {1000}, {1000}},
),
expectedIndexes: [][]uint32{},
},
{
// only two blob txs should make it in the square
squareSize: 4,
nonreserveStart: 4,
blobTxs: generateBlobTxsWithNIDs(
t,
[][]byte{ns1, ns2, ns3},
[][]int{{2000}, {2000}, {6000}},
),
expectedIndexes: [][]uint32{{4}, {8}},
},
{
// only one blob tx should make it in the square (after reordering)
squareSize: 4,
nonreserveStart: 4,
blobTxs: generateBlobTxsWithNIDs(
t,
[][]byte{ns3, ns2, ns1},
[][]int{{2000}, {2000}, {6000}},
),
expectedIndexes: [][]uint32{{4}},
},
{
squareSize: 4,
nonreserveStart: 4,
blobTxs: generateBlobTxsWithNIDs(
t,
[][]byte{ns3, ns3, ns2, ns1},
[][]int{{2000, 1000}, {6000}, {2000}},
),
// should be ns1 and {ns3, ns3} as ns2 is too large
expectedIndexes: [][]uint32{{8, 12}, {4}},
},
{
squareSize: 4,
nonreserveStart: 4,
Expand All @@ -170,6 +214,7 @@ func Test_finalizeLayout(t *testing.T) {
for i, tt := range tests {
t.Run(fmt.Sprintf("case%d", i), func(t *testing.T) {
wrappedPFBs, blobs := finalizeBlobLayout(tt.squareSize, tt.nonreserveStart, tt.blobTxs)
require.Equal(t, len(wrappedPFBs), len(tt.expectedIndexes))
for j, pfbBytes := range wrappedPFBs {
wrappedPFB, isWrappedPFB := coretypes.UnmarshalIndexWrapper(pfbBytes)
require.True(t, isWrappedPFB)
Expand Down

0 comments on commit 580d186

Please sign in to comment.