From fe5e207c2b6601dd4d4eab3c3ddc76b9481d0b6b Mon Sep 17 00:00:00 2001 From: Artem Poltorzhitskiy Date: Sun, 1 Sep 2024 12:26:55 +0200 Subject: [PATCH] Fix: rollup_actions flag (#34) --- internal/storage/postgres/action.go | 2 +- internal/storage/postgres/action_test.go | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/internal/storage/postgres/action.go b/internal/storage/postgres/action.go index e44d935..3e65d9b 100644 --- a/internal/storage/postgres/action.go +++ b/internal/storage/postgres/action.go @@ -142,7 +142,7 @@ func (a *Action) ByRollupAndBridge(ctx context.Context, rollupId uint64, fltrs s return } - subQuery = sortScope(subQuery, "rollup_action.time", fltrs.Sort) + subQuery = sortScope(subQuery, "time", fltrs.Sort) subQuery = limitScope(subQuery, fltrs.Limit) subQuery = offsetScope(subQuery, fltrs.Offset) diff --git a/internal/storage/postgres/action_test.go b/internal/storage/postgres/action_test.go index a150b18..743bbcd 100644 --- a/internal/storage/postgres/action_test.go +++ b/internal/storage/postgres/action_test.go @@ -117,3 +117,27 @@ func (s *StorageTestSuite) TestActionByRollupAndBridge() { s.Require().NotNil(action.Action.Data) s.Require().NotNil(action.Action.Fee) } + +func (s *StorageTestSuite) TestActionByRollupAndBridgeWithoutRollupActions() { + ctx, ctxCancel := context.WithTimeout(context.Background(), 5*time.Second) + defer ctxCancel() + + actions, err := s.storage.Action.ByRollupAndBridge(ctx, 1, storage.RollupAndBridgeActionsFilter{ + Sort: sdk.SortOrderAsc, + Limit: 10, + Offset: 0, + RollupActions: false, + BridgeActions: true, + }) + s.Require().NoError(err) + s.Require().Len(actions, 2) + + action := actions[0] + s.Require().EqualValues(7316, action.Height) + s.Require().NotNil(action.Tx) + s.Require().NotNil(action.Action) + s.Require().EqualValues(1, action.Action.TxId) + s.Require().EqualValues(types.ActionTypeSequence, action.Action.Type) + s.Require().NotNil(action.Action.Data) + s.Require().NotNil(action.Action.Fee) +}