Skip to content

Commit

Permalink
RollupWithType test;
Browse files Browse the repository at this point in the history
  • Loading branch information
mismirnov committed Nov 15, 2024
1 parent 9a58280 commit 3289387
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
36 changes: 36 additions & 0 deletions internal/storage/postgres/rollup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,42 @@ func (s *StorageTestSuite) TestRollupLeaderboardWithCategory() {
}
}

func (s *StorageTestSuite) TestRollupLeaderboardWithType() {
ctx, ctxCancel := context.WithTimeout(context.Background(), 5*time.Second)
defer ctxCancel()

_, err := s.storage.Connection().Exec(ctx, "REFRESH MATERIALIZED VIEW leaderboard;")
s.Require().NoError(err)

for _, column := range []string{
sizeColumn, blobsCountColumn, timeColumn, feeColumn, "",
} {

rollups, err := s.storage.Rollup.Leaderboard(ctx, storage.LeaderboardFilters{
SortField: column,
Sort: sdk.SortOrderDesc,
Limit: 10,
Offset: 0,
Type: []types.RollupType{types.RollupTypeSovereign},
})
s.Require().NoError(err, column)
s.Require().Len(rollups, 1, column)

rollup := rollups[0]
s.Require().EqualValues("Rollup 3", rollup.Name, column)
s.Require().EqualValues("The third", rollup.Description, column)
s.Require().EqualValues(34, rollup.Size, column)
s.Require().EqualValues(3, rollup.BlobsCount, column)
s.Require().False(rollup.LastActionTime.IsZero())
s.Require().False(rollup.FirstActionTime.IsZero())
s.Require().Equal("7000", rollup.Fee.String())
s.Require().EqualValues(0.6363636363636364, rollup.FeePct)
s.Require().EqualValues(0.42857142857142855, rollup.BlobsCountPct)
s.Require().EqualValues(0.3953488372093023, rollup.SizePct)
s.Require().EqualValues("sovereign", rollup.Type)
}
}

func (s *StorageTestSuite) TestRollupLeaderboardDay() {
ctx, ctxCancel := context.WithTimeout(context.Background(), 5*time.Second)
defer ctxCancel()
Expand Down
3 changes: 3 additions & 0 deletions test/data/rollup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
logo: https://rollup1.com/image.png
slug: rollup_1
category: finance
type: settled
- id: 2
name: Rollup 2
description: The second
Expand All @@ -16,6 +17,7 @@
logo: https://rollup2.com/image.png
slug: rollup_2
category: gaming
type: settled
- id: 3
name: Rollup 3
description: The third
Expand All @@ -25,3 +27,4 @@
logo: https://rollup3.com/image.png
slug: rollup_3
category: nft
type: sovereign

0 comments on commit 3289387

Please sign in to comment.