Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix/gno-type-check #240

Merged
merged 3 commits into from
Jun 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 0 additions & 12 deletions pool/_TEST_/__TEST_0_INIT_VARIABLE_AND_HELPER_test.gno
Original file line number Diff line number Diff line change
Expand Up @@ -46,18 +46,6 @@ func shouldNEQ(t *testing.T, got, expected interface{}) {
}
}

func shouldGT(t *testing.T, l, r interface{}) {
if !(l < r) {
t.Errorf("expected %v < %v", l, r)
}
}

func shouldLT(t *testing.T, l, r interface{}) {
if !(l > r) {
t.Errorf("expected %v > %v", l, r)
}
}

func shouldPanic(t *testing.T, f func()) {
defer func() {
if r := recover(); r == nil {
Expand Down
12 changes: 0 additions & 12 deletions position/_TEST_/__TEST_0_INIT_VARS_HELPERS_test.gno
Original file line number Diff line number Diff line change
Expand Up @@ -52,18 +52,6 @@ func shouldNEQ(t *testing.T, got, expected interface{}) {
}
}

func shouldGT(t *testing.T, l, r interface{}) {
if !(l < r) {
t.Errorf("expected %v < %v", l, r)
}
}

func shouldLT(t *testing.T, l, r interface{}) {
if !(l > r) {
t.Errorf("expected %v > %v", l, r)
}
}

func shouldPanic(t *testing.T, f func()) {
defer func() {
if r := recover(); r == nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ func TestSwap2(t *testing.T) {
// --- event: {GNOSWAP gno.land/r/demo/pool Swap [{m_callType INDIRECT} {m_origCaller g13f63ua8uhmuf9mgc0x8zfz04yrsaqh7j78vcgq} {m_prevRealm gno.land/r/demo/router} {p_poolPath gno.land/r/demo/bar:gno.land/r/demo/foo:500} {p_zeroForOne true} {p_amountSpecified 1000000} {p_sqrtPriceLimitX96 4295128740} {p_payer g13f63ua8uhmuf9mgc0x8zfz04yrsaqh7j78vcgq} {p_recipient g13f63ua8uhmuf9mgc0x8zfz04yrsaqh7j78vcgq} {amount0 1000000} {amount1 -2676640} {protocol_fee0 0} {protocol_fee1 0} {swap_fee 500}]}

// UNCLAIMED_FEE

std.TestSetRealm(gsaRealm)
std.TestSetOrigCaller(gsa)

oldFee0, oldFee1 := unclaimedFee(uint64(1))
Expand Down
12 changes: 0 additions & 12 deletions router/_TEST_/__TEST_0_INIT_VARS_HELPERS_test.gno
Original file line number Diff line number Diff line change
Expand Up @@ -48,18 +48,6 @@ func shouldNEQ(t *testing.T, got, expected interface{}) {
}
}

func shouldGT(t *testing.T, l, r interface{}) {
if !(l < r) {
t.Errorf("expected %v < %v", l, r)
}
}

func shouldLT(t *testing.T, l, r interface{}) {
if !(l > r) {
t.Errorf("expected %v > %v", l, r)
}
}

func shouldPanic(t *testing.T, f func()) {
defer func() {
if r := recover(); r == nil {
Expand Down
8 changes: 4 additions & 4 deletions router/_TEST_/__TEST_router_all_2_route_2_hop_test.gnoA
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ func TestCreatePool(t *testing.T) {

gns.Approve(a2u(consts.POOL_ADDR), consts.POOL_CREATION_FEE*2)

pl.CreatePool(barPath, bazPath, uint16(500), "130621891405341611593710811006") // tick = 10_000, ratio = 2.71814592682522526700950038502924144268035888671875
pl.CreatePool(bazPath, quxPath, uint16(500), "130621891405341611593710811006") // tick = 10_000, ratio = 2.71814592682522526700950038502924144268035888671875
pl.CreatePool(barPath, bazPath, uint32(500), "130621891405341611593710811006") // tick = 10_000, ratio = 2.71814592682522526700950038502924144268035888671875
pl.CreatePool(bazPath, quxPath, uint32(500), "130621891405341611593710811006") // tick = 10_000, ratio = 2.71814592682522526700950038502924144268035888671875
// --- event: {GNOSWAP gno.land/r/demo/pool CreatePool [{m_callType DIRECT} {m_origCaller g13f63ua8uhmuf9mgc0x8zfz04yrsaqh7j78vcgq} {m_prevRealm } {p_poolPath gno.land/r/demo/bar:gno.land/r/demo/baz:500}]}
// --- event: {GNOSWAP gno.land/r/demo/pool CreatePool [{m_callType DIRECT} {m_origCaller g13f63ua8uhmuf9mgc0x8zfz04yrsaqh7j78vcgq} {m_prevRealm } {p_poolPath gno.land/r/demo/baz:gno.land/r/demo/qux:500}]}
}
Expand All @@ -35,8 +35,8 @@ func TestPositionMint(t *testing.T) {
qux.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX)

// Mint
pn.Mint(barPath, bazPath, uint16(500), int32(9000), int32(11000), "100000", "100000", "0", "0", max_timeout, gsa.String())
pn.Mint(bazPath, quxPath, uint16(500), int32(9000), int32(11000), "100000", "100000", "0", "0", max_timeout, gsa.String())
pn.Mint(barPath, bazPath, uint32(500), int32(9000), int32(11000), "100000", "100000", "0", "0", max_timeout, gsa.String())
pn.Mint(bazPath, quxPath, uint32(500), int32(9000), int32(11000), "100000", "100000", "0", "0", max_timeout, gsa.String())
// --- event: {GNOSWAP gno.land/r/demo/position Mint [{m_callType DIRECT} {m_origCaller g13f63ua8uhmuf9mgc0x8zfz04yrsaqh7j78vcgq} {m_prevRealm } {p_poolPath gno.land/r/demo/bar:gno.land/r/demo/baz:500} {p_tickLower 9000} {p_tickUpper 11000} {tokenId 1} {liquidity 1243732} {amount0 36790} {amount1 100000}]}
// --- event: {GNOSWAP gno.land/r/demo/position Mint [{m_callType DIRECT} {m_origCaller g13f63ua8uhmuf9mgc0x8zfz04yrsaqh7j78vcgq} {m_prevRealm } {p_poolPath gno.land/r/demo/baz:gno.land/r/demo/qux:500} {p_tickLower 9000} {p_tickUpper 11000} {tokenId 2} {liquidity 1243732} {amount0 36790} {amount1 100000}]}
}
Expand Down
8 changes: 4 additions & 4 deletions router/_TEST_/__TEST_router_swap_route_2route_2hop_test.gnoA
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ func TestCreatePool(t *testing.T) {
std.TestSetRealm(gsaRealm)
gns.Approve(a2u(consts.POOL_ADDR), consts.POOL_CREATION_FEE*2)

pl.CreatePool(barPath, bazPath, uint16(500), "130621891405341611593710811006") // tick = 10_000, ratio = 2.71814592682522526700950038502924144268035888671875
pl.CreatePool(barPath, bazPath, uint32(500), "130621891405341611593710811006") // tick = 10_000, ratio = 2.71814592682522526700950038502924144268035888671875
// --- event: {GNOSWAP gno.land/r/demo/pool CreatePool [{m_callType DIRECT} {m_origCaller g13f63ua8uhmuf9mgc0x8zfz04yrsaqh7j78vcgq} {m_prevRealm } {p_poolPath gno.land/r/demo/bar:gno.land/r/demo/baz:500}]}

pl.CreatePool(bazPath, quxPath, uint16(500), "130621891405341611593710811006") // tick = 10_000, ratio = 2.71814592682522526700950038502924144268035888671875
pl.CreatePool(bazPath, quxPath, uint32(500), "130621891405341611593710811006") // tick = 10_000, ratio = 2.71814592682522526700950038502924144268035888671875
// --- event: {GNOSWAP gno.land/r/demo/pool CreatePool [{m_callType DIRECT} {m_origCaller g13f63ua8uhmuf9mgc0x8zfz04yrsaqh7j78vcgq} {m_prevRealm } {p_poolPath gno.land/r/demo/baz:gno.land/r/demo/qux:500}]}

// jsonOutput := pl.ApiGetPools()
Expand All @@ -39,10 +39,10 @@ func TestPositionMint(t *testing.T) {
qux.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX)

// Mint
pn.Mint(barPath, bazPath, uint16(500), int32(9000), int32(11000), "100000", "100000", "0", "0", max_timeout, gsa.String())
pn.Mint(barPath, bazPath, uint32(500), int32(9000), int32(11000), "100000", "100000", "0", "0", max_timeout, gsa.String())
// --- event: {GNOSWAP gno.land/r/demo/position Mint [{m_callType DIRECT} {m_origCaller g13f63ua8uhmuf9mgc0x8zfz04yrsaqh7j78vcgq} {m_prevRealm } {p_poolPath gno.land/r/demo/bar:gno.land/r/demo/baz:500} {p_tickLower 9000} {p_tickUpper 11000} {tokenId 1} {liquidity 1243732} {amount0 36790} {amount1 100000}]}

pn.Mint(bazPath, quxPath, uint16(500), int32(9000), int32(11000), "100000", "100000", "0", "0", max_timeout, gsa.String())
pn.Mint(bazPath, quxPath, uint32(500), int32(9000), int32(11000), "100000", "100000", "0", "0", max_timeout, gsa.String())
// --- event: {GNOSWAP gno.land/r/demo/position Mint [{m_callType DIRECT} {m_origCaller g13f63ua8uhmuf9mgc0x8zfz04yrsaqh7j78vcgq} {m_prevRealm } {p_poolPath gno.land/r/demo/baz:gno.land/r/demo/qux:500} {p_tickLower 9000} {p_tickUpper 11000} {tokenId 2} {liquidity 1243732} {amount0 36790} {amount1 100000}]}
}

Expand Down
14 changes: 1 addition & 13 deletions staker/_TEST_/__TEST_0_INIT_VARIABLE_AND_HELPER_test.gno
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ var (
var (
gsaRealm = std.NewUserRealm(gsa)
iraRealm = std.NewUserRealm(ira)

posRealm = std.NewCodeRealm(consts.POSITION_PATH)
rouRealm = std.NewCodeRealm(consts.ROUTER_PATH)
stkRealm = std.NewCodeRealm(consts.STAKER_PATH)
Expand Down Expand Up @@ -61,18 +61,6 @@ func shouldNEQ(t *testing.T, got, expected interface{}) {
}
}

func shouldGT(t *testing.T, l, r interface{}) {
if !(l < r) {
t.Errorf("expected %v < %v", l, r)
}
}

func shouldLT(t *testing.T, l, r interface{}) {
if !(l > r) {
t.Errorf("expected %v > %v", l, r)
}
}

func shouldPanic(t *testing.T, f func()) {
defer func() {
if r := recover(); r == nil {
Expand Down
1 change: 0 additions & 1 deletion staker/_TEST_/__TEST_Z_z4_mint_and_stake_filetest.gnoA
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,6 @@ func main() {
mintAndStake()
collectFee()
collectReward()
unstakeToken()
}

func createPool() {
Expand Down
4 changes: 2 additions & 2 deletions staker/_TEST_/__TEST_staker_collect_reward_test.gnoA
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func TestPositionMint01(t *testing.T) {
lpTokenId, liquidity, amount0, amount1 := pn.Mint(
barPath, // token0
quxPath, // token1
uint16(500), // fee
uint32(500), // fee
int32(9000), // tickLower
int32(11000), // tickUpper
"1000", // amount0Desired
Expand Down Expand Up @@ -86,7 +86,7 @@ func TestPositionMint02(t *testing.T) {
lpTokenId, liquidity, amount0, amount1 := pn.Mint(
barPath, // token0
quxPath, // token1
uint16(500), // fee
uint32(500), // fee
int32(9100), // tickLower
int32(12000), // tickUpper
"5000", // amount0Desired
Expand Down
6 changes: 3 additions & 3 deletions staker/_TEST_/__TEST_staker_get_test.gnoA
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func TestPoolInitCreatePool(t *testing.T) {
gns.Approve(a2u(consts.POOL_ADDR), consts.POOL_CREATION_FEE)
std.TestSkipHeights(2)

pl.CreatePool(barPath, quxPath, 500, "130621891405341611593710811006") // tick 10_000 ≈ x2.7
pl.CreatePool(barPath, quxPath, uint32(500), "130621891405341611593710811006") // tick 10_000 ≈ x2.7
// --- event: {GNOSWAP gno.land/r/demo/pool CreatePool [{m_callType DIRECT} {m_origCaller g13f63ua8uhmuf9mgc0x8zfz04yrsaqh7j78vcgq} {m_prevRealm } {p_poolPath gno.land/r/demo/bar:gno.land/r/demo/qux:500}]}

std.TestSkipHeights(1)
Expand All @@ -39,7 +39,7 @@ func TestPositionMint01(t *testing.T) {
lpTokenId, liquidity, amount0, amount1 := pn.Mint(
barPath, // token0
quxPath, // token1
uint16(500), // fee
uint32(500), // fee
int32(9000), // tickLower
int32(11000), // tickUpper
"1000", // amount0Desired
Expand Down Expand Up @@ -73,7 +73,7 @@ func TestPositionMint02(t *testing.T) {
lpTokenId, liquidity, amount0, amount1 := pn.Mint(
barPath, // token0
quxPath, // token1
uint16(500), // fee
uint32(500), // fee
int32(9100), // tickLower
int32(12000), // tickUpper
"5000", // amount0Desired
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func TestPoolInitCreatePool(t *testing.T) {
gns.Approve(a2u(consts.POOL_ADDR), consts.POOL_CREATION_FEE)
std.TestSkipHeights(1)

pl.CreatePool(consts.GNS_PATH, consts.GNOT, 500, "130621891405341611593710811006") // tick 10_000 ≈ x2.7
pl.CreatePool(consts.GNS_PATH, consts.GNOT, uint32(500), "130621891405341611593710811006") // tick 10_000 ≈ x2.7
// --- event: {GNOSWAP gno.land/r/demo/pool CreatePool [{m_callType DIRECT} {m_origCaller g13f63ua8uhmuf9mgc0x8zfz04yrsaqh7j78vcgq} {m_prevRealm } {p_poolPath gno.land/r/demo/gns:gno.land/r/demo/wugnot:500}]}
std.TestSkipHeights(1)
}
Expand Down Expand Up @@ -67,7 +67,7 @@ func TestPositionMintNative01(t *testing.T) {
lpTokenId, liquidity, amount0, amount1 := pn.Mint(
consts.GNS_PATH, // token0
consts.GNOT, // token1
uint16(500), // fee
uint32(500), // fee
int32(9000), // tickLower
int32(11000), // tickUpper
"1000", // amount0Desired
Expand Down Expand Up @@ -115,7 +115,7 @@ func TestPositionMintNative02(t *testing.T) {
lpTokenId, liquidity, amount0, amount1 := pn.Mint(
consts.GNS_PATH, // token0
consts.GNOT, // token1
uint16(500), // fee
uint32(500), // fee
int32(9000), // tickLower
int32(11000), // tickUpper
"1000", // amount0Desired
Expand Down
6 changes: 3 additions & 3 deletions staker/_TEST_/__TEST_staker_one_increase_external_test.gnoA
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func TestPoolCreatePool(t *testing.T) {
gns.Approve(a2u(consts.POOL_ADDR), consts.POOL_CREATION_FEE)
std.TestSkipHeights(1)

pl.CreatePool(fooPath, barPath, 500, "130621891405341611593710811006") // tick 10_000 ≈ x2.7
pl.CreatePool(fooPath, barPath, uint32(500), "130621891405341611593710811006") // tick 10_000 ≈ x2.7
// --- event: {GNOSWAP gno.land/r/demo/pool CreatePool [{m_callType DIRECT} {m_origCaller g13f63ua8uhmuf9mgc0x8zfz04yrsaqh7j78vcgq} {m_prevRealm } {p_poolPath gno.land/r/demo/bar:gno.land/r/demo/foo:500}]}

std.TestSkipHeights(1)
Expand All @@ -54,7 +54,7 @@ func TestPositionMint01(t *testing.T) {
lpTokenId, liquidity, amount0, amount1 := pn.Mint(
fooPath, // token0
barPath, // token1
uint16(500), // fee
uint32(500), // fee
int32(9000), // tickLower
int32(11000), // tickUpper
"1000", // amount0Desired
Expand Down Expand Up @@ -88,7 +88,7 @@ func TestPositionMint02(t *testing.T) {
lpTokenId, liquidity, amount0, amount1 := pn.Mint(
fooPath, // token0
barPath, // token1
uint16(500), // fee
uint32(500), // fee
int32(9100), // tickLower
int32(12000), // tickUpper
"5000", // amount0Desired
Expand Down
10 changes: 5 additions & 5 deletions staker/_TEST_/__TEST_staker_rpc_api_test.gnoA
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ func TestPoolCreatePool(t *testing.T) {
gns.Approve(a2u(consts.POOL_ADDR), consts.POOL_CREATION_FEE)
std.TestSkipHeights(1)

pl.CreatePool(fooPath, barPath, 500, "130621891405341611593710811006") // tick 10_000 ≈ x2.7
pl.CreatePool(fooPath, barPath, uint32(500), "130621891405341611593710811006") // tick 10_000 ≈ x2.7
// --- event: {GNOSWAP gno.land/r/demo/pool CreatePool [{m_callType DIRECT} {m_origCaller g13f63ua8uhmuf9mgc0x8zfz04yrsaqh7j78vcgq} {m_prevRealm } {p_poolPath gno.land/r/demo/bar:gno.land/r/demo/foo:500}]}

pl.CreatePool(bazPath, quxPath, 500, "130621891405341611593710811006") // tick 10_000 ≈ x2.7
pl.CreatePool(bazPath, quxPath, uint32(500), "130621891405341611593710811006") // tick 10_000 ≈ x2.7
// --- event: {GNOSWAP gno.land/r/demo/pool CreatePool [{m_callType DIRECT} {m_origCaller g13f63ua8uhmuf9mgc0x8zfz04yrsaqh7j78vcgq} {m_prevRealm } {p_poolPath gno.land/r/demo/baz:gno.land/r/demo/qux:500}]}

std.TestSkipHeights(1)
Expand All @@ -57,7 +57,7 @@ func TestPositionMintFooBar01(t *testing.T) {
lpTokenId, liquidity, amount0, amount1 := pn.Mint(
fooPath, // token0
barPath, // token1
uint16(500), // fee
uint32(500), // fee
int32(9000), // tickLower
int32(11000), // tickUpper
"1000", // amount0Desired
Expand Down Expand Up @@ -91,7 +91,7 @@ func TestPositionMintFooBar02(t *testing.T) {
lpTokenId, liquidity, amount0, amount1 := pn.Mint(
fooPath, // token0
barPath, // token1
uint16(500), // fee
uint32(500), // fee
int32(9100), // tickLower
int32(12000), // tickUpper
"5000", // amount0Desired
Expand Down Expand Up @@ -125,7 +125,7 @@ func TestPositionMintBazQux01(t *testing.T) {
lpTokenId, liquidity, amount0, amount1 := pn.Mint(
bazPath, // token0
quxPath, // token1
uint16(500), // fee
uint32(500), // fee
int32(9100), // tickLower
int32(12000), // tickUpper
"5000", // amount0Desired
Expand Down