Skip to content

Commit

Permalink
Fix broken tests from denom validation
Browse files Browse the repository at this point in the history
  • Loading branch information
Jake Hartnell committed Sep 2, 2023
1 parent 41ef6ec commit 5cb878f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
15 changes: 13 additions & 2 deletions contracts/proposal/dao-proposal-single/src/testing/do_votes.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use cosmwasm_std::{coins, Addr, Uint128};
use cosmwasm_std::{coins, Addr, Coin, Uint128};
use cw20::Cw20Coin;

use cw_multi_test::{App, BankSudo, Executor};
use cw_multi_test::{App, BankSudo, Executor, SudoMsg};
use dao_interface::state::ProposalModule;
use dao_pre_propose_single as cppbps;

Expand Down Expand Up @@ -96,6 +96,17 @@ where
{
let mut app = App::default();

// Mint some ujuno so that it exists for native staking tests
// Otherwise denom validation will fail
app.sudo(SudoMsg::Bank(BankSudo::Mint {
to_address: "sodenomexists".to_string(),
amount: vec![Coin {
amount: Uint128::new(10),
denom: "ujuno".to_string(),
}],
}))
.unwrap();

let mut initial_balances = votes
.iter()
.map(|TestSingleChoiceVote { voter, weight, .. }| Cw20Coin {
Expand Down
12 changes: 6 additions & 6 deletions contracts/voting/dao-voting-native-staked/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1046,7 +1046,7 @@ fn test_active_threshold_percent_rounds_up() {

#[test]
fn test_active_threshold_none() {
let mut app = App::default();
let mut app = mock_app();
let staking_id = app.store_code(staking_contract());
let addr = instantiate_staking(
&mut app,
Expand Down Expand Up @@ -1140,7 +1140,7 @@ fn test_update_active_threshold() {
#[test]
#[should_panic(expected = "Active threshold percentage must be greater than 0 and less than 1")]
fn test_active_threshold_percentage_gt_100() {
let mut app = App::default();
let mut app = mock_app();
let staking_id = app.store_code(staking_contract());
instantiate_staking(
&mut app,
Expand All @@ -1158,7 +1158,7 @@ fn test_active_threshold_percentage_gt_100() {
#[test]
#[should_panic(expected = "Active threshold percentage must be greater than 0 and less than 1")]
fn test_active_threshold_percentage_lte_0() {
let mut app = App::default();
let mut app = mock_app();
let staking_id = app.store_code(staking_contract());
instantiate_staking(
&mut app,
Expand All @@ -1176,7 +1176,7 @@ fn test_active_threshold_percentage_lte_0() {
#[test]
#[should_panic(expected = "Absolute count threshold cannot be greater than the total token supply")]
fn test_active_threshold_absolute_count_invalid() {
let mut app = App::default();
let mut app = mock_app();
let staking_id = app.store_code(staking_contract());
instantiate_staking(
&mut app,
Expand All @@ -1185,15 +1185,15 @@ fn test_active_threshold_absolute_count_invalid() {
denom: DENOM.to_string(),
unstaking_duration: Some(Duration::Height(5)),
active_threshold: Some(ActiveThreshold::AbsoluteCount {
count: Uint128::new(301),
count: Uint128::new(3000000000000000000),
}),
},
);
}

#[test]
fn test_add_remove_hooks() {
let mut app = App::default();
let mut app = mock_app();
let staking_id = app.store_code(staking_contract());
let addr = instantiate_staking(
&mut app,
Expand Down

0 comments on commit 5cb878f

Please sign in to comment.