Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
fixed wasm tests according to @athei feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
agryaznov committed Feb 4, 2022
1 parent f2d6fcb commit e22a338
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions frame/contracts/src/wasm/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2281,7 +2281,7 @@ mod tests {
"#;
let output = execute(CODE_IS_CONTRACT, vec![], MockExt::default()).unwrap();

// The mock ext just returns the same data that was passed as the subject.
// The mock ext just always returns 1u32 (`true`).
assert_eq!(
output,
ExecReturnValue { flags: ReturnFlags::empty(), data: Bytes(1u32.encode()) },
Expand All @@ -2294,18 +2294,20 @@ mod tests {
const CODE_CALLER_IS_ORIGIN: &str = r#"
;; This runs `caller_is_origin` check on zero account address
(module
(import "__unstable__" "seal_caller_is_origin" (func $seal_is_contract (result i32)))
(import "__unstable__" "seal_caller_is_origin" (func $seal_caller_is_origin (result i32)))
(import "seal0" "seal_return" (func $seal_return (param i32 i32 i32)))
(import "env" "memory" (memory 1 1))
;; [0, 4) here we store the return code of the `seal_caller_is_origin`
;; [0, 4) here the return code of the `seal_caller_is_origin` will be stored
;; we initialize it with non-zero value to be sure that it's being overwritten below
(data (i32.const 0) "\10\10\10\10")
(func (export "deploy"))
(func (export "call")
(i32.store
(i32.const 4)
(call $seal_is_contract)
(i32.const 0)
(call $seal_caller_is_origin)
)
;; exit with success and take `seal_caller_is_origin` return code to the output buffer
(call $seal_return (i32.const 0) (i32.const 0) (i32.const 4))
Expand All @@ -2314,7 +2316,7 @@ mod tests {
"#;
let output = execute(CODE_CALLER_IS_ORIGIN, vec![], MockExt::default()).unwrap();

// The mock ext just returns the same data that was passed as the subject.
// The mock ext just always returns 0u32 (`false`)
assert_eq!(
output,
ExecReturnValue { flags: ReturnFlags::empty(), data: Bytes(0u32.encode()) },
Expand Down

0 comments on commit e22a338

Please sign in to comment.