Skip to content

Commit

Permalink
fix remaining failing tests, canister did files are now included auto…
Browse files Browse the repository at this point in the history
…matically in the canister /candid directory
  • Loading branch information
lastmjs committed Apr 24, 2024
1 parent 8eed733 commit a4187b1
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 9 deletions.
1 change: 0 additions & 1 deletion examples/composite_queries/dfx.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
"AZLE_TEST_FETCH"
],
"assets": [
[".azle/canister1/canister1.did", "candid/canister1.did"],
[".azle/canister2/canister2.did", "candid/canister2.did"],
[".azle/canister3/canister3.did", "candid/canister3.did"]
],
Expand Down
1 change: 0 additions & 1 deletion examples/motoko_examples/whoami/dfx.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
"main": "src/index.ts",
"candid_gen": "automatic",
"env": ["AZLE_TEST_FETCH"],
"assets": [[".azle/whoami/whoami.did", "candid/whoami.did"]],
"declarations": {
"output": "test/dfx_generated/whoami",
"node_compatibility": true
Expand Down
10 changes: 5 additions & 5 deletions examples/rejections/src/rejections/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export default Canister({
if (process.env.AZLE_TEST_FETCH === 'true') {
await fetch(`icp://${getSomeCanisterPrincipal()}/accept`, {
body: serialize({
candidPath: `/src/some_canister.did`
candidPath: `/candid/some_canister.did`
})
});
} else {
Expand All @@ -47,7 +47,7 @@ export default Canister({
if (process.env.AZLE_TEST_FETCH === 'true') {
await fetch(`icp://rkp4c-7iaaa-aaaaa-aaaca-cai/method`, {
body: serialize({
candidPath: `/src/nonexistent.did`
candidPath: `/candid/nonexistent.did`
})
});
} else {
Expand All @@ -64,7 +64,7 @@ export default Canister({
if (process.env.AZLE_TEST_FETCH === 'true') {
await fetch(`icp://${getSomeCanisterPrincipal()}/reject`, {
body: serialize({
candidPath: `/src/some_canister.did`,
candidPath: `/candid/some_canister.did`,
args: ['reject']
})
});
Expand All @@ -82,7 +82,7 @@ export default Canister({
if (process.env.AZLE_TEST_FETCH === 'true') {
await fetch(`icp://${getSomeCanisterPrincipal()}/error`, {
body: serialize({
candidPath: `/src/some_canister.did`
candidPath: `/candid/some_canister.did`
})
});
} else {
Expand All @@ -99,7 +99,7 @@ export default Canister({
if (process.env.AZLE_TEST_FETCH === 'true') {
await fetch(`icp://${getSomeCanisterPrincipal()}/reject`, {
body: serialize({
candidPath: `/src/some_canister.did`,
candidPath: `/candid/some_canister.did`,
args: [message]
})
});
Expand Down
6 changes: 4 additions & 2 deletions examples/rejections/test/pretest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@ async function pretest() {
stdio: 'inherit'
});

execSync(`dfx canister create some_canister`, {
execSync(`dfx deploy some_canister`, {
stdio: 'inherit'
});

execSync(
`SOME_CANISTER_PRINCIPAL=${getCanisterId('some_canister')} dfx deploy`,
`SOME_CANISTER_PRINCIPAL=${getCanisterId(
'some_canister'
)} dfx deploy rejections`,
{
stdio: 'inherit'
}
Expand Down
20 changes: 20 additions & 0 deletions src/compiler/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ async function azle() {
nativeCompilation
);

addCanisterDidToAssets(canisterPath, canisterName, candid);

// This is for the dfx.json candid property
writeFileSync(candidPath, candid);

Expand Down Expand Up @@ -156,3 +158,21 @@ function installDfxExtension(stdioType: IOType) {
stdioType
);
}

function addCanisterDidToAssets(
canisterPath: string,
canisterName: string,
candid: string
) {
writeFileSync(
join(
canisterPath,
'canister',
'src',
'assets',
'candid',
`${canisterName}.did`
),
candid
);
}

0 comments on commit a4187b1

Please sign in to comment.