Skip to content

Commit

Permalink
tests/e2e: replace PoS test epoch waits with epoch-sleeps
Browse files Browse the repository at this point in the history
PoS hammered the node as fast as possible with epoch queries in its
tests to wait for a specified epoch. Instead, epoch-sleep repeatedly
until the target epoch has been reached.

This could be improved further by adding an --until parameter to
epoch-sleep.
  • Loading branch information
juped authored and tzemanovic committed Jul 11, 2023
1 parent ab08395 commit 4de68f7
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions tests/src/e2e/ledger_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2151,7 +2151,7 @@ fn pos_bonds() -> Result<()> {
delegation_withdrawable_epoch
);
}
let epoch = get_epoch(&test, &validator_one_rpc)?;
let epoch = epoch_sleep(&test, &validator_one_rpc, 40)?;
if epoch >= delegation_withdrawable_epoch {
break;
}
Expand Down Expand Up @@ -2358,7 +2358,7 @@ fn pos_rewards() -> Result<()> {
if Instant::now().duration_since(start) > loop_timeout {
panic!("Timed out waiting for epoch: {}", wait_epoch);
}
let epoch = get_epoch(&test, &validator_zero_rpc)?;
let epoch = epoch_sleep(&test, &validator_zero_rpc, 40)?;
if dbg!(epoch) >= wait_epoch {
break;
}
Expand Down Expand Up @@ -2441,7 +2441,7 @@ fn test_bond_queries() -> Result<()> {
if Instant::now().duration_since(start) > loop_timeout {
panic!("Timed out waiting for epoch: {}", 1);
}
let epoch = get_epoch(&test, &validator_one_rpc)?;
let epoch = epoch_sleep(&test, &validator_one_rpc, 40)?;
if epoch >= Epoch(4) {
break;
}
Expand Down Expand Up @@ -2500,7 +2500,7 @@ fn test_bond_queries() -> Result<()> {

// 6. Wait for withdraw_epoch
loop {
let epoch = epoch_sleep(&test, &validator_one_rpc, 120)?;
let epoch = epoch_sleep(&test, &validator_one_rpc, 40)?;
if epoch >= withdraw_epoch {
break;
}
Expand Down Expand Up @@ -2740,7 +2740,7 @@ fn pos_init_validator() -> Result<()> {
if Instant::now().duration_since(start) > loop_timeout {
panic!("Timed out waiting for epoch: {}", earliest_update_epoch);
}
let epoch = get_epoch(&test, &non_validator_rpc)?;
let epoch = epoch_sleep(&test, &non_validator_rpc, 40)?;
if epoch >= earliest_update_epoch {
break;
}
Expand Down

0 comments on commit 4de68f7

Please sign in to comment.