Skip to content

Commit

Permalink
supporting test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
p0mvn committed Dec 23, 2022
1 parent 6dcce8b commit 598c53a
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
7 changes: 7 additions & 0 deletions osmomath/sigfig_round_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,13 @@ func TestSigFigRound(t *testing.T) {
tenToSigFig: sdk.NewInt(100),
expectedResult: sdk.MustNewDecFromStr("0.087"),
},

{
name: "minimum decimal is still kept",
decimal: sdk.NewDecWithPrec(1, 18),
tenToSigFig: sdk.NewInt(10),
expectedResult: sdk.NewDecWithPrec(1, 18),
},
}

for i, tc := range testCases {
Expand Down
16 changes: 16 additions & 0 deletions x/gamm/pool-models/balancer/pool_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -766,6 +766,22 @@ func (suite *KeeperTestSuite) TestBalancerSpotPriceBounds() {
baseDenomWeight: sdk.NewInt(100),
expectError: true,
},
{
name: "internal error due to spot price precision being too small, resulting in 0 spot price",
quoteDenomPoolInput: sdk.NewCoin(baseDenom, sdk.OneInt()),
quoteDenomWeight: sdk.NewInt(100),
baseDenomPoolInput: sdk.NewCoin(quoteDenom, sdk.NewDec(10).PowerMut(19).TruncateInt().Sub(sdk.NewInt(2))),
baseDenomWeight: sdk.NewInt(100),
expectError: true,
},
{
name: "at min spot price",
quoteDenomPoolInput: sdk.NewCoin(baseDenom, sdk.OneInt()),
quoteDenomWeight: sdk.NewInt(100),
baseDenomPoolInput: sdk.NewCoin(quoteDenom, sdk.NewDec(10).PowerMut(18).TruncateInt()),
baseDenomWeight: sdk.NewInt(100),
expectedOutput: sdk.OneDec().Quo(sdk.NewDec(10).PowerMut(18)),
},
}

for _, tc := range tests {
Expand Down

0 comments on commit 598c53a

Please sign in to comment.