z5a_transfer_filetest.gno
3.34 Kb · 118 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/transfer"
13 "gno.land/r/aib/ibc/core"
14)
15
16// Transfer: success for native coins
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 testing.SetRealm(testing.NewUserRealm("g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm"))
29 testing.SetOriginSend(chain.NewCoins(chain.NewCoin("ugnot", 100)))
30
31 println("----------- assert render total_escrow/ugnot before Transfer")
32 println(transfer.Render("total_escrow/ugnot"))
33
34 transfer.Transfer(cross(cur), clientID, "atone1user", "ugnot", 100, uint64(time.Now().Add(time.Hour).Unix()), "memo")
35
36 println("----------- assert render total_escrow/ugnot after Transfer")
37 println(transfer.Render("total_escrow/ugnot"))
38}
39
40// Output:
41// ----------- assert render total_escrow/ugnot before Transfer
42// {"denom":"ugnot","amount":0}
43// ----------- assert render total_escrow/ugnot after Transfer
44// {"denom":"ugnot","amount":100}
45
46// Events:
47// [
48// {
49// "type": "create_client",
50// "attrs": [
51// {
52// "key": "client_id",
53// "value": "07-tendermint-1"
54// },
55// {
56// "key": "client_type",
57// "value": "07-tendermint"
58// },
59// {
60// "key": "consensus_heights",
61// "value": "2/2"
62// }
63// ],
64// "pkg_path": "gno.land/r/aib/ibc/core"
65// },
66// {
67// "type": "send_packet",
68// "attrs": [
69// {
70// "key": "packet_source_client",
71// "value": "07-tendermint-1"
72// },
73// {
74// "key": "packet_dest_client",
75// "value": "07-tendermint-2"
76// },
77// {
78// "key": "packet_sequence",
79// "value": "1"
80// },
81// {
82// "key": "packet_timeout_timestamp",
83// "value": "1234571490"
84// },
85// {
86// "key": "encoded_packet_hex",
87// "value": "0801120f30372d74656e6465726d696e742d311a0f30372d74656e6465726d696e742d3220e2a1d8cc042a7f0a087472616e7366657212087472616e736665721a0769637332302d3122166170706c69636174696f6e2f782d70726f746f6275662a480a0575676e6f7412033130301a28673177796d75343764726872306b7571323039386d3739326c797467746a326e797837377972736d220a61746f6e6531757365722a046d656d6f"
88// }
89// ],
90// "pkg_path": "gno.land/r/aib/ibc/core"
91// },
92// {
93// "type": "ibc_transfer",
94// "attrs": [
95// {
96// "key": "sender",
97// "value": "g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm"
98// },
99// {
100// "key": "receiver",
101// "value": "atone1user"
102// },
103// {
104// "key": "denom",
105// "value": "ugnot"
106// },
107// {
108// "key": "amount",
109// "value": "100"
110// },
111// {
112// "key": "memo",
113// "value": "memo"
114// }
115// ],
116// "pkg_path": "gno.land/r/aib/ibc/apps/transfer"
117// }
118// ]