1// SEND: 100000000ugnot
2
3package main
4
5import (
6 "std"
7
8 "gno.land/r/demo/banktest"
9)
10
11func main() {
12 // set up main address and banktest addr.
13 banktestAddr := std.DerivePkgAddr("gno.land/r/demo/banktest")
14 mainaddr := std.DerivePkgAddr("main")
15 std.TestSetOrigCaller(mainaddr)
16 std.TestSetOrigPkgAddr(banktestAddr)
17
18 // get and print balance of mainaddr.
19 // with the SEND, + 200 gnot given by the TestContext, main should have 300gnot.
20 banker := std.GetBanker(std.BankerTypeRealmSend)
21 mainbal := banker.GetCoins(mainaddr)
22 println("main before:", mainbal)
23
24 // simulate a Deposit call. use Send + OrigSend to simulate -send.
25 banker.SendCoins(mainaddr, banktestAddr, std.Coins{{"ugnot", 100_000_000}})
26 std.TestSetOrigSend(std.Coins{{"ugnot", 100_000_000}}, nil)
27 res := banktest.Deposit("ugnot", 50_000_000)
28 println("Deposit():", res)
29
30 // print main balance after.
31 mainbal = banker.GetCoins(mainaddr)
32 println("main after:", mainbal)
33
34 // simulate a Render(). banker should have given back all coins.
35 res = banktest.Render("")
36 println(res)
37}
38
39// Output:
40// main before: 300000000ugnot
41// Deposit(): returned!
42// main after: 250000000ugnot
43// ## recent activity
44//
45// * g17rgsdnfxzza0sdfsdma37sdwxagsz378833ca4 100000000ugnot sent, 50000000ugnot returned, at 2009-02-13 11:31pm UTC
46//
47// ## total deposits
48// 50000000ugnot
z_0_filetest.gno
1.30 Kb ยท 48 lines