Skip to content

Commit

Permalink
Merge pull request #1987 from demergent-labs/chunk_property_tests
Browse files Browse the repository at this point in the history
Chunk property tests
  • Loading branch information
lastmjs authored Aug 16, 2024
2 parents 0e1c241 + 28344f7 commit 4b7f20b
Show file tree
Hide file tree
Showing 13 changed files with 6,479 additions and 1 deletion.
1 change: 1 addition & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ jobs:
"tests/end_to_end/http_server/tfjs",
"tests/end_to_end/http_server/web_assembly",
"tests/property/ic_api/caller",
"tests/property/ic_api/chunk",
"tests/property/ic_api/id",
"tests/property/ic_api/instruction_counter",
"tests/property/ic_api/is_controller",
Expand Down
11 changes: 11 additions & 0 deletions src/lib/stable/ic_apis/chunk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,17 @@ import { call } from './call';
import { candidEncode } from './candid_encode';
import { id } from './id';

/**
* Resets the instruction limit when this function is called and awaited.
* To achieve this, a simple cross-canister call to the canister calling this function is executed.
*
* You should exercise the appropriate cautions similar to when executing other cross-canister calls, such as managing global mutable state across await points safely.
*
* Only works when called from:
* - update calls and their reply/reject callbacks ([U Ry Rt](https://internetcomputer.org/docs/current/references/ic-interface-spec#system-api-imports))
* - timers ([T](https://internetcomputer.org/docs/current/references/ic-interface-spec#system-api-imports))
* - heartbeats ([T](https://internetcomputer.org/docs/current/references/ic-interface-spec#system-api-imports))
*/
export async function chunk(): Promise<void> {
if (globalThis._azleIc === undefined) {
return undefined;
Expand Down

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

4 changes: 4 additions & 0 deletions tests/property/ic_api/chunk/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.azle
.dfx
dfx_generated
node_modules
13 changes: 13 additions & 0 deletions tests/property/ic_api/chunk/dfx.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"canisters": {
"canister": {
"type": "azle",
"main": "src/index.ts",
"candid_gen": "automatic",
"declarations": {
"output": "test/dfx_generated/canister",
"node_compatibility": true
}
}
}
}
12 changes: 12 additions & 0 deletions tests/property/ic_api/chunk/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/** @type {import('ts-jest').JestConfigWithTsJest} */
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
bail: true,
testTimeout: 100_000_000,
transform: {
'^.+\\.ts$': ['ts-jest', { isolatedModules: true }],
'^.+\\.js$': 'ts-jest'
},
transformIgnorePatterns: ['/node_modules/(?!(azle)/)'] // Make sure azle is transformed
};
Loading

0 comments on commit 4b7f20b

Please sign in to comment.