Search Apps Documentation Source Content File Folder Download Copy Actions Download

z5e_transfer_filetest.gno

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