Search Apps Documentation Source Content File Folder Download Copy

z_2_filetest.gno

1.23 Kb ยท 50 lines
 1// Empty line between the directives is important for them to be parsed
 2// independently. :facepalm:
 3
 4// PKGPATH: gno.land/r/demo/bank1
 5
 6package bank1
 7
 8import (
 9	"std"
10
11	"gno.land/r/demo/banktest"
12)
13
14func main() {
15	banktestAddr := std.DerivePkgAddr("gno.land/r/demo/banktest")
16
17	// print main balance before.
18	mainaddr := std.DerivePkgAddr("gno.land/r/demo/bank1")
19	std.TestSetOrigCaller(mainaddr)
20
21	banker := std.GetBanker(std.BankerTypeReadonly)
22	mainbal := banker.GetCoins(mainaddr)
23	println("main before:", mainbal) // plus OrigSend equals 300.
24
25	// simulate a Deposit call.
26	std.TestSetOrigPkgAddr(banktestAddr)
27	std.TestIssueCoins(banktestAddr, std.Coins{{"ugnot", 100000000}})
28	std.TestSetOrigSend(std.Coins{{"ugnot", 100000000}}, nil)
29	res := banktest.Deposit("ugnot", 55000000)
30	println("Deposit():", res)
31
32	// print main balance after.
33	mainbal = banker.GetCoins(mainaddr)
34	println("main after:", mainbal) // now 255.
35
36	// simulate a Render().
37	res = banktest.Render("")
38	println(res)
39}
40
41// Output:
42// main before:
43// Deposit(): returned!
44// main after: 55000000ugnot
45// ## recent activity
46//
47//  * g1tnpdmvrmtgql8fmxgsq9rwtst5hsxahk3f05dk 100000000ugnot sent, 55000000ugnot returned, at 2009-02-13 11:31pm UTC
48//
49// ## total deposits
50// 45000000ugnot