Skip to content

Commit

Permalink
Merge pull request #2180 from demergent-labs/responses_prop_test
Browse files Browse the repository at this point in the history
add responses prop test
  • Loading branch information
lastmjs authored Nov 26, 2024
2 parents 26b2631 + 8325114 commit 04c9a0d
Show file tree
Hide file tree
Showing 44 changed files with 17,396 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/lib/stable/ic_apis/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export { notify } from './notify';
export { performanceCounter } from './performance_counter';
export { print } from './print';
export { reject } from './reject';
export { rejectCode } from './reject_code';
export { rejectCode, RejectionCode } from './reject_code';
export { rejectMessage } from './reject_message';
export { reply } from './reply';
export { setCertifiedData } from './set_certified_data';
Expand Down
19 changes: 18 additions & 1 deletion src/lib/stable/ic_apis/reject_code.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
type RejectionCode =
// TODO this should be removed once https://github.com/demergent-labs/azle/issues/2271 is resolved
import { TextDecoder, TextEncoder } from 'text-encoding';
globalThis.TextDecoder = TextDecoder;
globalThis.TextEncoder = TextEncoder;

import { IDL } from '@dfinity/candid';

export type RejectionCode =
| { NoError: null }
| { SysFatal: null }
| { SysTransient: null }
Expand All @@ -7,6 +14,16 @@ type RejectionCode =
| { CanisterError: null }
| { Unknown: null };

export const RejectionCode = IDL.Variant({
NoError: IDL.Null,
SysFatal: IDL.Null,
SysTransient: IDL.Null,
DestinationInvalid: IDL.Null,
CanisterReject: IDL.Null,
CanisterError: IDL.Null,
Unknown: IDL.Null
});

/**
* Returns the rejection code from the most recently executed cross-canister call
* @returns the rejection code
Expand Down
4 changes: 4 additions & 0 deletions tests/property/ic_api/reject/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.azle
.dfx
dfx_generated
node_modules
12 changes: 12 additions & 0 deletions tests/property/ic_api/reject/dfx.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"canisters": {
"canister": {
"type": "azle",
"main": "src/index.ts",
"declarations": {
"output": "test/dfx_generated/canister",
"node_compatibility": true
}
}
}
}
11 changes: 11 additions & 0 deletions tests/property/ic_api/reject/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/** @type {import('ts-jest').JestConfigWithTsJest} */
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
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 04c9a0d

Please sign in to comment.