From 2ba4f848ea2fb3de196b5d71fda0c5473ed770cc Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Wed, 11 May 2022 20:19:18 +0200 Subject: [PATCH] Fix hackatom testing --- contracts/hackatom/src/contract.rs | 34 ++++++++++++------------- contracts/hackatom/tests/integration.rs | 2 +- 2 files changed, 17 insertions(+), 19 deletions(-) diff --git a/contracts/hackatom/src/contract.rs b/contracts/hackatom/src/contract.rs index 36c9d06196..9bc34efe7e 100644 --- a/contracts/hackatom/src/contract.rs +++ b/contracts/hackatom/src/contract.rs @@ -20,7 +20,7 @@ pub fn instantiate( info: MessageInfo, msg: InstantiateMsg, ) -> Result { - // deps.api.debug("here we go 🚀"); + deps.api.debug("here we go 🚀"); deps.storage.set( CONFIG_KEY, @@ -31,23 +31,6 @@ pub fn instantiate( })?, ); - // Uncomment your favourite panic case - - // panicked at 'Now what?', src/contract.rs:53:5 - panic!("Now what?"); - - // panicked at 'oh no (a = 3)', src/contract.rs:56:5 - // let a = 3; - // panic!("oh no (a = {a})"); - - // panicked at 'attempt to subtract with overflow', src/contract.rs:59:13 - // #[allow(arithmetic_overflow)] - // let _ = 5u32 - 8u32; - - // panicked at 'no entry found for key', src/contract.rs:62:13 - // let map = std::collections::HashMap::::new(); - // let _ = map["foo"]; - // This adds some unrelated event attribute for testing purposes Ok(Response::new().add_attribute("Let the", "hacking begin")) } @@ -206,7 +189,22 @@ fn do_allocate_large_memory(pages: u32) -> Result { } fn do_panic() -> Result { + // Uncomment your favourite panic case + + // panicked at 'This page intentionally faulted', src/contract.rs:53:5 panic!("This page intentionally faulted"); + + // panicked at 'oh no (a = 3)', src/contract.rs:56:5 + // let a = 3; + // panic!("oh no (a = {a})"); + + // panicked at 'attempt to subtract with overflow', src/contract.rs:59:13 + // #[allow(arithmetic_overflow)] + // let _ = 5u32 - 8u32; + + // panicked at 'no entry found for key', src/contract.rs:62:13 + // let map = std::collections::HashMap::::new(); + // let _ = map["foo"]; } fn do_user_errors_in_api_calls(api: &dyn Api) -> Result { diff --git a/contracts/hackatom/tests/integration.rs b/contracts/hackatom/tests/integration.rs index 0035900872..a9dcef713a 100644 --- a/contracts/hackatom/tests/integration.rs +++ b/contracts/hackatom/tests/integration.rs @@ -484,7 +484,7 @@ fn execute_panic() { ); match execute_res.unwrap_err() { VmError::RuntimeErr { msg, .. } => { - assert_eq!(msg, "Wasmer runtime error: RuntimeError: unreachable") + assert_eq!(msg, "Wasmer runtime error: RuntimeError: Aborted: panicked at 'This page intentionally faulted', src/contract.rs:195:5") } err => panic!("Unexpected error: {:?}", err), }