Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
Signed-off-by: Dmitry Murzin <[email protected]>
  • Loading branch information
dima74 committed Feb 18, 2025
1 parent 6b2c4af commit 844348c
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 14 deletions.
1 change: 1 addition & 0 deletions crates/iroha/tests/asset_propagation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ fn client_add_asset_quantity_to_existing_asset_should_increase_asset_amount_on_a
.with_genesis_instruction(SetParameter::new(Parameter::Block(
BlockParameter::MaxTransactions(nonzero!(1_u64)),
)))
.with_default_pipeline_time()
.start_blocking()?;
let mut peers = network.peers().iter();
let peer_a = peers.next().unwrap();
Expand Down
10 changes: 7 additions & 3 deletions crates/iroha/tests/extra_functional/connected_peers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,11 @@ async fn register_new_peer() -> Result<()> {
async fn connected_peers_with_f(faults: usize) -> Result<()> {
let n_peers = 3 * faults + 1;

let network = NetworkBuilder::new().with_peers(n_peers).start().await?;
let network = NetworkBuilder::new()
.with_peers(n_peers)
.with_default_pipeline_time()
.start()
.await?;

assert_peers_status(network.peers().iter(), 1, n_peers as u64 - 1).await;

Expand Down Expand Up @@ -86,7 +90,7 @@ async fn connected_peers_with_f(faults: usize) -> Result<()> {

let status = removed_peer.status().await?;
// Peer might have been disconnected before getting the block
assert_matches!(status.blocks, 1 | 2);
assert_matches!(status.blocks_non_empty, 1 | 2);
assert_eq!(status.peers, 0);

// Re-register the peer: committed with f = `faults` - 1 then `status.peers` increments
Expand Down Expand Up @@ -124,7 +128,7 @@ async fn assert_peers_status(
peer.peer_id()
);
assert_eq!(
status.blocks,
status.blocks_non_empty,
expected_blocks,
"expected blocks for {}",
peer.peer_id()
Expand Down
5 changes: 4 additions & 1 deletion crates/iroha/tests/extra_functional/normal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ use nonzero_ext::nonzero;

#[test]
fn transactions_should_be_applied() -> Result<()> {
let (network, _rt) = NetworkBuilder::new().with_peers(4).start_blocking()?;
let (network, _rt) = NetworkBuilder::new()
.with_peers(4)
.with_default_pipeline_time()
.start_blocking()?;
let iroha = network.client();
iroha.submit_blocking(SetParameter::new(Parameter::Block(
BlockParameter::MaxTransactions(nonzero!(1_u64)),
Expand Down
4 changes: 3 additions & 1 deletion crates/iroha/tests/queries/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ fn too_big_fetch_size_is_not_allowed() {

#[test]
fn find_blocks_reversed() -> eyre::Result<()> {
let (network, _rt) = NetworkBuilder::new().start_blocking()?;
let (network, _rt) = NetworkBuilder::new()
.with_default_pipeline_time()
.start_blocking()?;
let client = network.client();

client.submit_blocking(Register::domain(Domain::new("domain1".parse()?)))?;
Expand Down
5 changes: 4 additions & 1 deletion crates/iroha/tests/status_response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ async fn check(client: &client::Client, blocks: u64) -> Result<()> {

#[tokio::test]
async fn json_and_scale_statuses_equality() -> Result<()> {
let network = NetworkBuilder::new().start().await?;
let network = NetworkBuilder::new()
.with_default_pipeline_time()
.start()
.await?;
let client = network.client();

check(&client, 1).await?;
Expand Down
10 changes: 5 additions & 5 deletions crates/iroha/tests/triggers/by_call_trigger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,9 @@ fn execute_trigger_should_produce_event() -> Result<()> {

#[test]
fn infinite_recursion_should_produce_one_call_per_block() -> Result<()> {
let (network, _rt) = NetworkBuilder::new().start_blocking()?;
let (network, _rt) = NetworkBuilder::new()
.with_default_pipeline_time()
.start_blocking()?;
let test_client = network.client();

let asset_definition_id = "rose#wonderland".parse()?;
Expand Down Expand Up @@ -155,10 +157,8 @@ fn trigger_failure_should_not_cancel_other_triggers_execution() -> Result<()> {

// Checking results
let new_asset_value = get_asset_value(&test_client, asset_id);
assert_eq!(
new_asset_value,
prev_asset_value.checked_add(Numeric::ONE).unwrap()
);
// There will be empty blocks, so we can't check for ==
assert!(new_asset_value >= prev_asset_value.checked_add(Numeric::ONE).unwrap());
Ok(())
}

Expand Down
7 changes: 4 additions & 3 deletions crates/iroha/tests/triggers/time_trigger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ fn curr_time() -> Duration {
}

#[test]
fn mint_asset_after_3_sec() -> Result<()> {
const GAP: Duration = Duration::from_secs(3);
fn mint_asset_after_5_sec() -> Result<()> {
const GAP: Duration = Duration::from_secs(5);

let (network, _rt) = NetworkBuilder::new()
.with_default_pipeline_time()
Expand Down Expand Up @@ -121,7 +121,8 @@ fn pre_commit_trigger_should_be_executed() -> Result<()> {

for _ in event_listener.take(CHECKS_COUNT) {
let new_value = get_asset_value(&test_client, asset_id.clone());
assert_eq!(new_value, prev_value.checked_add(Numeric::ONE).unwrap());
// There will be empty blocks, so we can't check for ==
assert!(new_value >= prev_value.checked_add(Numeric::ONE).unwrap());
prev_value = new_value;

// ISI just to create a new block
Expand Down

0 comments on commit 844348c

Please sign in to comment.