Skip to content

Commit

Permalink
feat(ledger): add tests on transactions queries
Browse files Browse the repository at this point in the history
  • Loading branch information
gfyrag committed Apr 4, 2024
1 parent d9ca517 commit c396f1b
Showing 1 changed file with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -952,6 +952,12 @@ func TestGetTransactions(t *testing.T) {
ledger.NewPosting("users:marley", "world", "USD", big.NewInt(100)),
).
WithDate(now)
tx5 := ledger.NewTransaction().
WithIDUint64(4).
WithPostings(
ledger.NewPosting("users:marley", "sellers:amazon", "USD", big.NewInt(100)),
).
WithDate(now)

logs := []*ledger.Log{
ledger.NewTransactionLog(tx1, map[string]metadata.Metadata{}),
Expand All @@ -961,6 +967,7 @@ func TestGetTransactions(t *testing.T) {
ledger.NewSetMetadataOnTransactionLog(time.Now(), tx3.ID, metadata.Metadata{
"additional_metadata": "true",
}),
ledger.NewTransactionLog(tx5, map[string]metadata.Metadata{}),
}

require.NoError(t, store.InsertLogs(ctx, ledger.ChainLogs(logs...)...))
Expand Down Expand Up @@ -991,6 +998,16 @@ func TestGetTransactions(t *testing.T) {
Data: expandLogs(logs...)[1:2],
},
},
{
name: "address filter using segments matching two addresses by individual segments",
query: NewPaginatedQueryOptions(PITFilterWithVolumes{}).
WithQueryBuilder(query.Match("account", "users:amazon")),
expected: &bunpaginate.Cursor[ledger.ExpandedTransaction]{
PageSize: 15,
HasMore: false,
Data: []ledger.ExpandedTransaction{},
},
},
{
name: "address filter using segment",
query: NewPaginatedQueryOptions(PITFilterWithVolumes{}).
Expand Down

0 comments on commit c396f1b

Please sign in to comment.