diff --git a/integration_tests/tests/features/claim_burn.feature b/integration_tests/tests/features/claim_burn.feature index 999faefb5..483810971 100644 --- a/integration_tests/tests/features/claim_burn.feature +++ b/integration_tests/tests/features/claim_burn.feature @@ -36,7 +36,7 @@ Feature: Claim Burn Then VN has scanned to height 30 When I convert commitment COMMITMENT into COMM_ADDRESS address - Then validator node VN has state at COMM_ADDRESS + Then validator node VN has state at COMM_ADDRESS within 20 seconds When I claim burn COMMITMENT with PROOF, RANGEPROOF and CLAIM_PUBKEY and spend it into account ACC via the wallet daemon WALLET_D # Then account ACC has one confidential bucket in it @@ -73,10 +73,8 @@ Feature: Claim Burn When miner MINER mines 13 new blocks Then VN has scanned to height 30 - # TODO: remove sleep - this is needed to allow validators enough time to propose the UTXO - When I wait 20 seconds When I convert commitment COMMITMENT into COMM_ADDRESS address - Then validator node VN has state at COMM_ADDRESS + Then validator node VN has state at COMM_ADDRESS within 20 seconds When I claim burn COMMITMENT with PROOF, RANGEPROOF and CLAIM_PUBKEY and spend it into account ACC via the wallet daemon WALLET_D When I claim burn COMMITMENT with PROOF, RANGEPROOF and CLAIM_PUBKEY and spend it into account ACC via the wallet daemon WALLET_D, it fails diff --git a/integration_tests/tests/features/transfer.feature b/integration_tests/tests/features/transfer.feature index 7e4f02752..9f9934b44 100644 --- a/integration_tests/tests/features/transfer.feature +++ b/integration_tests/tests/features/transfer.feature @@ -48,7 +48,7 @@ Feature: Account transfers Then indexer IDX has scanned to height 45 When I convert commitment COMMITMENT into COMM_ADDRESS address - Then validator node VN has state at COMM_ADDRESS + Then validator node VN has state at COMM_ADDRESS within 20 seconds When I claim burn COMMITMENT with PROOF, RANGEPROOF and CLAIM_PUBKEY and spend it into account ACCOUNT via the wallet daemon WALLET_D # Wait for the wallet daemon account monitor to update the sender account information @@ -129,7 +129,7 @@ Feature: Account transfers Then indexer IDX has scanned to height 45 When I convert commitment COMMITMENT into COMM_ADDRESS address - Then validator node VN has state at COMM_ADDRESS + Then validator node VN has state at COMM_ADDRESS within 20 seconds When I claim burn COMMITMENT with PROOF, RANGEPROOF and CLAIM_PUBKEY and spend it into account ACCOUNT_1 via the wallet daemon WALLET_D # Wait for the wallet daemon account monitor to update the sender account information diff --git a/integration_tests/tests/features/wallet_daemon.feature b/integration_tests/tests/features/wallet_daemon.feature index f6bb4919b..8a0eedd80 100644 --- a/integration_tests/tests/features/wallet_daemon.feature +++ b/integration_tests/tests/features/wallet_daemon.feature @@ -120,7 +120,7 @@ Feature: Wallet Daemon Then VN has scanned to height 30 When I convert commitment COMMITMENT into COMM_ADDRESS address - Then validator node VN has state at COMM_ADDRESS + Then validator node VN has state at COMM_ADDRESS within 20 seconds When I claim burn COMMITMENT with PROOF, RANGEPROOF and CLAIM_PUBKEY and spend it into account ACCOUNT_1 via the wallet daemon WALLET_D When I print the cucumber world diff --git a/integration_tests/tests/steps/validator_node.rs b/integration_tests/tests/steps/validator_node.rs index 331527467..1ab7370dd 100644 --- a/integration_tests/tests/steps/validator_node.rs +++ b/integration_tests/tests/steps/validator_node.rs @@ -320,8 +320,13 @@ async fn assert_template_is_registered_by_all(world: &mut TariWorld, template_na } } -#[then(expr = "validator node {word} has state at {word}")] -async fn then_validator_node_has_state_at(world: &mut TariWorld, vn_name: String, state_address_name: String) { +#[then(expr = "validator node {word} has state at {word} within {int} seconds")] +async fn then_validator_node_has_state_at( + world: &mut TariWorld, + vn_name: String, + state_address_name: String, + timeout_secs: u64, +) { let state_address = world .addresses .get(&state_address_name) @@ -330,14 +335,25 @@ async fn then_validator_node_has_state_at(world: &mut TariWorld, vn_name: String let mut client = vn.create_client(); let substate_address = SubstateAddress::from_substate_id(&SubstateId::from_str(state_address).expect("Invalid state address"), 0); - if let Err(e) = client - .get_state(GetStateRequest { - address: substate_address, - }) - .await - { - println!("Failed to get state: {}", e); - panic!("Failed to get state: {}", e); + let mut attempts = 0; + loop { + match client + .get_state(GetStateRequest { + address: substate_address, + }) + .await + { + Ok(_) => return, + Err(e) => { + attempts += 1; + if attempts == timeout_secs { + println!("Failed to get state: {}", e); + panic!("Failed to get state: {}", e); + } + }, + } + + tokio::time::sleep(Duration::from_secs(1)).await; } }