Search Apps Documentation Source Content File Folder Download Copy Actions Download State String Boolean Number Struct Map Slice Pointer Function Closure Reference Nil Package Type Interface Unknown

z5e_transfer_filetest.gno

1.45 Kb · 43 lines
 1// PKGPATH: gno.land/r/aib/main
 2package main
 3
 4import (
 5	"chain"
 6	"testing"
 7	"time"
 8
 9	tmtesting "gno.land/p/aib/ibc/lightclient/tendermint/testing"
10	"gno.land/p/aib/ibc/types"
11
12	"gno.land/r/aib/ibc/apps/testing/grc20test"
13	"gno.land/r/aib/ibc/apps/transfer"
14	"gno.land/r/aib/ibc/core"
15)
16
17// TransferGRC20: insufficient balance
18func main(cur realm) {
19	var (
20		chainID        = "chain-id-2"
21		clientState    = tmtesting.NewClientState(chainID, types.NewHeight(2, 2))
22		apphash        = tmtesting.Hash("apphash")
23		trustedValset  = tmtesting.GenValset()
24		consensusState = tmtesting.GenConsensusState(time.Now(), apphash, trustedValset.Hash())
25	)
26	clientID := core.CreateClient(cross(cur), clientState, consensusState)
27	core.RegisterCounterparty(cross(cur), clientID, [][]byte{[]byte("iavlStoreKey"), []byte("prefix2")}, "07-tendermint-2")
28
29	caller := cur.Previous().Address()
30
31	// Mint only 50 tokens but try to transfer 100
32	grc20test.Mint(cross(cur), caller, 50)
33
34	transferAppAddr := chain.PackageAddress("gno.land/r/aib/ibc/apps/transfer")
35	grc20test.Approve(cross(cur), caller, transferAppAddr, 100)
36
37	denom := "gno.land/r/aib/ibc/apps/testing/grc20test." + grc20test.Slug
38	testing.SetRealm(testing.NewUserRealm(caller))
39	transfer.Transfer(cross(cur), clientID, "atone1user", denom, 100, uint64(time.Now().Add(time.Hour).Unix()), "")
40}
41
42// Error:
43// send packet failed for payload #0 app "transfer": escrow GRC20 gno.land/r/aib/ibc/apps/testing/grc20test.TEST error: insufficient balance