Skip to content

Commit

Permalink
test(dataverse): 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 116ff78 commit de64ea7
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
22 changes: 18 additions & 4 deletions contracts/axone-dataverse/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,9 @@ mod tests {
WhereCondition, IRI,
};
use cosmwasm_std::testing::{mock_dependencies, mock_env, mock_info};
use cosmwasm_std::{
from_json, Addr, Attribute, ContractResult, CosmosMsg, HexBinary, SubMsg, SystemError,
SystemResult, Uint128, Uint64, WasmQuery,
};
use cosmwasm_std::{from_json, Addr, Attribute, ContractResult, CosmosMsg, HexBinary, SubMsg, SystemError, SystemResult, Uint128, Uint64, WasmQuery, coins};
use std::collections::BTreeMap;
use cw_utils::PaymentError;

#[test]
fn proper_instantiate() {
Expand Down Expand Up @@ -237,6 +235,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 msg = ExecuteMsg::SubmitClaims {
metadata: Binary::from("data".as_bytes()),
format: Some(RdfFormat::NQuads),
};

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

#[test]
fn proper_submit_claims() {
let mut deps = mock_dependencies();
Expand Down
4 changes: 4 additions & 0 deletions contracts/axone-dataverse/src/error.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use crate::credential::error::{InvalidCredentialError, VerificationError};
use axone_rdf::serde::NQuadsReadError;
use cosmwasm_std::{Instantiate2AddressError, StdError};
use cw_utils::PaymentError;
use thiserror::Error;

#[derive(Error, Debug)]
Expand Down Expand Up @@ -28,4 +29,7 @@ pub enum ContractError {

#[error("An unexpected error occurred: {0}")]
Unexpected(String),

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

0 comments on commit de64ea7

Please sign in to comment.