Skip to content

Commit 24da3df

Browse files
authored
Merge pull request #155 from gnoswap-labs/add-missed-const-in-pool-test
Add consts package and update references to MIN_PRICE
2 parents cbc7ee9 + 18d0abe commit 24da3df

4 files changed

+18
-11
lines changed

pool/_TEST_math_logic_test.gnoa

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import (
44
"std"
55
"testing"
66

7+
"gno.land/r/demo/consts"
8+
79
_ "gno.land/r/demo/grc20_wrapper"
810
)
911

@@ -39,12 +41,12 @@ func TestDrySwap_ZeroForOneTrue_AmountSpecified_Positive_16000(t *testing.T) {
3941
std.TestSetOrigCaller(test1)
4042

4143
// no mint == no liquidity => swap will fail
42-
_, _, ok := DrySwap(fooPath, barPath, fee500, "_", true, 16000, MIN_PRICE)
44+
_, _, ok := DrySwap(fooPath, barPath, fee500, "_", true, 16000, consts.MIN_PRICE)
4345
shouldEQ(t, ok, false)
4446

4547
// not enough mint == swap will fail
4648
Mint(fooPath, barPath, fee500, posAddr, -tickUpper, -tickLower, 10)
47-
_, _, ok = DrySwap(fooPath, barPath, fee500, "_", true, 16000, MIN_PRICE)
49+
_, _, ok = DrySwap(fooPath, barPath, fee500, "_", true, 16000, consts.MIN_PRICE)
4850
shouldEQ(t, ok, false)
4951

5052
Mint(fooPath, barPath, fee500, posAddr, -tickUpper, -tickLower, liquidityExpect) // -11000 ~ -9000
@@ -58,7 +60,7 @@ func TestDrySwap_ZeroForOneTrue_AmountSpecified_Positive_16000(t *testing.T) {
5860
"_", // recipient
5961
true, // zeroForOne
6062
16000, // amountSpecified
61-
MIN_PRICE, // sqrtPriceLimitX96
63+
consts.MIN_PRICE, // sqrtPriceLimitX96
6264
)
6365
shouldEQ(t, poolIn, bigint(16000))
6466
shouldEQ(t, poolOut, bigint(-5883))
@@ -75,7 +77,7 @@ func TestDrySwap_ZeroForOneTrue_AmountSpecified_Negative_16000(t *testing.T) {
7577
"_", // recipient
7678
true, // zeroForOne
7779
-16000, // amountSpecified
78-
MIN_PRICE, // sqrtPriceLimitX96
80+
consts.MIN_PRICE, // sqrtPriceLimitX96
7981
)
8082

8183
shouldEQ(t, poolIn, bigint(43511))

pool/_TEST_pool_multi_token_test.gnoa

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import (
44
"std"
55
"testing"
66

7+
"gno.land/r/demo/consts"
8+
79
_ "gno.land/r/demo/grc20_wrapper"
810
)
911

@@ -85,7 +87,7 @@ func TestSwapFooBarFooToBar(t *testing.T) {
8587
test1,
8688
true,
8789
bigint(16000),
88-
MIN_PRICE,
90+
consts.MIN_PRICE,
8991
std.GetOrigCaller(),
9092
)
9193
shouldEQ(t, poolIn, bigint(16000))
@@ -119,7 +121,7 @@ func TestSwapBarBazBarToBaz(t *testing.T) {
119121
test1,
120122
true,
121123
bigint(16000),
122-
MIN_PRICE,
124+
consts.MIN_PRICE,
123125
std.GetOrigCaller(),
124126
)
125127
shouldEQ(t, poolIn, bigint(16000))

pool/_TEST_pool_native_swap_test.gnoa

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@ import (
44
"std"
55
"testing"
66

7-
_ "gno.land/r/demo/grc20_wrapper"
7+
"gno.land/r/demo/consts"
88
"gno.land/r/demo/wugnot"
9-
109
pos "gno.land/r/demo/position"
10+
11+
_ "gno.land/r/demo/grc20_wrapper"
1112
)
1213

1314
var (
@@ -78,7 +79,7 @@ func TestSwapBuyNative(t *testing.T) {
7879
test1,
7980
true,
8081
bigint(10000),
81-
MIN_PRICE,
82+
consts.MIN_PRICE,
8283
std.GetOrigCaller(),
8384
)
8485
shouldEQ(t, amount0, bigint(10000))

pool/_TEST_pool_single_lp_test.gnoa

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import (
55
"std"
66
"testing"
77

8+
"gno.land/r/demo/consts"
9+
810
_ "gno.land/r/demo/grc20_wrapper"
911
)
1012

@@ -191,7 +193,7 @@ func TestSwap(t *testing.T) {
191193
// Swap several times
192194
std.TestSetPrevRealm("gno.land/r/demo/router")
193195
std.TestSetOrigCaller(test1)
194-
test_price := bigint(MIN_PRICE)
196+
test_price := bigint(consts.MIN_PRICE)
195197
{
196198
poolOldToken0Bal := balanceOfByRegisterCall(pool.token0Path, poolAddr)
197199
poolOldToken1Bal := balanceOfByRegisterCall(pool.token1Path, poolAddr)
@@ -320,7 +322,7 @@ func TestCollectProtocol(t *testing.T) {
320322

321323
std.TestSetPrevRealm("gno.land/r/demo/router")
322324
std.TestSetOrigCaller(test1)
323-
Swap(barPath, fooPath, fee500, test1, true, 200000, MIN_PRICE, std.GetOrigCaller()) // swap token0 -> token1 => fee only in token0
325+
Swap(barPath, fooPath, fee500, test1, true, 200000, consts.MIN_PRICE, std.GetOrigCaller()) // swap token0 -> token1 => fee only in token0
324326

325327
test1OldToken0Bal := balanceOfByRegisterCall(pool.token0Path, test1)
326328
test1OldToken1Bal := balanceOfByRegisterCall(pool.token1Path, test1)

0 commit comments

Comments
 (0)