Skip to content

Commit

Permalink
Merge branch 'main' into update_es_version
Browse files Browse the repository at this point in the history
  • Loading branch information
bdemann committed Feb 10, 2025
2 parents 1ee59ed + 4ff3433 commit c6c1358
Show file tree
Hide file tree
Showing 15 changed files with 66 additions and 62 deletions.
Binary file modified canister_templates/experimental.wasm
Binary file not shown.
Binary file modified canister_templates/stable.wasm
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
node_modules
dist
dfx_generated
!src
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
import { Principal } from 'azle';
import { getCanisterId } from 'azle/dfx';
import {
defaultPropTestParams,
expect,
it,
runAndProvideReproduction,
Test
} from 'azle/test';
import { defaultPropTestParams, expect, it, Test } from 'azle/test';
import fc from 'fast-check';

import { deployFreshCanister, getCanisterStatus } from './dfx';
Expand All @@ -18,44 +12,39 @@ const CANISTER_NAME = 'canister';
export function getTests(): Test {
return () => {
it('should trigger low memory handler when memory limit is approached', async () => {
await runAndProvideReproduction(async () => {
await fc.assert(
fc.asyncProperty(
fc.integer({ min: 0, max: 100 }),
fc.integer({
min: 90 * 1024 * 1024, // 90 MiB in bytes (about the smallest size of this azle canister)
max: HARD_LIMIT
}),
async (
wasmMemoryThresholdPercentage,
await fc.assert(
fc.asyncProperty(
fc.integer({ min: 0, max: 100 }),
fc.integer({
min: 90 * 1024 * 1024, // 90 MiB in bytes (about the smallest size of this azle canister)
max: HARD_LIMIT
}),
async (wasmMemoryThresholdPercentage, wasmMemoryLimit) => {
// Calculate actual threshold based on percentage
const wasmMemoryThreshold = Math.floor(
wasmMemoryLimit *
(wasmMemoryThresholdPercentage / 100)
);

const actor = await deployFreshCanister<Actor>(
CANISTER_NAME,
wasmMemoryThreshold,
wasmMemoryLimit
) => {
// Calculate actual threshold based on percentage
const wasmMemoryThreshold = Math.floor(
wasmMemoryLimit *
(wasmMemoryThresholdPercentage / 100)
);

const actor = await deployFreshCanister<Actor>(
CANISTER_NAME,
wasmMemoryThreshold,
wasmMemoryLimit
);

await validateInitialStatus(actor, wasmMemoryLimit);

await addBytesUntilLimitReached(actor);

await validateFinalStatus(
actor,
wasmMemoryLimit,
wasmMemoryThreshold
);
}
),
defaultPropTestParams()
);
});
);

await validateInitialStatus(actor, wasmMemoryLimit);

await addBytesUntilLimitReached(actor);

await validateFinalStatus(
actor,
wasmMemoryLimit,
wasmMemoryThreshold
);
}
),
defaultPropTestParams()
);
});
};
}
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

42 changes: 28 additions & 14 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
},
"devDependencies": {
"@dfinity/identity": "^2.2.0",
"@eslint/js": "^9.19.0",
"@eslint/js": "^9.20.0",
"@types/deep-equal": "^1.0.4",
"@types/fs-extra": "11.0.4",
"@types/pako": "^2.0.3",
Expand All @@ -67,14 +67,14 @@
"@typescript-eslint/eslint-plugin": "^8.23.0",
"@typescript-eslint/parser": "^8.23.0",
"deep-equal": "^2.2.3",
"eslint": "^9.19.0",
"eslint": "^9.20.0",
"eslint-config-prettier": "^10.0.1",
"eslint-plugin-simple-import-sort": "^12.1.1",
"fast-check": "^3.23.2",
"husky": "9.1.7",
"jest": "^29.7.0",
"lint-staged": "15.4.3",
"prettier": "^3.4.2",
"prettier": "^3.5.0",
"puppeteer": "^24.2.0",
"semver": "^7.7.1",
"ts-jest": "^29.1.4",
Expand Down

0 comments on commit c6c1358

Please sign in to comment.