Skip to content

Commit

Permalink
api: v2alpha1 TransactionList: Fix typo in EndLayer filter (#6016)
Browse files Browse the repository at this point in the history
EndLayer filter used Address field instead of Layer to prepare SQL query.
  • Loading branch information
kacpersaw committed Jun 7, 2024
1 parent f3d2064 commit 4a93cff
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion api/grpcserver/v2alpha1/transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ func toTransactionOperations(filter *spacemeshv2alpha1.TransactionRequest) (buil

if filter.EndLayer != nil {
ops.Filter = append(ops.Filter, builder.Op{
Field: builder.Address,
Field: builder.Layer,
Token: builder.Lte,
Value: int64(filter.GetEndLayer()),
})
Expand Down
19 changes: 19 additions & 0 deletions api/grpcserver/v2alpha1/transaction_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,25 @@ func TestTransactionService_List(t *testing.T) {
require.Equal(t, spacemeshv2alpha1.TransactionResult_TRANSACTION_STATUS_SUCCESS,
list.Transactions[0].TxResult.Status)
})

t.Run("start layer & end layer", func(t *testing.T) {
layer := txsList[0].Layer.Uint32()

var expectedTxs []types.TransactionWithResult
for _, tx := range txsList {
if tx.Layer.Uint32() == layer {
expectedTxs = append(expectedTxs, tx)
}
}

list, err := client.List(ctx, &spacemeshv2alpha1.TransactionRequest{
StartLayer: &layer,
EndLayer: &layer,
Limit: 100,
})
require.NoError(t, err)
require.Len(t, list.Transactions, len(expectedTxs))
})
}

func TestTransactionService_EstimateGas(t *testing.T) {
Expand Down

0 comments on commit 4a93cff

Please sign in to comment.