Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

services/horizon/internal/db2/history: Include lower bound on descending history queries #5465

Merged
merged 6 commits into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add tests
  • Loading branch information
tamirms committed Sep 25, 2024
commit 8c676b5e1beaacb4987e3f670e3fb4c94aea8671
9 changes: 8 additions & 1 deletion services/horizon/internal/db2/history/trade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package history
import (
"testing"

"github.com/stellar/go/toid"
"github.com/stellar/go/xdr"

"github.com/stellar/go/services/horizon/internal/db2"
Expand Down Expand Up @@ -46,6 +47,8 @@ func TestSelectTrades(t *testing.T) {
test.ResetHorizonDB(t, tt.HorizonDB)
q := &Q{tt.HorizonSession()}
fixtures := TradeScenario(tt, q)
afterTradesSeq := toid.Parse(fixtures.Trades[0].HistoryOperationID).LedgerSequence + 1
beforeTradesSeq := afterTradesSeq - 2

for _, account := range append([]string{allAccounts}, fixtures.Addresses...) {
for _, tradeType := range []string{AllTrades, OrderbookTrades, LiquidityPoolTrades} {
Expand All @@ -55,7 +58,7 @@ func TestSelectTrades(t *testing.T) {

assertTradesAreEqual(tt, expected, rows)

rows, err = q.GetTrades(tt.Ctx, descPQ, 0, account, tradeType)
rows, err = q.GetTrades(tt.Ctx, descPQ, beforeTradesSeq, account, tradeType)
tt.Assert.NoError(err)
start, end := 0, len(rows)-1
for start < end {
Expand All @@ -65,6 +68,10 @@ func TestSelectTrades(t *testing.T) {
}

assertTradesAreEqual(tt, expected, rows)

rows, err = q.GetTrades(tt.Ctx, descPQ, afterTradesSeq, account, tradeType)
tt.Assert.NoError(err)
tt.Assert.Empty(rows)
}
}
}
Expand Down
Loading
Loading