Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
hpeebles committed Dec 20, 2023
1 parent 7361c42 commit 6755b2f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 16 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use crate::client::icrc1::happy_path::balance_of;
use crate::client::{start_canister, stop_canister};
use crate::env::ENV;
use crate::rng::{random_message_id, random_string};
use crate::utils::{now_millis, now_nanos, tick_many};
Expand Down Expand Up @@ -68,8 +69,7 @@ fn send_crypto_in_channel(with_c2c_error: bool) {
} = init_test_data(env, canister_ids, *controller);

if with_c2c_error {
env.stop_canister(community_id.into(), Some(canister_ids.local_group_index))
.unwrap();
stop_canister(env, canister_ids.local_group_index, community_id.into());
}

let send_message_result = client::user::send_message_with_transfer_to_channel(
Expand Down Expand Up @@ -121,8 +121,7 @@ fn send_crypto_in_channel(with_c2c_error: bool) {

if with_c2c_error {
env.advance_time(Duration::from_secs(10));
env.start_canister(community_id.into(), Some(canister_ids.local_group_index))
.unwrap();
start_canister(env, canister_ids.local_group_index, community_id.into());
env.tick();
}

Expand Down
20 changes: 8 additions & 12 deletions backend/integration_tests/src/send_crypto_tests.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use crate::client::{start_canister, stop_canister};
use crate::env::ENV;
use crate::rng::{random_message_id, random_string};
use crate::utils::now_nanos;
use crate::utils::{now_nanos, tick_many};
use crate::{client, TestEnv};
use candid::Principal;
use icrc_ledger_types::icrc1::account::Account;
Expand Down Expand Up @@ -31,8 +32,7 @@ fn send_direct_message_with_transfer_succeeds(with_c2c_error: bool) {
client::icrc1::happy_path::transfer(env, *controller, canister_ids.icp_ledger, user1.user_id, 1_000_000_000);

if with_c2c_error {
env.stop_canister(user2.canister(), Some(canister_ids.local_user_index))
.unwrap();
stop_canister(env, canister_ids.local_user_index, user2.canister());
}

let send_message_result = client::user::send_message_v2(
Expand Down Expand Up @@ -68,16 +68,15 @@ fn send_direct_message_with_transfer_succeeds(with_c2c_error: bool) {
user_canister::send_message_v2::Response::TransferSuccessV2(_)
));

env.tick();
tick_many(env, 3);

let user2_balance = client::icrc1::happy_path::balance_of(env, canister_ids.icp_ledger, user2.user_id);
assert_eq!(user2_balance, 10000);

if with_c2c_error {
env.advance_time(Duration::from_secs(10));
env.start_canister(user2.canister(), Some(canister_ids.local_user_index))
.unwrap();
env.tick();
start_canister(env, canister_ids.local_user_index, user2.canister());
tick_many(env, 3);
}

let event = client::user::happy_path::events(env, &user2, user1.user_id, 0.into(), true, 10, 10)
Expand Down Expand Up @@ -113,8 +112,7 @@ fn send_message_with_transfer_to_group_succeeds(with_c2c_error: bool) {
client::icrc1::happy_path::transfer(env, *controller, canister_ids.icp_ledger, user1.user_id, 1_000_000_000);

if with_c2c_error {
env.stop_canister(group_id.into(), Some(canister_ids.local_group_index))
.unwrap();
stop_canister(env, canister_ids.local_group_index, group_id.into());
}

let send_message_result = client::user::send_message_with_transfer_to_group(
Expand Down Expand Up @@ -165,9 +163,7 @@ fn send_message_with_transfer_to_group_succeeds(with_c2c_error: bool) {

if with_c2c_error {
env.advance_time(Duration::from_secs(10));
env.start_canister(group_id.into(), Some(canister_ids.local_group_index))
.unwrap();
env.tick();
start_canister(env, canister_ids.local_group_index, group_id.into());
}

let event = client::group::happy_path::events(env, &user2, group_id, 0.into(), true, 10, 10)
Expand Down

0 comments on commit 6755b2f

Please sign in to comment.