Skip to content

Commit

Permalink
test upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
chenyan-dfinity committed Sep 23, 2023
1 parent d3822af commit b4ba793
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/instrumentation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -613,7 +613,7 @@ fn inject_pre_upgrade(m: &mut Module, vars: &Variables, config: &Config) {
let mut builder = get_or_create_export_func(m, "canister_pre_upgrade");
#[rustfmt::skip]
builder
// backup memory
// backup memory. This is not restricted needed, since the end of pre-upgrade.
.i32_const(0)
.load(memory, LoadKind::I64 { atomic: false }, MemArg { offset: 0, align: 8})
.local_set(a)
Expand Down
18 changes: 17 additions & 1 deletion tests/deployable.ic-repl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,16 @@ function install(wasm) {
);
S
};
function upgrade(S, wasm) {
call ic.install_code(
record {
arg = encode ();
wasm_module = wasm;
mode = variant { upgrade };
canister_id = S;
}
);
};

function motoko(wasm) {
let S = install(wasm);
Expand Down Expand Up @@ -94,14 +104,20 @@ function check_profiling(S, cycles, len) {
assert _ == (cycles : int64);
call S.__get_profiling();
assert _.size() == (len : nat);
null
};

let S = motoko(file("ok/motoko-instrument.wasm"));
check_profiling(S, 9397, 78);
let S = motoko(file("ok/motoko-gc-instrument.wasm"));
check_profiling(S, 250, 4);
let S = motoko(file("ok/motoko-region-instrument.wasm"));
let wasm = file("ok/motoko-region-instrument.wasm");
let S = motoko(wasm);
check_profiling(S, 463589, 78);
upgrade(S, wasm);
call S.get();
assert _ == (45 : nat);
check_profiling(S, 472223, 374);
motoko(file("ok/motoko-shrink.wasm"));
motoko(file("ok/motoko-limit.wasm"));

Expand Down

0 comments on commit b4ba793

Please sign in to comment.