Skip to content

Commit

Permalink
Merge branch 'main' into arg_data_raw_prop_test
Browse files Browse the repository at this point in the history
  • Loading branch information
bdemann committed Nov 14, 2024
2 parents 5e9e5a2 + 82bda55 commit dea13f1
Show file tree
Hide file tree
Showing 18 changed files with 6,177 additions and 57 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ mod accept_message;
mod arg_data_raw;
mod call_raw;
mod caller;
mod candid_compiler;
mod candid_decode;
mod candid_encode;
mod canister_balance;
Expand Down Expand Up @@ -56,8 +55,6 @@ pub fn register(ctx: Ctx) -> Result<()> {

ic.set("caller", caller::get_function(ctx.clone()))?;

ic.set("candidCompiler", candid_compiler::get_function(ctx.clone()))?;

ic.set("candidDecode", candid_decode::get_function(ctx.clone()))?;

ic.set("candidEncode", candid_encode::get_function(ctx.clone()))?;
Expand Down
1 change: 0 additions & 1 deletion src/lib/stable/ic_apis/azle_ic_stable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ export type AzleIcStable = {
cyclesString: string
) => void;
caller: () => Uint8Array;
candidCompiler: (candidPath: string) => string;
candidDecode: (candidBytes: Uint8Array) => string;
candidEncode: (candidString: string) => Uint8Array;
canisterBalance: () => string;
Expand Down
19 changes: 0 additions & 19 deletions src/lib/stable/ic_apis/candid_compiler.ts

This file was deleted.

1 change: 0 additions & 1 deletion src/lib/stable/ic_apis/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ export { acceptMessage } from './accept_message';
export { argDataRaw } from './arg_data_raw';
export { call } from './call';
export { caller } from './caller';
export { candidCompiler } from './candid_compiler';
export { candidDecode } from './candid_decode';
export { candidEncode } from './candid_encode';
export { canisterBalance } from './canister_balance';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { ActorSubclass } from '@dfinity/agent';
import { expect, it, Test } from 'azle/test';
import { execSync } from 'child_process';
import { createHash } from 'crypto';
import { readFile } from 'fs/promises';

import { execSyncPretty } from '../../../../../../src/build/stable/utils/exec_sync_pretty';
import { _SERVICE } from './dfx_generated/multi_deploy/multi_deploy.did';

export function getTests(multiDeployCanister: ActorSubclass<_SERVICE>): Test {
Expand All @@ -12,7 +12,7 @@ export function getTests(multiDeployCanister: ActorSubclass<_SERVICE>): Test {
const originalHashes = await getFileHashes();

for (let i = 0; i < 10; i++) {
execSyncPretty(`dfx build multi_deploy`);
execSync(`dfx build multi_deploy`);
await verifyHashesMatch(originalHashes);
}
});
Expand All @@ -22,7 +22,7 @@ export function getTests(multiDeployCanister: ActorSubclass<_SERVICE>): Test {
await verifyCalledFunction(multiDeployCanister, 'init');

for (let i = 0; i < 5; i++) {
execSyncPretty(`dfx deploy multi_deploy`);
execSync(`dfx deploy multi_deploy`);
await verifyHashesMatch(originalHashes);
await verifyCalledFunction(multiDeployCanister, 'init');
await verifyModuleHashesMatch();
Expand All @@ -33,7 +33,7 @@ export function getTests(multiDeployCanister: ActorSubclass<_SERVICE>): Test {
const originalHashes = await getFileHashes();

for (let i = 0; i < 5; i++) {
execSyncPretty(`dfx deploy multi_deploy --upgrade-unchanged`);
execSync(`dfx deploy multi_deploy --upgrade-unchanged`);
await verifyHashesMatch(originalHashes);
await verifyCalledFunction(multiDeployCanister, 'postUpgrade');
await verifyModuleHashesMatch();
Expand Down Expand Up @@ -67,9 +67,7 @@ async function verifyModuleHashesMatch(): Promise<void> {
const localHash = await getFileHash(
'.dfx/local/canisters/multi_deploy/multi_deploy.wasm.gz'
);
const canisterInfo = execSyncPretty(
`dfx canister info multi_deploy`
).toString();
const canisterInfo = execSync(`dfx canister info multi_deploy`).toString();
const moduleHash = canisterInfo.match(/Module hash: (0x[a-f0-9]+)/)?.[1];

if (!moduleHash) {
Expand Down
13 changes: 5 additions & 8 deletions tests/end_to_end/http_server/multi_deploy/test/tests.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { expect, it, Test } from 'azle/test';
import { execSync } from 'child_process';
import { createHash } from 'crypto';
import { readFile } from 'fs/promises';

import { execSyncPretty } from '../../../../../src/build/stable/utils/exec_sync_pretty';

export function getTests(canisterId: string): Test {
const origin = `http://${canisterId}.localhost:8000`;

Expand All @@ -12,7 +11,7 @@ export function getTests(canisterId: string): Test {
const originalHashes = await getFileHashes();

for (let i = 0; i < 10; i++) {
execSyncPretty(`dfx build multi_deploy`);
execSync(`dfx build multi_deploy`);
await verifyHashesMatch(originalHashes);
}
});
Expand All @@ -22,7 +21,7 @@ export function getTests(canisterId: string): Test {
await verifyCalledFunction(origin, 'init');

for (let i = 0; i < 5; i++) {
execSyncPretty(`dfx deploy multi_deploy`);
execSync(`dfx deploy multi_deploy`);
await verifyHashesMatch(originalHashes);
await verifyCalledFunction(origin, 'init');
await verifyModuleHashesMatch();
Expand All @@ -33,7 +32,7 @@ export function getTests(canisterId: string): Test {
const originalHashes = await getFileHashes();

for (let i = 0; i < 5; i++) {
execSyncPretty(`dfx deploy multi_deploy --upgrade-unchanged`);
execSync(`dfx deploy multi_deploy --upgrade-unchanged`);
await verifyHashesMatch(originalHashes);
await verifyCalledFunction(origin, 'postUpgrade');
await verifyModuleHashesMatch();
Expand Down Expand Up @@ -72,9 +71,7 @@ async function verifyModuleHashesMatch(): Promise<void> {
const localHash = await getFileHash(
'.dfx/local/canisters/multi_deploy/multi_deploy.wasm.gz'
);
const canisterInfo = execSyncPretty(
`dfx canister info multi_deploy`
).toString();
const canisterInfo = execSync(`dfx canister info multi_deploy`).toString();
const moduleHash = canisterInfo.match(/Module hash: (0x[a-f0-9]+)/)?.[1];

if (!moduleHash) {
Expand Down
4 changes: 4 additions & 0 deletions tests/property/ic_api/candid/.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/candid/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/candid/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 dea13f1

Please sign in to comment.