From 158d843342f1e845c9cb62aec8e76fd65b13c828 Mon Sep 17 00:00:00 2001 From: n3wbie Date: Wed, 8 Jan 2025 15:24:52 +0900 Subject: [PATCH] test: fix --- launchpad/_helper_test.gno | 8 +++++++- launchpad/deposit_test.gno | 14 +++++++++----- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/launchpad/_helper_test.gno b/launchpad/_helper_test.gno index 46a224508..d1008f935 100644 --- a/launchpad/_helper_test.gno +++ b/launchpad/_helper_test.gno @@ -6,12 +6,18 @@ import ( "gno.land/p/demo/grc/grc20" "gno.land/p/demo/testutils" - "gno.land/p/demo/ufmt" pusers "gno.land/p/demo/users" "gno.land/r/demo/users" + "gno.land/r/gnoswap/v1/common" "gno.land/r/gnoswap/v1/consts" ) +var ( + adminAddr = consts.ADMIN + adminUser = common.AddrToUser(adminAddr) + adminRealm = std.NewUserRealm(adminAddr) +) + // MockXGNSToken implements basic functionality for testing xgns token type MockXGNSToken struct { token *grc20.Token diff --git a/launchpad/deposit_test.gno b/launchpad/deposit_test.gno index 08a2679ae..3d7a55c29 100644 --- a/launchpad/deposit_test.gno +++ b/launchpad/deposit_test.gno @@ -2,16 +2,17 @@ package launchpad import ( "std" - "strings" "testing" "time" "gno.land/p/demo/testutils" "gno.land/p/demo/uassert" "gno.land/p/demo/ufmt" + "gno.land/r/gnoswap/v1/common" "gno.land/r/gnoswap/v1/consts" - "gno.land/r/gnoswap/v1/gov/xgns" + + "gno.land/r/gnoswap/v1/gns" ) // Mock data structs @@ -320,12 +321,11 @@ func TestDepositGns(t *testing.T) { t.Run("Fail with insufficient balance", func(t *testing.T) { std.TestSetRealm(std.NewUserRealm(testAddr)) - mockTeller.balance = 500 // Less than required deposit amount defer func() { r := recover() if r != nil { - t.Fatalf("Recovered from panic: %v", r) + t.Logf("Recovered from panic: %v", r) } }() @@ -333,8 +333,12 @@ func TestDepositGns(t *testing.T) { }) t.Run("Success with sufficient balance", func(t *testing.T) { + // transfer enough gns + std.TestSetRealm(adminRealm) + gns.Transfer(common.AddrToUser(testAddr), 1000) + std.TestSetRealm(std.NewUserRealm(testAddr)) - mockTeller.balance = 2000 // More than required deposit amount + gns.Approve(common.AddrToUser(consts.LAUNCHPAD_ADDR), 1000) depositId := DepositGns(project.id+":30", 1000) deposit := deposits[depositId]