Skip to content

Commit

Permalink
Fix generate comparison (#42)
Browse files Browse the repository at this point in the history
  • Loading branch information
chenyaoy authored Jan 3, 2025
1 parent f4a5322 commit ec1b4c2
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
4 changes: 0 additions & 4 deletions generator/types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,6 @@ func Compare(a, b Feed) bool {
return a.CMCInfo.BaseRank > b.CMCInfo.BaseRank
}

if a.CMCInfo.QuoteRank != b.CMCInfo.QuoteRank {
return a.CMCInfo.QuoteRank > b.CMCInfo.QuoteRank
}

if a.LiquidityInfo.TotalLiquidity() != b.LiquidityInfo.TotalLiquidity() {
return a.LiquidityInfo.TotalLiquidity() < b.LiquidityInfo.TotalLiquidity()
}
Expand Down
19 changes: 19 additions & 0 deletions generator/types/types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,25 @@ func TestCompare(t *testing.T) {
want: true,
wantErr: false,
},
{
name: "quote rank is not considered in comparison",
a: types.Feed{
CMCInfo: mmutypes.NewCoinMarketCapInfo(0, 0, 1, 10),
LiquidityInfo: mmutypes.LiquidityInfo{
NegativeDepthTwo: 10,
PositiveDepthTwo: 10,
},
},
b: types.Feed{
CMCInfo: mmutypes.NewCoinMarketCapInfo(0, 0, 1, 1),
LiquidityInfo: mmutypes.LiquidityInfo{
NegativeDepthTwo: 0,
PositiveDepthTwo: 0,
},
},
want: false,
wantErr: false,
},
{
name: "mismatched currency still returns",
a: types.Feed{
Expand Down

0 comments on commit ec1b4c2

Please sign in to comment.