Skip to content

Commit

Permalink
refactor(intergation): use new genesis wait async
Browse files Browse the repository at this point in the history
Signed-off-by: Shanin Roman <[email protected]>
  • Loading branch information
Erigara committed Sep 5, 2024
1 parent bc8b9bb commit 67c62b6
Show file tree
Hide file tree
Showing 30 changed files with 179 additions and 179 deletions.
36 changes: 18 additions & 18 deletions client/tests/integration/asset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ use test_samples::{gen_account_in, ALICE_ID, BOB_ID};
// This test is also covered at the UI level in the iroha_cli tests
// in test_register_asset_definitions.py
fn client_register_asset_should_add_asset_once_but_not_twice() -> Result<()> {
let (_rt, _peer, test_client) = <PeerBuilder>::new().with_port(10_620).start_with_runtime();
wait_for_genesis_committed(&[test_client.clone()], 0);
let (rt, _peer, test_client) = <PeerBuilder>::new().with_port(10_620).start_with_runtime();
rt.block_on(wait_for_genesis_committed_async(&[test_client.clone()]));

// Given
let account_id = ALICE_ID.clone();
Expand Down Expand Up @@ -59,8 +59,8 @@ fn client_register_asset_should_add_asset_once_but_not_twice() -> Result<()> {

#[test]
fn unregister_asset_should_remove_asset_from_account() -> Result<()> {
let (_rt, _peer, test_client) = <PeerBuilder>::new().with_port(10_555).start_with_runtime();
wait_for_genesis_committed(&[test_client.clone()], 0);
let (rt, _peer, test_client) = <PeerBuilder>::new().with_port(10_555).start_with_runtime();
rt.block_on(wait_for_genesis_committed_async(&[test_client.clone()]));

// Given
let account_id = ALICE_ID.clone();
Expand Down Expand Up @@ -107,8 +107,8 @@ fn unregister_asset_should_remove_asset_from_account() -> Result<()> {
// This test is also covered at the UI level in the iroha_cli tests
// in test_mint_assets.py
fn client_add_asset_quantity_to_existing_asset_should_increase_asset_amount() -> Result<()> {
let (_rt, _peer, test_client) = <PeerBuilder>::new().with_port(10_000).start_with_runtime();
wait_for_genesis_committed(&[test_client.clone()], 0);
let (rt, _peer, test_client) = <PeerBuilder>::new().with_port(10_000).start_with_runtime();
rt.block_on(wait_for_genesis_committed_async(&[test_client.clone()]));

// Given
let account_id = ALICE_ID.clone();
Expand Down Expand Up @@ -141,8 +141,8 @@ fn client_add_asset_quantity_to_existing_asset_should_increase_asset_amount() ->

#[test]
fn client_add_big_asset_quantity_to_existing_asset_should_increase_asset_amount() -> Result<()> {
let (_rt, _peer, test_client) = <PeerBuilder>::new().with_port(10_510).start_with_runtime();
wait_for_genesis_committed(&[test_client.clone()], 0);
let (rt, _peer, test_client) = <PeerBuilder>::new().with_port(10_510).start_with_runtime();
rt.block_on(wait_for_genesis_committed_async(&[test_client.clone()]));

// Given
let account_id = ALICE_ID.clone();
Expand Down Expand Up @@ -175,8 +175,8 @@ fn client_add_big_asset_quantity_to_existing_asset_should_increase_asset_amount(

#[test]
fn client_add_asset_with_decimal_should_increase_asset_amount() -> Result<()> {
let (_rt, _peer, test_client) = <PeerBuilder>::new().with_port(10_515).start_with_runtime();
wait_for_genesis_committed(&[test_client.clone()], 0);
let (rt, _peer, test_client) = <PeerBuilder>::new().with_port(10_515).start_with_runtime();
rt.block_on(wait_for_genesis_committed_async(&[test_client.clone()]));

// Given
let account_id = ALICE_ID.clone();
Expand Down Expand Up @@ -235,8 +235,8 @@ fn client_add_asset_with_decimal_should_increase_asset_amount() -> Result<()> {
// This test is also covered at the UI level in the iroha_cli tests
// in test_register_asset_definitions.py
fn client_add_asset_with_name_length_more_than_limit_should_not_commit_transaction() -> Result<()> {
let (_rt, _peer, test_client) = <PeerBuilder>::new().with_port(10_520).start_with_runtime();
wait_for_genesis_committed(&[test_client.clone()], 0);
let (rt, _peer, test_client) = <PeerBuilder>::new().with_port(10_520).start_with_runtime();
rt.block_on(wait_for_genesis_committed_async(&[test_client.clone()]));
let pipeline_time = Config::pipeline_time();

// Given
Expand Down Expand Up @@ -281,8 +281,8 @@ fn client_add_asset_with_name_length_more_than_limit_should_not_commit_transacti
#[allow(clippy::expect_fun_call)]
#[test]
fn find_rate_and_make_exchange_isi_should_succeed() {
let (_rt, _peer, test_client) = <PeerBuilder>::new().with_port(10_675).start_with_runtime();
wait_for_genesis_committed(&[test_client.clone()], 0);
let (rt, _peer, test_client) = <PeerBuilder>::new().with_port(10_675).start_with_runtime();
rt.block_on(wait_for_genesis_committed_async(&[test_client.clone()]));

let (dex_id, _dex_keypair) = gen_account_in("exchange");
let (seller_id, seller_keypair) = gen_account_in("company");
Expand Down Expand Up @@ -375,8 +375,8 @@ fn find_rate_and_make_exchange_isi_should_succeed() {

#[test]
fn transfer_asset_definition() {
let (_rt, _peer, test_client) = <PeerBuilder>::new().with_port(11_060).start_with_runtime();
wait_for_genesis_committed(&[test_client.clone()], 0);
let (rt, _peer, test_client) = <PeerBuilder>::new().with_port(11_060).start_with_runtime();
rt.block_on(wait_for_genesis_committed_async(&[test_client.clone()]));

let alice_id = ALICE_ID.clone();
let bob_id = BOB_ID.clone();
Expand Down Expand Up @@ -413,8 +413,8 @@ fn transfer_asset_definition() {

#[test]
fn fail_if_dont_satisfy_spec() {
let (_rt, _peer, test_client) = <PeerBuilder>::new().with_port(11_125).start_with_runtime();
wait_for_genesis_committed(&[test_client.clone()], 0);
let (rt, _peer, test_client) = <PeerBuilder>::new().with_port(11_125).start_with_runtime();
rt.block_on(wait_for_genesis_committed_async(&[test_client.clone()]));

let alice_id = ALICE_ID.clone();
let bob_id = BOB_ID.clone();
Expand Down
4 changes: 2 additions & 2 deletions client/tests/integration/asset_propagation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ use test_samples::gen_account_in;
fn client_add_asset_quantity_to_existing_asset_should_increase_asset_amount_on_another_peer(
) -> Result<()> {
// Given
let (_rt, network, client) = Network::start_test_with_runtime(4, Some(10_450));
wait_for_genesis_committed(&network.clients(), 0);
let (rt, network, client) = Network::start_test_with_runtime(4, Some(10_450));
rt.block_on(wait_for_genesis_committed_async(&network.clients()));
let pipeline_time = Config::pipeline_time();

client.submit_blocking(SetParameter::new(Parameter::Block(
Expand Down
8 changes: 4 additions & 4 deletions client/tests/integration/events/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,8 @@ fn transaction_execution_should_produce_events(
executable: impl Into<Executable>,
port: u16,
) -> Result<()> {
let (_rt, _peer, client) = <PeerBuilder>::new().with_port(port).start_with_runtime();
wait_for_genesis_committed(&[client.clone()], 0);
let (rt, _peer, client) = <PeerBuilder>::new().with_port(port).start_with_runtime();
rt.block_on(wait_for_genesis_committed_async(&[client.clone()]));

// spawn event reporter
let listener = client.clone();
Expand Down Expand Up @@ -178,8 +178,8 @@ fn transaction_execution_should_produce_events(
#[test]
#[allow(clippy::too_many_lines)]
fn produce_multiple_events() -> Result<()> {
let (_rt, _peer, client) = <PeerBuilder>::new().with_port(10_645).start_with_runtime();
wait_for_genesis_committed(&[client.clone()], 0);
let (rt, _peer, client) = <PeerBuilder>::new().with_port(10_645).start_with_runtime();
rt.block_on(wait_for_genesis_committed_async(&[client.clone()]));

// Spawn event reporter
let listener = client.clone();
Expand Down
8 changes: 4 additions & 4 deletions client/tests/integration/events/notification.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ use test_samples::ALICE_ID;

#[test]
fn trigger_completion_success_should_produce_event() -> Result<()> {
let (_rt, _peer, test_client) = <PeerBuilder>::new().with_port(11_050).start_with_runtime();
wait_for_genesis_committed(&vec![test_client.clone()], 0);
let (rt, _peer, test_client) = <PeerBuilder>::new().with_port(11_050).start_with_runtime();
rt.block_on(wait_for_genesis_committed_async(&vec![test_client.clone()]));

let asset_definition_id = "rose#wonderland".parse()?;
let account_id = ALICE_ID.clone();
Expand Down Expand Up @@ -53,8 +53,8 @@ fn trigger_completion_success_should_produce_event() -> Result<()> {

#[test]
fn trigger_completion_failure_should_produce_event() -> Result<()> {
let (_rt, _peer, test_client) = <PeerBuilder>::new().with_port(11_055).start_with_runtime();
wait_for_genesis_committed(&vec![test_client.clone()], 0);
let (rt, _peer, test_client) = <PeerBuilder>::new().with_port(11_055).start_with_runtime();
rt.block_on(wait_for_genesis_committed_async(&vec![test_client.clone()]));

let account_id = ALICE_ID.clone();
let trigger_id = TriggerId::from_str("fail_box")?;
Expand Down
8 changes: 4 additions & 4 deletions client/tests/integration/events/pipeline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ fn test_with_instruction_and_status_and_port(
should_be: &TransactionStatus,
port: u16,
) -> Result<()> {
let (_rt, network, client) =
let (rt, network, client) =
Network::start_test_with_runtime(PEER_COUNT.try_into().unwrap(), Some(port));
let clients = network.clients();
wait_for_genesis_committed(&clients, 0);
rt.block_on(wait_for_genesis_committed_async(&clients));
let pipeline_time = Config::pipeline_time();

client.submit_blocking(SetParameter::new(Parameter::Block(
Expand Down Expand Up @@ -106,8 +106,8 @@ impl Checker {

#[test]
fn applied_block_must_be_available_in_kura() {
let (_rt, peer, client) = <PeerBuilder>::new().with_port(11_040).start_with_runtime();
wait_for_genesis_committed(&[client.clone()], 0);
let (rt, peer, client) = <PeerBuilder>::new().with_port(11_040).start_with_runtime();
rt.block_on(wait_for_genesis_committed_async(&[client.clone()]));

let event_filter = BlockEventFilter::default().for_status(BlockStatus::Applied);
let mut event_iter = client
Expand Down
4 changes: 2 additions & 2 deletions client/tests/integration/multisig.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ use test_samples::{gen_account_in, ALICE_ID};

#[test]
fn mutlisig() -> Result<()> {
let (_rt, _peer, test_client) = <PeerBuilder>::new().with_port(11_400).start_with_runtime();
wait_for_genesis_committed(&vec![test_client.clone()], 0);
let (rt, _peer, test_client) = <PeerBuilder>::new().with_port(11_400).start_with_runtime();
rt.block_on(wait_for_genesis_committed_async(&vec![test_client.clone()]));

test_client.submit_all_blocking([
SetParameter::new(Parameter::SmartContract(SmartContractParameter::Fuel(
Expand Down
12 changes: 6 additions & 6 deletions client/tests/integration/non_mintable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ use test_samples::ALICE_ID;

#[test]
fn non_mintable_asset_can_be_minted_once_but_not_twice() -> Result<()> {
let (_rt, _peer, test_client) = <PeerBuilder>::new().with_port(10_625).start_with_runtime();
wait_for_genesis_committed(&[test_client.clone()], 0);
let (rt, _peer, test_client) = <PeerBuilder>::new().with_port(10_625).start_with_runtime();
rt.block_on(wait_for_genesis_committed_async(&[test_client.clone()]));

// Given
let account_id = ALICE_ID.clone();
Expand Down Expand Up @@ -64,8 +64,8 @@ fn non_mintable_asset_can_be_minted_once_but_not_twice() -> Result<()> {

#[test]
fn non_mintable_asset_cannot_be_minted_if_registered_with_non_zero_value() -> Result<()> {
let (_rt, _peer, test_client) = <PeerBuilder>::new().with_port(10_610).start_with_runtime();
wait_for_genesis_committed(&[test_client.clone()], 0);
let (rt, _peer, test_client) = <PeerBuilder>::new().with_port(10_610).start_with_runtime();
rt.block_on(wait_for_genesis_committed_async(&[test_client.clone()]));

// Given
let account_id = ALICE_ID.clone();
Expand Down Expand Up @@ -103,8 +103,8 @@ fn non_mintable_asset_cannot_be_minted_if_registered_with_non_zero_value() -> Re

#[test]
fn non_mintable_asset_can_be_minted_if_registered_with_zero_value() -> Result<()> {
let (_rt, _peer, test_client) = <PeerBuilder>::new().with_port(10_630).start_with_runtime();
wait_for_genesis_committed(&[test_client.clone()], 0);
let (rt, _peer, test_client) = <PeerBuilder>::new().with_port(10_630).start_with_runtime();
rt.block_on(wait_for_genesis_committed_async(&[test_client.clone()]));

// Given
let account_id = ALICE_ID.clone();
Expand Down
12 changes: 6 additions & 6 deletions client/tests/integration/pagination.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ use test_network::*;

#[test]
fn limits_should_work() -> Result<()> {
let (_rt, _peer, client) = <PeerBuilder>::new().with_port(10_690).start_with_runtime();
wait_for_genesis_committed(&vec![client.clone()], 0);
let (rt, _peer, client) = <PeerBuilder>::new().with_port(10_690).start_with_runtime();
rt.block_on(wait_for_genesis_committed_async(&vec![client.clone()]));

register_assets(&client)?;

Expand All @@ -26,8 +26,8 @@ fn limits_should_work() -> Result<()> {

#[test]
fn reported_length_should_be_accurate() -> Result<()> {
let (_rt, _peer, client) = <PeerBuilder>::new().with_port(11_170).start_with_runtime();
wait_for_genesis_committed(&vec![client.clone()], 0);
let (rt, _peer, client) = <PeerBuilder>::new().with_port(11_170).start_with_runtime();
rt.block_on(wait_for_genesis_committed_async(&vec![client.clone()]));

register_assets(&client)?;

Expand Down Expand Up @@ -60,8 +60,8 @@ fn fetch_size_should_work() -> Result<()> {
QueryWithFilter, QueryWithParams,
};

let (_rt, _peer, client) = <PeerBuilder>::new().with_port(11_120).start_with_runtime();
wait_for_genesis_committed(&vec![client.clone()], 0);
let (rt, _peer, client) = <PeerBuilder>::new().with_port(11_120).start_with_runtime();
rt.block_on(wait_for_genesis_committed_async(&vec![client.clone()]));

register_assets(&client)?;

Expand Down
24 changes: 12 additions & 12 deletions client/tests/integration/permissions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ fn get_assets(iroha: &Client, id: &AccountId) -> Vec<Asset> {
fn permissions_disallow_asset_transfer() {
let chain_id = ChainId::from("00000000-0000-0000-0000-000000000000");

let (_rt, _peer, iroha) = <PeerBuilder>::new().with_port(10_730).start_with_runtime();
wait_for_genesis_committed(&[iroha.clone()], 0);
let (rt, _peer, iroha) = <PeerBuilder>::new().with_port(10_730).start_with_runtime();
rt.block_on(wait_for_genesis_committed_async(&[iroha.clone()]));

// Given
let alice_id = ALICE_ID.clone();
Expand Down Expand Up @@ -177,8 +177,8 @@ fn permissions_disallow_asset_burn() {
#[test]
#[ignore = "ignore, more in #2851"]
fn account_can_query_only_its_own_domain() -> Result<()> {
let (_rt, _peer, client) = <PeerBuilder>::new().with_port(10_740).start_with_runtime();
wait_for_genesis_committed(&[client.clone()], 0);
let (rt, _peer, client) = <PeerBuilder>::new().with_port(10_740).start_with_runtime();
rt.block_on(wait_for_genesis_committed_async(&[client.clone()]));

// Given
let domain_id: DomainId = "wonderland".parse()?;
Expand Down Expand Up @@ -299,8 +299,8 @@ fn permissions_differ_not_only_by_names() {
fn stored_vs_granted_permission_payload() -> Result<()> {
let chain_id = ChainId::from("00000000-0000-0000-0000-000000000000");

let (_rt, _peer, iroha) = <PeerBuilder>::new().with_port(10_730).start_with_runtime();
wait_for_genesis_committed(&[iroha.clone()], 0);
let (rt, _peer, iroha) = <PeerBuilder>::new().with_port(10_730).start_with_runtime();
rt.block_on(wait_for_genesis_committed_async(&[iroha.clone()]));

// Given
let alice_id = ALICE_ID.clone();
Expand Down Expand Up @@ -351,8 +351,8 @@ fn stored_vs_granted_permission_payload() -> Result<()> {
#[test]
#[allow(deprecated)]
fn permissions_are_unified() {
let (_rt, _peer, iroha) = <PeerBuilder>::new().with_port(11_230).start_with_runtime();
wait_for_genesis_committed(&[iroha.clone()], 0);
let (rt, _peer, iroha) = <PeerBuilder>::new().with_port(11_230).start_with_runtime();
rt.block_on(wait_for_genesis_committed_async(&[iroha.clone()]));

// Given
let alice_id = ALICE_ID.clone();
Expand All @@ -378,8 +378,8 @@ fn permissions_are_unified() {

#[test]
fn associated_permissions_removed_on_unregister() {
let (_rt, _peer, iroha) = <PeerBuilder>::new().with_port(11_240).start_with_runtime();
wait_for_genesis_committed(&[iroha.clone()], 0);
let (rt, _peer, iroha) = <PeerBuilder>::new().with_port(11_240).start_with_runtime();
rt.block_on(wait_for_genesis_committed_async(&[iroha.clone()]));

let bob_id = BOB_ID.clone();
let kingdom_id: DomainId = "kingdom".parse().expect("Valid");
Expand Down Expand Up @@ -430,8 +430,8 @@ fn associated_permissions_removed_on_unregister() {

#[test]
fn associated_permissions_removed_from_role_on_unregister() {
let (_rt, _peer, iroha) = <PeerBuilder>::new().with_port(11_255).start_with_runtime();
wait_for_genesis_committed(&[iroha.clone()], 0);
let (rt, _peer, iroha) = <PeerBuilder>::new().with_port(11_255).start_with_runtime();
rt.block_on(wait_for_genesis_committed_async(&[iroha.clone()]));

let role_id: RoleId = "role".parse().expect("Valid");
let kingdom_id: DomainId = "kingdom".parse().expect("Valid");
Expand Down
4 changes: 2 additions & 2 deletions client/tests/integration/queries/account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ use test_samples::{gen_account_in, ALICE_ID};

#[test]
fn find_accounts_with_asset() -> Result<()> {
let (_rt, _peer, test_client) = <PeerBuilder>::new().with_port(10_760).start_with_runtime();
wait_for_genesis_committed(&[test_client.clone()], 0);
let (rt, _peer, test_client) = <PeerBuilder>::new().with_port(10_760).start_with_runtime();
rt.block_on(wait_for_genesis_committed_async(&[test_client.clone()]));

// Registering new asset definition
let definition_id = AssetDefinitionId::from_str("test_coin#wonderland").expect("Valid");
Expand Down
4 changes: 2 additions & 2 deletions client/tests/integration/queries/asset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ use test_samples::{gen_account_in, ALICE_ID};
#[test]
#[allow(clippy::too_many_lines)]
fn find_asset_total_quantity() -> Result<()> {
let (_rt, _peer, test_client) = <PeerBuilder>::new().with_port(10_765).start_with_runtime();
wait_for_genesis_committed(&[test_client.clone()], 0);
let (rt, _peer, test_client) = <PeerBuilder>::new().with_port(10_765).start_with_runtime();
rt.block_on(wait_for_genesis_committed_async(&[test_client.clone()]));

// Register new domain
let domain_id: DomainId = "looking_glass".parse()?;
Expand Down
4 changes: 2 additions & 2 deletions client/tests/integration/queries/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ mod smart_contract;

#[test]
fn too_big_fetch_size_is_not_allowed() {
let (_rt, _peer, client) = <PeerBuilder>::new().with_port(11_130).start_with_runtime();
wait_for_genesis_committed(&[client.clone()], 0);
let (rt, _peer, client) = <PeerBuilder>::new().with_port(11_130).start_with_runtime();
rt.block_on(wait_for_genesis_committed_async(&[client.clone()]));

let err = client
.query(client::asset::all())
Expand Down
Loading

0 comments on commit 67c62b6

Please sign in to comment.