Skip to content

Commit

Permalink
Fix test_protocol_upgrade_under_congestion
Browse files Browse the repository at this point in the history
This test kept failing on the check:
```
assert!(congestion_info.receipt_bytes() > next_congestion_info.receipt_bytes());
```

It seems flaky, sometimes it passes and sometimes it doesn't.
I think it's related to the recent changes (tx and receipt size limits).

Let's change the way in which we test that the chain is doing progress
to measuring burned gas on the congested shard, this is more reliable
and makes the test pass.
  • Loading branch information
jancionear committed Jun 5, 2024
1 parent e781b8a commit ea35ef9
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions integration-tests/src/tests/client/features/congestion_control.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use assert_matches::assert_matches;
use near_chain::Provenance;
use near_chain_configs::Genesis;
use near_client::test_utils::TestEnv;
use near_client::ProcessTxResponse;
Expand Down Expand Up @@ -212,11 +213,19 @@ fn test_protocol_upgrade_under_congestion() {
);

// Also check that the congested shard is still making progress.
env.produce_block(0, tip.height + 1);
let next_congestion_info = head_congestion_info(&mut env, contract_shard_id);
let block = env.clients[0].produce_block(tip.height + 1).unwrap().unwrap();
assert_eq!(
block.header().chunk_mask()[contract_shard_id as usize],
true,
"chunk isn't missing"
);
let gas_used = block.chunks().get(contract_shard_id as usize).unwrap().prev_gas_used();
tracing::debug!(target: "test", "prev_gas_used: {}", gas_used);

// The chunk should process at least 500TGas worth of receipts
assert!(gas_used > 500_000_000_000_000);

assert!(congestion_info.delayed_receipts_gas() > next_congestion_info.delayed_receipts_gas());
assert!(congestion_info.receipt_bytes() > next_congestion_info.receipt_bytes());
env.process_block(0, block, Provenance::PRODUCED);
}

/// Check we are still in the old version and no congestion info is shared.
Expand Down

0 comments on commit ea35ef9

Please sign in to comment.