Search Apps Documentation Source Content File Folder Download Copy Actions Download

z5f_transfer_filetest.gno

1.45 Kb · 39 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: native denom is rejected when the caller is not a direct user
17// call. This is the maketx-run / wrapper-realm scenario the IsUserCall guard
18// exists to block: -send can land elsewhere than this realm, so OriginSend
19// cannot be trusted.
20func main(cur realm) {
21	var (
22		chainID        = "chain-id-2"
23		clientState    = tmtesting.NewClientState(chainID, types.NewHeight(2, 2))
24		apphash        = tmtesting.Hash("apphash")
25		trustedValset  = tmtesting.GenValset()
26		consensusState = tmtesting.GenConsensusState(time.Now(), apphash, trustedValset.Hash())
27	)
28	clientID := core.CreateClient(cross(cur), clientState, consensusState)
29	core.RegisterCounterparty(cross(cur), clientID, [][]byte{[]byte("iavlStoreKey"), []byte("prefix2")}, "07-tendermint-2")
30
31	// Deliberately no testing.SetRealm(NewUserRealm(...)) — default package
32	// main caller fails IsUserCall(), matching maketx run / wrapper realm.
33	// OriginSend is set to prove the guard fires before any amount check.
34	testing.SetOriginSend(chain.NewCoins(chain.NewCoin("ugnot", 100)))
35	transfer.Transfer(cross(cur), clientID, "atone1user", "ugnot", 100, uint64(time.Now().Add(time.Hour).Unix()), "")
36}
37
38// Error:
39// native transfer must be a direct user call (maketx call)