Skip to content

Commit

Permalink
fix e2e tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Gianmarco Fraccaroli committed Sep 26, 2022
1 parent 5b34bff commit e4ab8c9
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 3 deletions.
15 changes: 12 additions & 3 deletions tests/src/e2e/ledger_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ use namada_apps::config::genesis::genesis_config::{
use serde_json::json;
use setup::constants::*;

use super::setup::get_all_wasms_hashes;
use crate::e2e::helpers::{
find_address, find_voting_power, get_actor_rpc, get_epoch,
};
Expand Down Expand Up @@ -991,16 +992,24 @@ fn ledger_many_txs_in_a_block() -> Result<()> {
/// 13. Check governance address funds are 0
#[test]
fn proposal_submission() -> Result<()> {
let working_dir = setup::working_dir();

let test = setup::network(
|genesis| {
let parameters = ParametersConfig {
min_num_of_blocks: 1,
min_duration: 1,
max_expected_time_per_block: 1,
vp_whitelist: genesis.parameters.vp_whitelist,
vp_whitelist: Some(get_all_wasms_hashes(
&working_dir,
Some("vp_"),
)),
// Enable tx whitelist to test the execution of a
// non-whitelisted tx by governance
tx_whitelist: Some(vec![String::from("test")]),
tx_whitelist: Some(get_all_wasms_hashes(
&working_dir,
Some("tx_"),
)),
};

GenesisConfig {
Expand Down Expand Up @@ -1450,7 +1459,7 @@ fn proposal_offline() -> Result<()> {
let submit_proposal_vote = vec![
"vote-proposal",
"--data-path",
test.test_dir.path().to_str().unwrap(),
valid_proposal_json_path.to_str().unwrap(),,
"--vote",
"yay",
"--signer",
Expand Down
27 changes: 27 additions & 0 deletions tests/src/e2e/setup.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use std::collections::HashMap;
use std::ffi::OsStr;
use std::fmt::Display;
use std::fs::{File, OpenOptions};
Expand All @@ -23,6 +24,7 @@ use namada_apps::client::utils;
use namada_apps::config::genesis::genesis_config::{self, GenesisConfig};
use namada_apps::{config, wallet};
use rand::Rng;
use serde_json;
use tempfile::{tempdir, TempDir};

use crate::e2e::helpers::generate_bin_command;
Expand Down Expand Up @@ -860,3 +862,28 @@ pub fn copy_wasm_to_chain_dir<'a>(
}
}
}

pub fn get_all_wasms_hashes(
working_dir: &Path,
filter: Option<&str>,
) -> Vec<String> {
let checksums_path = working_dir.join("wasm/checksums.json");
let checksums_content = fs::read_to_string(checksums_path).unwrap();
let checksums: HashMap<String, String> =
serde_json::from_str(&checksums_content).unwrap();
let filter_prefix = filter.unwrap_or_default();
checksums
.values()
.filter_map(|wasm| {
if wasm.contains(&filter_prefix) {
Some(
wasm.split('.').collect::<Vec<&str>>()[1]
.to_owned()
.to_uppercase(),
)
} else {
None
}
})
.collect()
}

0 comments on commit e4ab8c9

Please sign in to comment.