Skip to content

Latest commit

 

History

History
151 lines (106 loc) · 2.57 KB

testing.md

File metadata and controls

151 lines (106 loc) · 2.57 KB
id
testing

Testing

func TestSkipHeights(count int64)
func TestSetOrigCaller(addr Address)
func TestSetOrigPkgAddr(addr Address)
func TestSetOrigSend(sent, spent Coins)
func TestIssueCoins(addr Address, coins Coins)
func TestSetRealm(realm Realm)
func NewUserRealm(address Address) Realm
func NewCodeRealm(pkgPath string) Realm

TestSkipHeights

func TestSkipHeights(count int64)

Modifies the block height variable by skipping count blocks.

It also increases block timestamp by 5 seconds for every single count

Usage

std.TestSkipHeights(100)

TestSetOrigCaller

func TestSetOrigCaller(addr Address)

Sets the current caller of the transaction to addr.

Usage

std.TestSetOrigCaller(std.Address("g1jg8mtutu9khhfwc4nxmuhcpftf0pajdhfvsqf5"))

TestSetOrigPkgAddr

func TestSetOrigPkgAddr(addr Address)

Sets the call entry realm address to addr.

Usage

std.TestSetOrigPkgAddr(std.Address("g1ecely4gjy0yl6s9kt409ll330q9hk2lj9ls3ec"))

TestSetOrigSend

func TestSetOrigSend(sent, spent Coins)

Sets the sent & spent coins for the current context.

Usage

std.TestSetOrigSend(sent, spent Coins)

TestIssueCoins

func TestIssueCoins(addr Address, coins Coins)

Issues testing context coins to addr.

Usage

issue := std.Coins{{"coin1", 100}, {"coin2", 200}}
addr := std.Address("g1ecely4gjy0yl6s9kt409ll330q9hk2lj9ls3ec")
std.TestIssueCoins(addr, issue)

TestSetRealm

func TestSetRealm(rlm Realm)

Sets the realm for the current frame. After calling TestSetRealm(), calling CurrentRealm() in the same test function will yield the value of rlm, and any PrevRealm() called from a function used after TestSetRealm will yield rlm.

Should be used in combination with NewUserRealm & NewCodeRealm.

Usage

addr := std.Address("g1ecely4gjy0yl6s9kt409ll330q9hk2lj9ls3ec")
std.TestSetRealm(std.NewUserRealm(""))
// or 
std.TestSetRealm(std.NewCodeRealm("gno.land/r/demo/users"))

NewUserRealm

func NewUserRealm(address Address) Realm

Creates a new user realm for testing purposes.

Usage

addr := std.Address("g1ecely4gjy0yl6s9kt409ll330q9hk2lj9ls3ec")
userRealm := std.NewUserRealm(addr)

NewCodeRealm

func NewCodeRealm(pkgPath string) Realm

Creates a new code realm for testing purposes.

Usage

path := "gno.land/r/demo/boards"
codeRealm := std.NewCodeRealm(path)