-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Mauro Lacy
committed
Sep 18, 2024
1 parent
9af350c
commit a7a03ad
Showing
1 changed file
with
35 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
use cosmwasm_std::{ContractResult, Response}; | ||
use cosmwasm_vm::testing::{instantiate, mock_env, mock_info, mock_instance}; | ||
|
||
use btc_finality::msg::InstantiateMsg; | ||
|
||
// wasm binary lite version | ||
static WASM: &[u8] = include_bytes!("../../../artifacts/btc_finality.wasm"); | ||
/// Wasm size limit: https://github.com/CosmWasm/wasmd/blob/main/x/wasm/types/validation.go#L24-L25 | ||
const MAX_WASM_SIZE: usize = 800 * 1024; // 800 KB | ||
|
||
const CREATOR: &str = "creator"; | ||
|
||
#[test] | ||
fn wasm_size_limit_check() { | ||
assert!( | ||
WASM.len() < MAX_WASM_SIZE, | ||
"BTC finality contract wasm binary is too large: {} (target: {})", | ||
WASM.len(), | ||
MAX_WASM_SIZE | ||
); | ||
} | ||
|
||
#[test] | ||
fn instantiate_works() { | ||
let mut deps = mock_instance(WASM, &[]); | ||
|
||
let msg = InstantiateMsg { | ||
params: None, | ||
admin: None, | ||
}; | ||
let info = mock_info(CREATOR, &[]); | ||
let res: ContractResult<Response> = instantiate(&mut deps, mock_env(), info, msg); | ||
let msgs = res.unwrap().messages; | ||
assert_eq!(0, msgs.len()); | ||
} |