Skip to content

Commit

Permalink
send: log, not println, duplicate message
Browse files Browse the repository at this point in the history
  • Loading branch information
ericswanson-dfinity committed Oct 17, 2023
1 parent 8ce780f commit cb16ef7
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
6 changes: 4 additions & 2 deletions e2e/tests-dfx/cycles-ledger.bash
Original file line number Diff line number Diff line change
Expand Up @@ -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."

Expand Down
1 change: 1 addition & 0 deletions src/dfx/src/commands/cycles/top_up.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
7 changes: 4 additions & 3 deletions src/dfx/src/lib/operations/cycles_ledger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ pub async fn transfer(

pub async fn send(
agent: &Agent,
logger: &Logger,
to: Principal,
amount: u128,
created_at_time: u64,
Expand Down Expand Up @@ -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)
}
Expand Down

0 comments on commit cb16ef7

Please sign in to comment.