Skip to content

Commit

Permalink
Merge pull request #1601 from demergent-labs/fetch_example_tests
Browse files Browse the repository at this point in the history
add fetch to management
  • Loading branch information
lastmjs authored Feb 1, 2024
2 parents 8356b83 + 8b81f7e commit f3e54fd
Show file tree
Hide file tree
Showing 5 changed files with 305 additions and 108 deletions.
29 changes: 20 additions & 9 deletions canisters/management/canister_management.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import {
nat,
Variant,
Null,
blob
blob,
nat64
} from '../../src/lib';

export const CanisterId = Principal;
Expand All @@ -29,7 +30,8 @@ export const CanisterSettings = Record({
controllers: Opt(Vec(Principal)),
compute_allocation: Opt(nat),
memory_allocation: Opt(nat),
freezing_threshold: Opt(nat)
freezing_threshold: Opt(nat),
reserved_cycles_limit: Opt(nat)
});
export type CanisterSettings = typeof CanisterSettings.tsType;

Expand All @@ -38,7 +40,8 @@ export type CanisterSettings = typeof CanisterSettings.tsType;
* method
*/
export const CreateCanisterArgs = Record({
settings: Opt(CanisterSettings)
settings: Opt(CanisterSettings),
sender_canister_version: Opt(nat64)
});
export type CreateCanisterArgs = typeof CreateCanisterArgs.tsType;

Expand All @@ -58,7 +61,8 @@ export const DefiniteCanisterSettings = Record({
controllers: Vec(Principal),
compute_allocation: nat,
memory_allocation: nat,
freezing_threshold: nat
freezing_threshold: nat,
reserved_cycles_limit: nat
});
export type DefiniteCanisterSettings = typeof DefiniteCanisterSettings.tsType;

Expand All @@ -67,7 +71,9 @@ export const CanisterStatusResult = Record({
settings: DefiniteCanisterSettings,
module_hash: Opt(blob),
memory_size: nat,
cycles: nat
cycles: nat,
reserved_cycles: nat,
idle_cycles_burned_per_day: nat
});
export type CanisterStatusResult = typeof CanisterStatusResult.tsType;

Expand All @@ -78,7 +84,8 @@ export type CanisterStatusArgs = typeof CanisterStatusArgs.tsType;

export const UpdateSettingsArgs = Record({
canister_id: CanisterId,
settings: CanisterSettings
settings: CanisterSettings,
sender_canister_version: Opt(nat64)
});
export type UpdateSettingsArgs = typeof UpdateSettingsArgs.tsType;

Expand All @@ -93,12 +100,14 @@ export const InstallCodeArgs = Record({
mode: InstallCodeMode,
canister_id: CanisterId,
wasm_module: WasmModule,
arg: blob
arg: blob,
sender_canister_version: Opt(nat64)
});
export type InstallCodeArgs = typeof InstallCodeArgs.tsType;

export const UninstallCodeArgs = Record({
canister_id: CanisterId
canister_id: CanisterId,
sender_canister_version: Opt(nat64)
});
export type UninstallCodeArgs = typeof UninstallCodeArgs.tsType;

Expand All @@ -119,7 +128,9 @@ export type DeleteCanisterArgs = typeof DeleteCanisterArgs.tsType;

export const ProvisionalCreateCanisterWithCyclesArgs = Record({
amount: Opt(nat),
settings: Opt(CanisterSettings)
settings: Opt(CanisterSettings),
specified_id: Opt(CanisterId),
sender_canister_version: Opt(nat64)
});
export type ProvisionalCreateCanisterWithCyclesArgs =
typeof ProvisionalCreateCanisterWithCyclesArgs.tsType;
Expand Down
3 changes: 2 additions & 1 deletion examples/management_canister/dfx.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
"declarations": {
"output": "test/dfx_generated/management_canister",
"node_compatibility": true
}
},
"env": ["AZLE_TEST_FETCH"]
}
}
}
5 changes: 3 additions & 2 deletions examples/management_canister/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"scripts": {
"pretest": "ts-node --transpile-only --ignore=false test/pretest.ts",
"test": "ts-node --transpile-only --ignore=false test/test.ts"
"pre_tests": "ts-node --transpile-only --ignore=false test/pretest.ts",
"tests": "npm run pre_tests && ts-node --transpile-only --ignore=false test/test.ts",
"test": "AZLE_TEST_FETCH=false npm run tests && AZLE_TEST_FETCH=true npm run tests"
},
"dependencies": {
"azle": "0.19.0"
Expand Down
2 changes: 1 addition & 1 deletion examples/management_canister/src/index.did
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ service: () -> {
executeUninstallCode: (principal) -> (bool);
executeUpdateSettings: (principal) -> (bool);
getCanisterInfo: (record {canister_id:principal; num_requested_changes:opt nat64}) -> (record {controllers:vec principal; module_hash:opt vec nat8; recent_changes:vec record {timestamp_nanos:nat64; canister_version:nat64; origin:variant {from_user:record {user_id:principal}; from_canister:record {canister_version:opt nat64; canister_id:principal}}; details:variant {creation:record {controllers:vec principal}; code_deployment:record {mode:variant {reinstall; upgrade; install}; module_hash:vec nat8}; controllers_change:record {controllers:vec principal}; code_uninstall}}; total_num_changes:nat64});
getCanisterStatus: (record {canister_id:principal}) -> (record {status:variant {stopped; stopping; running}; memory_size:nat; cycles:nat; settings:record {freezing_threshold:nat; controllers:vec principal; memory_allocation:nat; compute_allocation:nat}; module_hash:opt vec nat8});
getCanisterStatus: (record {canister_id:principal}) -> (record {status:variant {stopped; stopping; running}; memory_size:nat; cycles:nat; settings:record {freezing_threshold:nat; controllers:vec principal; reserved_cycles_limit:nat; memory_allocation:nat; compute_allocation:nat}; idle_cycles_burned_per_day:nat; module_hash:opt vec nat8; reserved_cycles:nat});
getCreatedCanisterId: () -> (principal) query;
getRawRand: () -> (vec nat8);
provisionalCreateCanisterWithCycles: () -> (record {canister_id:principal});
Expand Down
Loading

0 comments on commit f3e54fd

Please sign in to comment.