Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
sesi200 committed Dec 21, 2023
1 parent a62e133 commit 7cc27c9
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 10 deletions.
25 changes: 19 additions & 6 deletions e2e/tests-dfx/cycles-ledger.bash
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ current_time_nanoseconds() {

assert_command dfx deploy

assert_command dfx canister call cycles-depositor deposit "(record {to = record{owner = principal \"$ALICE\";};cycles = 2_400_000_000_000;})" --identity cycle-giver
assert_command dfx canister call cycles-depositor deposit "(record {to = record{owner = principal \"$ALICE\";};cycles = 3_400_000_000_000;})" --identity cycle-giver
assert_command dfx canister call cycles-depositor deposit "(record {to = record{owner = principal \"$ALICE\"; subaccount = opt blob \"$ALICE_SUBACCT1_CANDID\"};cycles = 2_600_000_000_000;})" --identity cycle-giver

cd ..
Expand All @@ -450,27 +450,40 @@ current_time_nanoseconds() {
assert_command dfx canister id e2e_project_backend
E2E_PROJECT_BACKEND_CANISTER_ID=$(dfx canister id e2e_project_backend)
assert_command dfx cycles balance --cycles-ledger-canister-id "$CYCLES_LEDGER_ID" --precise
assert_eq "1399900000000 cycles."
assert_eq "2399900000000 cycles."
# forget about canister. If --created-at-time is a valid idempotency key we should end up with the same canister id
rm .dfx/local/canister_ids.json
assert_command dfx canister create e2e_project_backend --with-cycles 1T --created-at-time "$t" --cycles-ledger-canister-id "$CYCLES_LEDGER_ID"
assert_command dfx canister id e2e_project_backend
assert_contains "$E2E_PROJECT_BACKEND_CANISTER_ID"
assert_command dfx cycles balance --cycles-ledger-canister-id "$CYCLES_LEDGER_ID" --precise
assert_eq "2399900000000 cycles."
dfx canister stop e2e_project_backend
dfx canister delete e2e_project_backend

assert_command dfx canister create e2e_project_backend --with-cycles 0.5T --from-subaccount "$ALICE_SUBACCT1" --cycles-ledger-canister-id "$CYCLES_LEDGER_ID"
assert_command dfx canister id e2e_project_backend
assert_command dfx cycles balance --cycles-ledger-canister-id "$CYCLES_LEDGER_ID" --subaccount "$ALICE_SUBACCT1" --precise
assert_eq "2099900000000 cycles."
dfx canister stop e2e_project_backend
dfx canister delete e2e_project_backend

# reset deployment status
rm -r .dfx

# using dfx deploy
assert_command dfx deploy e2e_project_backend --with-cycles 1T --cycles-ledger-canister-id "$CYCLES_LEDGER_ID"
t=$(current_time_nanoseconds)
assert_command dfx deploy e2e_project_backend --with-cycles 1T --created-at-time "$t" --cycles-ledger-canister-id "$CYCLES_LEDGER_ID"
assert_command dfx canister id e2e_project_backend
E2E_PROJECT_BACKEND_CANISTER_ID=$(dfx canister id e2e_project_backend)
assert_command dfx cycles balance --cycles-ledger-canister-id "$CYCLES_LEDGER_ID" --precise
assert_eq "1399800000000 cycles."
# reset and forget about canister. If --created-at-time is a valid idempotency key we should end up with the same canister id
dfx canister uninstall-code e2e_project_backend
rm .dfx/local/canister_ids.json
assert_command dfx deploy e2e_project_backend --with-cycles 1T --created-at-time "$t" --cycles-ledger-canister-id "$CYCLES_LEDGER_ID" -vv
assert_command dfx canister id e2e_project_backend
assert_contains "$E2E_PROJECT_BACKEND_CANISTER_ID"
assert_command dfx cycles balance --cycles-ledger-canister-id "$CYCLES_LEDGER_ID" --precise
assert_eq "399800000000 cycles."
assert_eq "1399800000000 cycles."
dfx canister stop e2e_project_backend
dfx canister delete e2e_project_backend

Expand Down
3 changes: 2 additions & 1 deletion src/dfx/src/commands/canister/create.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ pub struct CanisterCreateOpts {

/// Transaction timestamp, in nanoseconds, for use in controlling transaction deduplication, default is system time.
/// https://internetcomputer.org/docs/current/developer-docs/integrations/icrc-1/#transaction-deduplication-
#[arg(long)]
//TODO(SDK-1331): unhide
#[arg(long, hide = true)]
created_at_time: Option<u64>,

/// Subaccount of the selected identity to spend cycles from.
Expand Down
3 changes: 2 additions & 1 deletion src/dfx/src/commands/deploy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@ pub struct DeployOpts {

/// Transaction timestamp, in nanoseconds, for use in controlling transaction deduplication, default is system time.
/// https://internetcomputer.org/docs/current/developer-docs/integrations/icrc-1/#transaction-deduplication-
#[arg(long)]
//TODO(SDK-1331): unhide
#[arg(long, hide = true)]
created_at_time: Option<u64>,

/// Subaccount of the selected identity to spend cycles from.
Expand Down
4 changes: 2 additions & 2 deletions src/dfx/src/lib/operations/cycles_ledger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ pub async fn create_with_cycles_ledger(
info!(env.get_logger(), "created-at-time is {now}.");
Some(now)
});

let result = agent
.update(&cycles_ledger_canister_id, CREATE_CANISTER_METHOD)
.with_arg(
Expand All @@ -272,7 +273,7 @@ pub async fn create_with_cycles_ledger(
creation_args: Some(CmcCreateCanisterArgs {
settings: Some(settings.into()),
subnet_selection: None,
})
}),
})
.unwrap(),
)
Expand All @@ -289,7 +290,6 @@ pub async fn create_with_cycles_ledger(
err.to_string()
)
})?;
//todo: handle duplicate response
match create_result {
Ok(result) => Ok(result.canister_id),
Err(CreateCanisterError::Duplicate {
Expand Down

0 comments on commit 7cc27c9

Please sign in to comment.