33992542b1
* updated contracts to cosmwasm2.2 and fixed build issues * removed old coconut contract code + additional dkg fixes * replace deprecated to_binary and from_binary functions * mixnet contract tests compiling some are failing due to incorrect addresses * made other contract tests compile * fixed remaining tests * allow usage of manually dispatching contract replies * nym-api test fixes * removed old toolchain from contracts CI * linter fixes * regenerated contract schema * fixed easy_addr * further license fixes * post rebase fixes + update to 2.2.2 * change ci runner * minor CI adjustments * change wallet CI to use node 20 * more CI changes... * run cosmwasm-check against release contracts * test ci changes * wip...
76 lines
2.2 KiB
Rust
76 lines
2.2 KiB
Rust
// Copyright 2024 - Nym Technologies SA <contact@nymtech.net>
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
use cosmwasm_std::testing::MockApi;
|
|
use cosmwasm_std::{coin, Coin};
|
|
use cw_multi_test::IntoBech32;
|
|
use cw_utils::PaymentError;
|
|
use nym_ecash_contract_common::EcashContractError;
|
|
use sylvia::{cw_multi_test::App as MtApp, multitest::App};
|
|
|
|
use crate::contract::sv::mt::{CodeId, NymEcashContractProxy};
|
|
|
|
#[test]
|
|
fn invalid_deposit() {
|
|
let owner = "owner".into_bech32();
|
|
let denom = "unym";
|
|
|
|
let mtapp = MtApp::new(|router, _, storage| {
|
|
router
|
|
.bank
|
|
.init_balance(
|
|
storage,
|
|
&owner,
|
|
vec![
|
|
Coin::new(10000000u32, denom),
|
|
Coin::new(10000000u32, "some_denom"),
|
|
],
|
|
)
|
|
.unwrap()
|
|
});
|
|
let app = App::new(mtapp);
|
|
|
|
let code_id = CodeId::store_code(&app);
|
|
|
|
let contract = code_id
|
|
.instantiate(
|
|
MockApi::default().addr_make("holding_acount").to_string(),
|
|
MockApi::default().addr_make("multisig_addr").to_string(),
|
|
MockApi::default().addr_make("group_addr").to_string(),
|
|
coin(75000000, denom),
|
|
)
|
|
.call(&owner)
|
|
.unwrap();
|
|
|
|
let verification_key = "Verification key";
|
|
|
|
assert_eq!(
|
|
contract
|
|
.deposit_ticket_book_funds(verification_key.to_string(),)
|
|
.call(&owner)
|
|
.unwrap_err(),
|
|
EcashContractError::InvalidDeposit(PaymentError::NoFunds {})
|
|
);
|
|
|
|
let coin = Coin::new(1000000u32, denom.to_string());
|
|
let second_coin = Coin::new(1000000u32, "some_denom");
|
|
|
|
assert_eq!(
|
|
contract
|
|
.deposit_ticket_book_funds(verification_key.to_string(),)
|
|
.with_funds(&[coin, second_coin.clone()])
|
|
.call(&owner)
|
|
.unwrap_err(),
|
|
EcashContractError::InvalidDeposit(PaymentError::MultipleDenoms {})
|
|
);
|
|
|
|
assert_eq!(
|
|
contract
|
|
.deposit_ticket_book_funds(verification_key.to_string(),)
|
|
.with_funds(&[second_coin])
|
|
.call(&owner)
|
|
.unwrap_err(),
|
|
EcashContractError::InvalidDeposit(PaymentError::MissingDenom(denom.to_string()))
|
|
);
|
|
}
|