From cb16ef7884d2988c0be532b5c28af8c3f2459b57 Mon Sep 17 00:00:00 2001 From: Eric Swanson Date: Tue, 17 Oct 2023 14:37:14 -0700 Subject: [PATCH] send: log, not println, duplicate message --- e2e/tests-dfx/cycles-ledger.bash | 6 ++++-- src/dfx/src/commands/cycles/top_up.rs | 1 + src/dfx/src/lib/operations/cycles_ledger.rs | 7 ++++--- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/e2e/tests-dfx/cycles-ledger.bash b/e2e/tests-dfx/cycles-ledger.bash index 685ac4f072..a878e8cc60 100644 --- a/e2e/tests-dfx/cycles-ledger.bash +++ b/e2e/tests-dfx/cycles-ledger.bash @@ -352,8 +352,10 @@ current_time_nanoseconds() { # same created-at-time: dupe assert_command dfx cycles top-up "$(dfx canister id e2e_project_backend)" --created-at-time "$t" 100000 --cycles-ledger-canister-id "$(dfx canister id cycles-ledger)" --identity bob - assert_contains "transaction is a duplicate of another transaction in block 3" - assert_contains "Transfer sent at block index 3" + # shellcheck disable=SC2154 + assert_contains "transaction is a duplicate of another transaction in block 3" "$stderr" + # shellcheck disable=SC2154 + assert_contains "Transfer sent at block index 3" "$stdout" assert_command dfx cycles balance --cycles-ledger-canister-id "$(dfx canister id cycles-ledger)" --precise --identity bob assert_eq "2399899900000 cycles." diff --git a/src/dfx/src/commands/cycles/top_up.rs b/src/dfx/src/commands/cycles/top_up.rs index ac2cfe9222..bf6a72789e 100644 --- a/src/dfx/src/commands/cycles/top_up.rs +++ b/src/dfx/src/commands/cycles/top_up.rs @@ -53,6 +53,7 @@ pub async fn exec(env: &dyn Environment, opts: TopUpOpts) -> DfxResult { let from_subaccount = opts.from_subaccount.map(|x| x.0); let result = cycles_ledger::send( agent, + env.get_logger(), to, amount, created_at_time, diff --git a/src/dfx/src/lib/operations/cycles_ledger.rs b/src/dfx/src/lib/operations/cycles_ledger.rs index 0ef996f188..c82a561760 100644 --- a/src/dfx/src/lib/operations/cycles_ledger.rs +++ b/src/dfx/src/lib/operations/cycles_ledger.rs @@ -113,6 +113,7 @@ pub async fn transfer( pub async fn send( agent: &Agent, + logger: &Logger, to: Principal, amount: u128, created_at_time: u64, @@ -143,9 +144,9 @@ pub async fn send( { Ok(Ok(block_index)) => Ok(block_index), Ok(Err(SendError::Duplicate { duplicate_of })) => { - println!( - "transaction is a duplicate of another transaction in block {}", - duplicate_of + info!( + logger, + "transaction is a duplicate of another transaction in block {}", duplicate_of ); Ok(duplicate_of) }