diff --git a/contracts/axone-law-stone/src/contract.rs b/contracts/axone-law-stone/src/contract.rs index 08a9d6fe..ec807458 100644 --- a/contracts/axone-law-stone/src/contract.rs +++ b/contracts/axone-law-stone/src/contract.rs @@ -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, @@ -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![ diff --git a/contracts/axone-law-stone/src/error.rs b/contracts/axone-law-stone/src/error.rs index 0245d446..97743a37 100644 --- a/contracts/axone-law-stone/src/error.rs +++ b/contracts/axone-law-stone/src/error.rs @@ -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)] @@ -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)]