Skip to content

Commit

Permalink
test(law-stone): test if execute message fail when fund is given
Browse files Browse the repository at this point in the history
  • Loading branch information
bdeneux committed Jun 4, 2024
1 parent 816a0e5 commit 8f16457
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
21 changes: 19 additions & 2 deletions contracts/axone-law-stone/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -287,12 +287,13 @@ mod tests {
MockQuerierCustomHandlerResult, MockStorage,
};
use cosmwasm_std::{
from_json, to_json_binary, ContractInfoResponse, ContractResult, CosmosMsg, Event, Order,
OwnedDeps, SubMsgResponse, SubMsgResult, SystemError, SystemResult, WasmQuery,
coins, from_json, to_json_binary, ContractInfoResponse, ContractResult, CosmosMsg, Event,
Order, OwnedDeps, SubMsgResponse, SubMsgResult, SystemError, SystemResult, WasmQuery,
};
use cw_utils::ParseReplyError::SubMsgFailure;
use std::collections::VecDeque;
use std::marker::PhantomData;
use cw_utils::PaymentError;

fn custom_logic_handler_with_dependencies(
dependencies: Vec<String>,
Expand Down Expand Up @@ -853,6 +854,22 @@ mod tests {
}
}

#[test]
fn execute_fail_with_funds() {
let mut deps = mock_dependencies();
let env = mock_env();
let info = mock_info("sender", &coins(10, "uaxone"));

let result = execute(
deps.as_mut(),
env.clone(),
info.clone(),
ExecuteMsg::BreakStone,
);
assert!(result.is_err());
assert_eq!(result.unwrap_err(), ContractError::Payment(PaymentError::NonPayable {}));
}

#[test]
fn break_stone() {
let cases = vec![
Expand Down
5 changes: 4 additions & 1 deletion contracts/axone-law-stone/src/error.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use axone_logic_bindings::error::TermParseError;
use axone_wasm::error::CosmwasmUriError;
use cosmwasm_std::StdError;
use cw_utils::ParseReplyError;
use cw_utils::{ParseReplyError, PaymentError};
use thiserror::Error;

#[derive(Error, Debug, PartialEq)]
Expand All @@ -23,6 +23,9 @@ pub enum ContractError {

#[error("Only the contract admin can perform this operation.")]
Unauthorized,

#[error("{0}")]
Payment(#[from] PaymentError),
}

#[derive(Error, Debug, PartialEq, Eq)]
Expand Down

0 comments on commit 8f16457

Please sign in to comment.