Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( Coins1000000uband = sdk.NewCoins(sdk.NewInt64Coin("uband", 1000000)) Coins99999999uband = sdk.NewCoins(sdk.NewInt64Coin("uband", 99999999)) Coins100000000uband = sdk.NewCoins(sdk.NewInt64Coin("uband", 100000000)) )
nolint
View Source
var Wasm1 []byte = wat2wasm([]byte(`
(module
(type $t0 (func))
(type $t1 (func (param i64 i64 i64 i64)))
(type $t2 (func (param i64 i64)))
(import "env" "ask_external_data" (func $ask_external_data (type $t1)))
(import "env" "set_return_data" (func $set_return_data (type $t2)))
(func $prepare (export "prepare") (type $t0)
(local $l0 i64)
i64.const 1
i64.const 1
i32.const 1024
i64.extend_u/i32
tee_local $l0
i64.const 4
call $ask_external_data
i64.const 2
i64.const 2
get_local $l0
i64.const 4
call $ask_external_data
i64.const 3
i64.const 3
get_local $l0
i64.const 4
call $ask_external_data)
(func $execute (export "execute") (type $t0)
i32.const 1024
i64.extend_u/i32
i64.const 4
call $set_return_data)
(table $T0 1 1 anyfunc)
(memory $memory (export "memory") 17)
(data (i32.const 1024) "beeb"))
`))
A simple Owasm script with the following specification:
PREPARE: CALL ask_external_data with EID 1 DID 1 CALLDATA "beeb" CALL ask_external_data with EID 2 DID 2 CALLDATA "beeb" CALL ask_external_data with EID 3 DID 3 CALLDATA "beeb" EXECUTE: CALL set_return_date with RETDATE "beeb"
View Source
var Wasm2 []byte = wat2wasm([]byte(`
(module
(type $t0 (func))
(type $t2 (func (param i64 i64)))
(import "env" "set_return_data" (func $set_return_data (type $t2)))
(func $prepare (export "prepare")
i64.const 1024
i64.const 4
call $set_return_data)
(func $execute (export "execute"))
(memory $memory (export "memory") 17)
(data (i32.const 1024) "beeb"))
`))
A bad Owasm script with the following specification:
PREPARE: CALL set_return_data with RETDATA "beeb" -- Not allowed during prepare EXECUTE: DO NOTHING
View Source
var Wasm3 []byte = wat2wasm([]byte(`
(module
(type $t0 (func))
(type $t1 (func (param i64 i64 i64 i64)))
(type $t2 (func (param i64 i64)))
(import "env" "ask_external_data" (func $ask_external_data (type $t1)))
(import "env" "set_return_data" (func $set_return_data (type $t2)))
(func $prepare (export "prepare") (type $t0))
(func $execute (export "execute") (type $t0))
(table $T0 1 1 anyfunc)
(memory $memory (export "memory") 17)
(data (i32.const 1024) "beeb"))
`))
A silly oracle script, primarily to test that you must make at least one raw request:
PREPARE: DO NOTHING EXECUTE: DO NOTHING
View Source
var Wasm4 []byte
An oracle script for testing complex interactions.
PREPARE: Call into the given data source ids with the given calldata. EXECUTE: Assume all validators report, append all reports to the final result.
View Source
var Wasm9 []byte = wat2wasm([]byte(`
(module
(type $t0 (func))
(type $t1 (func (param i64 i64 i64 i64)))
(type $t2 (func (param i64 i64)))
(import "env" "ask_external_data" (func $ask_external_data (type $t1)))
(import "env" "set_return_data" (func $set_return_data (type $t2)))
(func $prepare (export "prepare") (type $t0))
(func $execute (export "execute") (type $t0)
i32.const 1024
i64.extend_u/i32
i64.const 4
call $set_return_data
i32.const 1024
i64.extend_u/i32
i64.const 4
call $set_return_data)
(table $T0 1 1 anyfunc)
(memory $memory (export "memory") 17)
(data (i32.const 1024) "beeb"))
`))
View Source
var WasmExtra1 []byte = wat2wasm([]byte(`
(module
(type $t0 (func))
(type $t2 (func (param i64 i64)))
(import "env" "set_return_data" (func $set_return_data (type $t2)))
(func $prepare (export "prepare") (type $t0))
(func $execute (export "execute") (type $t0))
(memory $memory (export "memory") 17))
`))
An extra Owasm code to test creating or editing oracle scripts.
View Source
var WasmExtra1FileName string
View Source
var WasmExtra2 []byte = wat2wasm([]byte(`
(module
(type $t0 (func))
(type $t1 (func (param i64 i64 i64 i64)))
(type $t2 (func (param i64 i64)))
(import "env" "ask_external_data" (func $ask_external_data (type $t1)))
(import "env" "set_return_data" (func $set_return_data (type $t2)))
(func $prepare (export "prepare") (type $t0))
(func $execute (export "execute") (type $t0))
(memory $memory (export "memory") 17))
`))
Another extra Owasm code to test creating or editing oracle scripts.
View Source
var WasmExtra2FileName string
Functions ¶
func CreateTestInput ¶
CreateTestInput creates a new test environment for unit tests.
Types ¶
type Account ¶
type Account struct { PrivKey crypto.PrivKey PubKey crypto.PubKey Address sdk.AccAddress ValAddress sdk.ValAddress }
Account is a data structure to store key of test account.
type Wasm4Input ¶
type Wasm4Output ¶
type Wasm4Output struct {
Ret string
}
Click to show internal directories.
Click to hide internal directories.