Skip to content

Commit

Permalink
test(bindings-perp): test ExecuteMsg::Claim with funds arg
Browse files Browse the repository at this point in the history
  • Loading branch information
Unique-Divine committed Jun 6, 2023
1 parent 0ff379c commit 17b8e51
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions contracts/bindings-perp/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -323,4 +323,37 @@ pub mod tests {
);
}
}

#[test]
fn test_execute_claim() {
// Prepare the test environment
let mut deps = testing::mock_dependencies();
let env = mock_env();
let contract_address = env.contract.address.clone();
let to_address = String::from("recipient_address");

// Set up a mock querier with contract balance
let balances: &[(&str, &[Coin])] = &[(
contract_address.as_str(),
&[Coin::new(100, "token")],
)];
let querier = testing::MockQuerier::new(balances);
deps.querier = querier.into();

// Define the ExecuteMsg::Claim variant
let msg = ExecuteMsg::Claim {
funds: Some(Coin::new(50, "token")),
claim_all: None,
to: to_address.clone(),
};

// Execute the claim
let sender = to_address.as_str(); // send to self
let info: MessageInfo = testing::mock_info(sender, &coins(2, "token"));
let res = execute(deps.as_mut(), env, info, msg);

// Assert the result
assert!(res.is_ok());
}

}

0 comments on commit 17b8e51

Please sign in to comment.