Skip to content

Commit

Permalink
[fix] #3185: Fix deny_new_validators() test and unignore it
Browse files Browse the repository at this point in the history
Signed-off-by: Daniil Polyakov <arjentix@gmail.com>
  • Loading branch information
Arjentix authored and appetrosyan committed Jun 5, 2023
1 parent 6357406 commit 56de128
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions client/tests/integration/permissions/runtime_validators.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,10 @@ use iroha_data_model::{
prelude::*,
transaction::WasmSmartContract,
};
use iroha_logger::info;
use test_network::*;

#[test]
// TODO: Maybe activate with a feature,
// which will be enabled in the build-script when `nightly` is enabled?
// Same for `mint_nft_for_every_use_every_1_sec()` test.
#[ignore = "Only on nightly"]
fn deny_new_validators() -> Result<()> {
let (_rt, _peer, test_client) = <PeerBuilder>::new().start_with_runtime();
wait_for_genesis_committed(&vec![test_client.clone()], 0);
Expand All @@ -23,10 +20,10 @@ fn deny_new_validators() -> Result<()> {
env!("OUT_DIR"),
"/wasm32-unknown-unknown/release/deny_new_validators_validator.wasm"
);
println!("Reading wasm from {filename}");
info!("Reading wasm from {filename}");

let wasm = fs::read(filename).wrap_err("Can't read smartcontract")?;
println!("wasm size is {} bytes", wasm.len());
info!("wasm size is {} bytes", wasm.len());

let validator = Validator::new(
"deny_new_validators%alice@wonderland".parse().unwrap(),
Expand All @@ -35,6 +32,7 @@ fn deny_new_validators() -> Result<()> {
raw_data: wasm.clone(),
},
);
info!("Submitting registration of the validator (should pass)");
test_client.submit_blocking(RegisterBox::new(validator))?;

// Trying to register the validator again
Expand All @@ -43,10 +41,13 @@ fn deny_new_validators() -> Result<()> {
validator::Type::Instruction,
WasmSmartContract { raw_data: wasm },
);
let error_mes = test_client
info!("Submitting registration of a new validator (should fail)");
let error = test_client
.submit_blocking(RegisterBox::new(validator_2))
.expect_err("Registration of a new validator should be denied")
.to_string();
assert!(error_mes.contains("New validators are not allowed"));
.expect_err("Registration of a new validator should be denied");
info!(?error);
assert!(error
.chain()
.any(|err| err.to_string().contains("New validators are not allowed")));
Ok(())
}

0 comments on commit 56de128

Please sign in to comment.