diff --git a/contracts/axone-cognitarium/src/contract.rs b/contracts/axone-cognitarium/src/contract.rs index 2ad500d3..0b723f02 100644 --- a/contracts/axone-cognitarium/src/contract.rs +++ b/contracts/axone-cognitarium/src/contract.rs @@ -446,12 +446,12 @@ mod tests { use cosmwasm_std::testing::{mock_dependencies, mock_env, mock_info}; use cosmwasm_std::{coins, from_json, Addr, Attribute, Order, Uint128}; use cw_utils::PaymentError; + use cw_utils::PaymentError::NonPayable; use std::collections::BTreeMap; use std::fs::File; use std::io::Read; use std::path::Path; use std::{env, u128}; - use cw_utils::PaymentError::NonPayable; #[test] fn proper_initialization() { diff --git a/contracts/axone-dataverse/src/contract.rs b/contracts/axone-dataverse/src/contract.rs index ae4e3662..0ca585cd 100644 --- a/contracts/axone-dataverse/src/contract.rs +++ b/contracts/axone-dataverse/src/contract.rs @@ -19,9 +19,10 @@ const CONTRACT_VERSION: &str = env!("CARGO_PKG_VERSION"); pub fn instantiate( deps: DepsMut<'_>, env: Env, - _info: MessageInfo, + info: MessageInfo, msg: InstantiateMsg, ) -> Result { + nonpayable(&info)?; set_contract_version(deps.storage, CONTRACT_NAME, CONTRACT_VERSION)?; let creator = deps.api.addr_canonicalize(env.contract.address.as_str())?; @@ -149,7 +150,7 @@ mod tests { coins, from_json, Addr, Attribute, ContractResult, CosmosMsg, HexBinary, SubMsg, SystemError, SystemResult, Uint128, Uint64, WasmQuery, }; - use cw_utils::PaymentError; + use cw_utils::PaymentError::NonPayable; use std::collections::BTreeMap; #[test] @@ -213,6 +214,28 @@ mod tests { ) } + #[test] + fn instantiate_fail_with_funds() { + let mut deps = mock_dependencies(); + let env = mock_env(); + let info = mock_info("sender", &coins(10, "uaxone")); + + let msg = InstantiateMsg { + name: "my-dataverse".to_string(), + triplestore_config: TripleStoreConfig { + code_id: Uint64::from(17u64), + limits: TripleStoreLimitsInput::default(), + }, + }; + + let result = instantiate(deps.as_mut(), env, info, msg); + assert!(result.is_err()); + assert!(matches!( + result.unwrap_err(), + ContractError::Payment(NonPayable {}) + )); + } + #[test] fn proper_dataverse() { let mut deps = mock_dependencies(); @@ -255,7 +278,7 @@ mod tests { assert!(result.is_err()); assert!(matches!( result.unwrap_err(), - ContractError::Payment(PaymentError::NonPayable {}) + ContractError::Payment(NonPayable {}) )); }