Skip to content

Commit

Permalink
feat(cognitarium): do not allow funds on instantiate
Browse files Browse the repository at this point in the history
  • Loading branch information
bdeneux committed Jun 4, 2024
1 parent 9ea2c50 commit 035e8a6
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions contracts/axone-cognitarium/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ pub fn instantiate(
info: MessageInfo,
msg: InstantiateMsg,
) -> Result<Response, ContractError> {
nonpayable(&info)?;
set_contract_version(deps.storage, CONTRACT_NAME, CONTRACT_VERSION)?;

STORE.save(deps.storage, &Store::new(info.sender, msg.limits.into()))?;
Expand Down Expand Up @@ -450,6 +451,7 @@ mod tests {
use std::io::Read;
use std::path::Path;
use std::{env, u128};
use cw_utils::PaymentError::NonPayable;

#[test]
fn proper_initialization() {
Expand Down Expand Up @@ -501,6 +503,19 @@ 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::default();

let result = instantiate(deps.as_mut(), env, info, msg);
assert!(result.is_err());
assert_eq!(result.unwrap_err(), ContractError::Payment(NonPayable {}));
}

#[test]
fn execute_fail_with_funds() {
let mut deps = mock_dependencies();
Expand Down

0 comments on commit 035e8a6

Please sign in to comment.