Skip to content

Commit

Permalink
chore: drop run_until_completion from canister tests (#1899)
Browse files Browse the repository at this point in the history
This PR removes `run_until_completion` from canister StateMachine tests
since it is not required in the existing tests (this draft
[PR](#1900) asserting that
`run_until_completion` is a no-op is an empirical evidence of this
claim). The motivation for removing `run_until_completion` from canister
StateMachine tests is that this function is not supported in PocketIC
and thus a blocker for migrating StateMachine tests to PocketIC.
  • Loading branch information
mraszyk authored Oct 9, 2024
1 parent cb996c5 commit ee0d1f6
Show file tree
Hide file tree
Showing 6 changed files with 0 additions and 45 deletions.
2 changes: 0 additions & 2 deletions rs/ethereum/ledger-suite-orchestrator/test_utils/src/flow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,6 @@ impl ManagedCanistersAssert {
.expect("BUG: fail to make a transfer to trigger archive creation");
}

self.setup.env.run_until_completion(/*max_ticks=*/ 10);

let archive_ids_after: BTreeSet<_> = self
.call_ledger_archives()
.into_iter()
Expand Down
8 changes: 0 additions & 8 deletions rs/ledger_suite/tests/sm-tests/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1495,8 +1495,6 @@ fn test_controllers<T>(
transfer(&env, ledger_id, p1.0, p2.0, 10_000 + i).expect("transfer failed");
}

env.run_until_completion(/*max_ticks=*/ 10);

let archive_info = list_archives(&env, ledger_id);
assert_eq!(archive_info.len(), 1);

Expand Down Expand Up @@ -1632,7 +1630,6 @@ where
for i in 0..ARCHIVE_TRIGGER_THRESHOLD {
transfer(&env, ledger_id, p1.0, p2.0, 10_000 + i).expect("transfer failed");
}
env.run_until_completion(/*max_ticks=*/ 10);

let archive_info = list_archives(&env, ledger_id);
let first_archive = ArchiveInfo {
Expand Down Expand Up @@ -1670,7 +1667,6 @@ where
for i in 0..NUM_BLOCKS_TO_ARCHIVE {
transfer(&env, ledger_id, p1.0, p2.0, 10_000 + i).expect("transfer failed");
}
env.run_until_completion(/*max_ticks=*/ 10);
let archive_info = list_archives(&env, ledger_id);
let second_archive = ArchiveInfo {
canister_id: "ryjl3-tyaaa-aaaaa-aaaba-cai".parse().unwrap(),
Expand Down Expand Up @@ -1714,8 +1710,6 @@ pub fn test_archiving<T>(
transfer(&env, canister_id, p1.0, p2.0, 10_000 + i).expect("transfer failed");
}

env.run_until_completion(/*max_ticks=*/ 10);

let archive_info = list_archives(&env, canister_id);
assert_eq!(archive_info.len(), 1);
assert_eq!(archive_info[0].block_range_start, 0u8);
Expand Down Expand Up @@ -1840,8 +1834,6 @@ where
transfer(&env, canister_id, p1.0, p2.0, 10_000 + i * 10_000).expect("transfer failed");
}

env.run_until_completion(/*max_ticks=*/ 10);

let resp = get_blocks(&env, canister_id.get().0, 0, 1_000_000);
assert_eq!(resp.first_index, Nat::from(NUM_BLOCKS_TO_ARCHIVE));
assert_eq!(
Expand Down
2 changes: 0 additions & 2 deletions rs/ledger_suite/tests/sm-tests/src/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,6 @@ pub fn assert_existence_of_ledger_total_transactions_metric<T>(
transfer(&env, ledger_id, MINTER, p1.0, 10_000_000).expect("mint failed");
}

env.run_until_completion(/*max_ticks=*/ 10);

assert_eq!(
NUM_MINT_TRANSACTIONS,
parse_metric(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,6 @@ fn test_enable_retrieving_rate_from_exchange_rate_canister() {
// Start testing. Advance the state machine so the heartbeat triggers
// at the new time.
state_machine.tick();
// Wait to ensure that the call to the exchange rate canister completes.
state_machine.run_until_completion(10_000);

// Step 3: Verify that the rate has been set by calling the cycles minting canister.
let response = get_icp_xdr_conversion_rate(&state_machine);
Expand Down Expand Up @@ -207,8 +205,6 @@ fn test_enable_retrieving_rate_from_exchange_rate_canister() {
state_machine.advance_time(Duration::from_secs(FIVE_MINUTES_SECONDS));
// Trigger the heartbeat.
state_machine.tick();
// Wait to ensure that the call to the exchange rate canister completes.
state_machine.run_until_completion(10_000);

let response = get_icp_xdr_conversion_rate(&state_machine);
// The rate's timestamp should be the CMC's first rate timestamp + 5 minutes + 10 secs.
Expand Down Expand Up @@ -380,8 +376,6 @@ fn test_disabling_and_reenabling_exchange_rate_canister_calling_via_exchange_rat
// Start testing. Advance the state machine so the heartbeat triggers
// at the new time.
state_machine.tick();
// Wait to ensure that the call to the exchange rate canister completes.
state_machine.run_until_completion(10_000);

// Step 3: Verify that the rate has been set by calling the cycles minting canister.
let response = get_icp_xdr_conversion_rate(&state_machine);
Expand Down
23 changes: 0 additions & 23 deletions rs/rosetta-api/tvl/sm-tests/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,26 +64,3 @@ fn tvl_init_args(governance_id: CanisterId, xrc_id: CanisterId) -> TVLInitArgs {
xrc_id: Some(xrc_id.get()),
}
}

pub fn test_tvl(tvl_wasm: Vec<u8>, xrc_wasm: Vec<u8>) {
let (env, governance_id, xrc_id) = setup(xrc_wasm);

let tvl_id = install_tvl(&env, tvl_wasm.clone(), governance_id, xrc_id);

env.run_until_completion(10_000);

env.advance_time(std::time::Duration::from_secs(60));
env.tick();

let get_tvl_result: TvlResult = get_tvl(&env, tvl_id).unwrap();
// 3 neurons with respectively 10 ICP, 1 ICP and 0.1 ICP locked.
// ICP price is 10$, hence tvl should be 111$.
assert_eq!(get_tvl_result.tvl, Nat::from(111_u8));

let upgrade_args = tvl_init_args(governance_id, xrc_id);
env.upgrade_canister(tvl_id, tvl_wasm, Encode!(&upgrade_args).unwrap())
.expect("failed to upgrade the tvl canister");

let get_tvl_result_after_upgrade: TvlResult = get_tvl(&env, tvl_id).unwrap();
assert_eq!(get_tvl_result, get_tvl_result_after_upgrade);
}
4 changes: 0 additions & 4 deletions rs/rosetta-api/tvl/tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,6 @@ impl TvlSetup {
#[test]
fn test_tvl() {
let tvl = TvlSetup::new();

tvl.env.run_until_completion(10_000);
tvl.env
.advance_time(std::time::Duration::from_secs(DEFAULT_UPDATE_PERIOD));
tvl.env.tick();
Expand All @@ -115,7 +113,6 @@ fn test_tvl() {
#[test]
fn test_multiple_currencies() {
let tvl = TvlSetup::new();
tvl.env.run_until_completion(100);
tvl.env
.advance_time(std::time::Duration::from_secs(24 * 60 * 60));
tvl.env.tick();
Expand Down Expand Up @@ -211,7 +208,6 @@ fn test_multiple_currencies() {
#[test]
fn test_fiat_updates() {
let tvl = TvlSetup::new();
tvl.env.run_until_completion(100);
tvl.env
.advance_time(std::time::Duration::from_secs(24 * 60 * 60));
tvl.env.tick();
Expand Down

0 comments on commit ee0d1f6

Please sign in to comment.