Skip to content

Commit

Permalink
Fix systests
Browse files Browse the repository at this point in the history
  • Loading branch information
ninegua committed Nov 12, 2024
1 parent 1405bf6 commit ddbd46e
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 252 deletions.
11 changes: 0 additions & 11 deletions rs/tests/ckbtc/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ DEPENDENCIES = [
"//packages/icrc-ledger-agent:icrc_ledger_agent",
"//packages/icrc-ledger-types:icrc_ledger_types",
"//rs/bitcoin/ckbtc/agent",
"//rs/bitcoin/ckbtc/kyt",
"//rs/bitcoin/ckbtc/minter",
"//rs/bitcoin/kyt:btc_kyt_lib",
"//rs/canister_client",
Expand Down Expand Up @@ -59,7 +58,6 @@ system_test_nns(
env = {
"BTC_WASM_PATH": "$(rootpath @btc_canister//file)",
"IC_BTC_KYT_WASM_PATH": "$(rootpath //rs/bitcoin/kyt:btc_kyt_canister)",
"IC_CKBTC_KYT_WASM_PATH": "$(rootpath //rs/bitcoin/ckbtc/kyt:kyt_canister)",
"IC_CKBTC_MINTER_WASM_PATH": "$(rootpath //rs/bitcoin/ckbtc/minter:ckbtc_minter_debug)",
"LEDGER_WASM_PATH": "$(rootpath //rs/ledger_suite/icrc1/ledger:ledger_canister)",
"UNIVERSAL_CANISTER_WASM_PATH": "$(rootpath //rs/universal_canister/impl:universal_canister.wasm.gz)",
Expand All @@ -75,7 +73,6 @@ system_test_nns(
GUESTOS_RUNTIME_DEPS +
UNIVERSAL_VM_RUNTIME_DEPS + [
# Keep sorted.
"//rs/bitcoin/ckbtc/kyt:kyt_canister",
"//rs/bitcoin/ckbtc/minter:ckbtc_minter_debug",
"//rs/bitcoin/kyt:btc_kyt_canister",
"//rs/ledger_suite/icrc1/ledger:ledger_canister",
Expand All @@ -90,7 +87,6 @@ system_test_nns(
env = {
"BTC_WASM_PATH": "$(rootpath @btc_canister//file)",
"IC_BTC_KYT_WASM_PATH": "$(rootpath //rs/bitcoin/kyt:btc_kyt_canister)",
"IC_CKBTC_KYT_WASM_PATH": "$(rootpath //rs/bitcoin/ckbtc/kyt:kyt_canister)",
"IC_CKBTC_MINTER_WASM_PATH": "$(rootpath //rs/bitcoin/ckbtc/minter:ckbtc_minter_debug)",
"LEDGER_WASM_PATH": "$(rootpath //rs/ledger_suite/icrc1/ledger:ledger_canister)",
"UNIVERSAL_CANISTER_WASM_PATH": "$(rootpath //rs/universal_canister/impl:universal_canister.wasm.gz)",
Expand All @@ -105,7 +101,6 @@ system_test_nns(
GUESTOS_RUNTIME_DEPS +
UNIVERSAL_VM_RUNTIME_DEPS + [
# Keep sorted.
"//rs/bitcoin/ckbtc/kyt:kyt_canister",
"//rs/bitcoin/ckbtc/minter:ckbtc_minter_debug",
"//rs/bitcoin/kyt:btc_kyt_canister",
"//rs/ledger_suite/icrc1/ledger:ledger_canister",
Expand All @@ -120,7 +115,6 @@ system_test_nns(
env = {
"BTC_WASM_PATH": "$(rootpath @btc_canister//file)",
"IC_BTC_KYT_WASM_PATH": "$(rootpath //rs/bitcoin/kyt:btc_kyt_canister)",
"IC_CKBTC_KYT_WASM_PATH": "$(rootpath //rs/bitcoin/ckbtc/kyt:kyt_canister)",
"IC_CKBTC_MINTER_WASM_PATH": "$(rootpath //rs/bitcoin/ckbtc/minter:ckbtc_minter_debug)",
"LEDGER_WASM_PATH": "$(rootpath //rs/ledger_suite/icrc1/ledger:ledger_canister)",
"UNIVERSAL_CANISTER_WASM_PATH": "$(rootpath //rs/universal_canister/impl:universal_canister.wasm.gz)",
Expand All @@ -136,7 +130,6 @@ system_test_nns(
GUESTOS_RUNTIME_DEPS +
UNIVERSAL_VM_RUNTIME_DEPS + [
# Keep sorted.
"//rs/bitcoin/ckbtc/kyt:kyt_canister",
"//rs/bitcoin/ckbtc/minter:ckbtc_minter_debug",
"//rs/bitcoin/kyt:btc_kyt_canister",
"//rs/ledger_suite/icrc1/ledger:ledger_canister",
Expand All @@ -151,7 +144,6 @@ system_test_nns(
env = {
"BTC_WASM_PATH": "$(rootpath @btc_canister//file)",
"IC_BTC_KYT_WASM_PATH": "$(rootpath //rs/bitcoin/kyt:btc_kyt_canister)",
"IC_CKBTC_KYT_WASM_PATH": "$(rootpath //rs/bitcoin/ckbtc/kyt:kyt_canister)",
"IC_CKBTC_MINTER_WASM_PATH": "$(rootpath //rs/bitcoin/ckbtc/minter:ckbtc_minter_debug)",
"LEDGER_WASM_PATH": "$(rootpath //rs/ledger_suite/icrc1/ledger:ledger_canister)",
"UNIVERSAL_CANISTER_WASM_PATH": "$(rootpath //rs/universal_canister/impl:universal_canister.wasm.gz)",
Expand All @@ -167,7 +159,6 @@ system_test_nns(
GUESTOS_RUNTIME_DEPS +
UNIVERSAL_VM_RUNTIME_DEPS + [
# Keep sorted.
"//rs/bitcoin/ckbtc/kyt:kyt_canister",
"//rs/bitcoin/ckbtc/minter:ckbtc_minter_debug",
"//rs/bitcoin/kyt:btc_kyt_canister",
"//rs/ledger_suite/icrc1/ledger:ledger_canister",
Expand All @@ -182,7 +173,6 @@ system_test_nns(
env = {
"BTC_WASM_PATH": "$(rootpath @btc_canister//file)",
"IC_BTC_KYT_WASM_PATH": "$(rootpath //rs/bitcoin/kyt:btc_kyt_canister)",
"IC_CKBTC_KYT_WASM_PATH": "$(rootpath //rs/bitcoin/ckbtc/kyt:kyt_canister)",
"IC_CKBTC_MINTER_WASM_PATH": "$(rootpath //rs/bitcoin/ckbtc/minter:ckbtc_minter_debug)",
"LEDGER_WASM_PATH": "$(rootpath //rs/ledger_suite/icrc1/ledger:ledger_canister)",
"UNIVERSAL_CANISTER_WASM_PATH": "$(rootpath //rs/universal_canister/impl:universal_canister.wasm.gz)",
Expand All @@ -198,7 +188,6 @@ system_test_nns(
GUESTOS_RUNTIME_DEPS +
UNIVERSAL_VM_RUNTIME_DEPS + [
# Keep sorted.
"//rs/bitcoin/ckbtc/kyt:kyt_canister",
"//rs/bitcoin/ckbtc/minter:ckbtc_minter_debug",
"//rs/bitcoin/kyt:btc_kyt_canister",
"//rs/ledger_suite/icrc1/ledger:ledger_canister",
Expand Down
55 changes: 6 additions & 49 deletions rs/tests/ckbtc/ckbtc_minter_basics_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@ use ic_system_test_driver::{
util::{assert_create_agent, block_on, runtime_from_url},
};
use ic_tests_ckbtc::{
activate_ecdsa_signature, create_canister, install_bitcoin_canister, install_kyt,
install_ledger, install_minter, install_new_kyt, set_kyt_api_key, setup, subnet_sys,
ADDRESS_LENGTH, TEST_KEY_LOCAL,
activate_ecdsa_signature, create_canister, install_bitcoin_canister, install_ledger,
install_minter, install_new_kyt, setup, subnet_sys, ADDRESS_LENGTH, TEST_KEY_LOCAL,
};
use icrc_ledger_types::icrc1::account::Account;
use slog::info;
Expand All @@ -34,34 +33,14 @@ pub fn test_ckbtc_addresses(env: TestEnv) {
install_bitcoin_canister(&runtime, &logger).await;
let mut ledger_canister = create_canister(&runtime).await;
let mut minter_canister = create_canister(&runtime).await;
let mut kyt_canister = create_canister(&runtime).await;
let mut new_kyt_canister = create_canister(&runtime).await;

let minting_user = minter_canister.canister_id().get();
let agent = assert_create_agent(sys_node.get_public_url().as_str()).await;
let agent_principal = agent.get_principal().unwrap();
let kyt_id = install_kyt(
&mut kyt_canister,
&logger,
Principal::from(minting_user),
vec![agent_principal],
)
.await;

set_kyt_api_key(&agent, &kyt_id.get().0, "fake key".to_string()).await;

let new_kyt_id = install_new_kyt(&mut new_kyt_canister, &env).await;

let ledger_id = install_ledger(&mut ledger_canister, minting_user, &logger).await;
let minter_id = install_minter(
&mut minter_canister,
ledger_id,
&logger,
0,
kyt_id,
new_kyt_id,
)
.await;
let minter_id =
install_minter(&mut minter_canister, ledger_id, &logger, 0, new_kyt_id).await;
let minter = Principal::try_from_slice(minter_id.as_ref()).unwrap();
activate_ecdsa_signature(sys_node, subnet_sys.subnet_id, TEST_KEY_LOCAL, &logger).await;

Expand Down Expand Up @@ -144,36 +123,14 @@ pub fn test_ckbtc_minter_agent(env: TestEnv) {
let runtime = runtime_from_url(sys_node.get_public_url(), sys_node.effective_canister_id());
let mut ledger_canister = create_canister(&runtime).await;
let mut minter_canister = create_canister(&runtime).await;
let mut kyt_canister = create_canister(&runtime).await;
let mut new_kyt_canister = create_canister(&runtime).await;

let minting_user = minter_canister.canister_id().get();

let agent = assert_create_agent(sys_node.get_public_url().as_str()).await;
let agent_principal = agent.get_principal().unwrap();

let kyt_id = install_kyt(
&mut kyt_canister,
&logger,
Principal::from(minting_user),
vec![agent_principal],
)
.await;

set_kyt_api_key(&agent, &kyt_id.get().0, "fake key".to_string()).await;

let new_kyt_id = install_new_kyt(&mut new_kyt_canister, &env).await;

let ledger_id = install_ledger(&mut ledger_canister, minting_user, &logger).await;
let minter_id = install_minter(
&mut minter_canister,
ledger_id,
&logger,
0,
kyt_id,
new_kyt_id,
)
.await;
let minter_id =
install_minter(&mut minter_canister, ledger_id, &logger, 0, new_kyt_id).await;
let minter = Principal::try_from_slice(minter_id.as_ref()).unwrap();
activate_ecdsa_signature(sys_node, subnet_sys.subnet_id, TEST_KEY_LOCAL, &logger).await;

Expand Down
17 changes: 2 additions & 15 deletions rs/tests/ckbtc/ckbtc_minter_batching.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ use ic_system_test_driver::{
util::{assert_create_agent, block_on, runtime_from_url},
};
use ic_tests_ckbtc::{
activate_ecdsa_signature, create_canister_at_id, install_bitcoin_canister, install_kyt,
install_ledger, install_minter, install_new_kyt, set_kyt_api_key, setup, subnet_sys,
activate_ecdsa_signature, create_canister_at_id, install_bitcoin_canister, install_ledger,
install_minter, install_new_kyt, setup, subnet_sys,
utils::{
ensure_wallet, generate_blocks, get_btc_address, get_btc_client, retrieve_btc,
send_to_btc_address, wait_for_finalization_no_new_blocks, wait_for_mempool_change,
Expand Down Expand Up @@ -73,7 +73,6 @@ pub fn test_batching(env: TestEnv) {

let minter_id = CanisterId::from_u64(200);
let ledger_id = CanisterId::from_u64(201);
let kyt_id = CanisterId::from_u64(202);
let new_kyt_id = CanisterId::from_u64(203);

block_on(async {
Expand All @@ -82,22 +81,11 @@ pub fn test_batching(env: TestEnv) {

let mut ledger_canister = create_canister_at_id(&runtime, ledger_id.get()).await;
let mut minter_canister = create_canister_at_id(&runtime, minter_id.get()).await;
let mut kyt_canister = create_canister_at_id(&runtime, kyt_id.get()).await;
let mut new_kyt_canister = create_canister_at_id(&runtime, new_kyt_id.get()).await;

let minting_user = minter_canister.canister_id().get();
let agent = assert_create_agent(sys_node.get_public_url().as_str()).await;
let agent_principal = agent.get_principal().unwrap();
let kyt_id = install_kyt(
&mut kyt_canister,
&logger,
Principal::from(minting_user),
vec![agent_principal],
)
.await;
set_kyt_api_key(&agent, &kyt_id.get().0, "fake key".to_string()).await;
let new_kyt_id = install_new_kyt(&mut new_kyt_canister, &env).await;

let ledger_id = install_ledger(&mut ledger_canister, minting_user, &logger).await;

// We set the minter with a very long time in the queue parameter so we can add up requests in queue
Expand All @@ -109,7 +97,6 @@ pub fn test_batching(env: TestEnv) {
ledger_id,
&logger,
five_hours_nanos,
kyt_id,
new_kyt_id,
)
.await;
Expand Down
26 changes: 4 additions & 22 deletions rs/tests/ckbtc/ckbtc_minter_deposit_and_withdrawal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ use ic_system_test_driver::{
util::{assert_create_agent, block_on, runtime_from_url},
};
use ic_tests_ckbtc::{
activate_ecdsa_signature, create_canister, install_bitcoin_canister, install_kyt,
install_ledger, install_minter, install_new_kyt, set_kyt_api_key, setup, subnet_sys,
activate_ecdsa_signature, create_canister, install_bitcoin_canister, install_ledger,
install_minter, install_new_kyt, setup, subnet_sys,
utils::{
ensure_wallet, generate_blocks, get_btc_address, get_btc_client, send_to_btc_address,
wait_for_finalization, wait_for_mempool_change, wait_for_signed_tx,
Expand Down Expand Up @@ -57,33 +57,15 @@ pub fn test_deposit_and_withdrawal(env: TestEnv) {

let mut ledger_canister = create_canister(&runtime).await;
let mut minter_canister = create_canister(&runtime).await;
let mut kyt_canister = create_canister(&runtime).await;
let mut new_kyt_canister = create_canister(&runtime).await;

let minting_user = minter_canister.canister_id().get();
let agent = assert_create_agent(sys_node.get_public_url().as_str()).await;
let agent_principal = agent.get_principal().unwrap();
let kyt_id = install_kyt(
&mut kyt_canister,
&logger,
Principal::from(minting_user),
vec![agent_principal],
)
.await;
set_kyt_api_key(&agent, &kyt_id.get().0, "fake key".to_string()).await;
let new_kyt_id = install_new_kyt(&mut new_kyt_canister, &env).await;

let ledger_id = install_ledger(&mut ledger_canister, minting_user, &logger).await;
// Here we put the max_time_in_queue to 0 because we want the minter to send request right away with no batching
let minter_id = install_minter(
&mut minter_canister,
ledger_id,
&logger,
0,
kyt_id,
new_kyt_id,
)
.await;
let minter_id =
install_minter(&mut minter_canister, ledger_id, &logger, 0, new_kyt_id).await;
let minter = Principal::from(minter_id.get());
let ledger = Principal::from(ledger_id.get());
activate_ecdsa_signature(sys_node, subnet_sys.subnet_id, TEST_KEY_LOCAL, &logger).await;
Expand Down
Loading

0 comments on commit ddbd46e

Please sign in to comment.