From 4d654f8e5932b4ef82a810e08fabf989f6542d69 Mon Sep 17 00:00:00 2001 From: Benjamin DeMann Date: Tue, 31 Dec 2024 07:03:53 -0700 Subject: [PATCH 1/6] update dfx and skip PATCH method tests --- .../test/end_to_end/http_server/express/test/tests.ts | 3 ++- .../end_to_end/http_server/file_protocol/test/tests.ts | 3 ++- .../test/end_to_end/http_server/nest/test/tests.ts | 9 ++++++--- package.json | 2 +- 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/examples/experimental/test/end_to_end/http_server/express/test/tests.ts b/examples/experimental/test/end_to_end/http_server/express/test/tests.ts index 7ac632db55..582fd5ce8b 100644 --- a/examples/experimental/test/end_to_end/http_server/express/test/tests.ts +++ b/examples/experimental/test/end_to_end/http_server/express/test/tests.ts @@ -95,7 +95,8 @@ export function getTests(canisterId: string): Test { expect(getResponseJson).toEqual(json); }); - it('handles patches', async () => { + // TODO enable this tests once https://github.com/demergent-labs/azle/issues/2404 is resolved + it.skip('handles patches', async () => { const json = { hello: 'patch' }; diff --git a/examples/experimental/test/end_to_end/http_server/file_protocol/test/tests.ts b/examples/experimental/test/end_to_end/http_server/file_protocol/test/tests.ts index db91adfe63..d068aa11bc 100644 --- a/examples/experimental/test/end_to_end/http_server/file_protocol/test/tests.ts +++ b/examples/experimental/test/end_to_end/http_server/file_protocol/test/tests.ts @@ -39,7 +39,8 @@ export function getTests(canisterId: string): Test { expect(responseText.trim()).toBe('test3'); }); - it('reads in a file in a grandchild directory', async () => { + // TODO enable this tests once https://github.com/demergent-labs/azle/issues/2404 is resolved + it.skip('reads in a file in a grandchild directory', async () => { const response = await fetch(`${origin}/read-test5`, { method: 'PATCH', headers: [['Content-Type', 'application/json']], diff --git a/examples/experimental/test/end_to_end/http_server/nest/test/tests.ts b/examples/experimental/test/end_to_end/http_server/nest/test/tests.ts index b1c2efed29..6123406d8b 100644 --- a/examples/experimental/test/end_to_end/http_server/nest/test/tests.ts +++ b/examples/experimental/test/end_to_end/http_server/nest/test/tests.ts @@ -29,7 +29,8 @@ export function getTests(canisterId: string): Test { expect(responseText).toBe('put'); }); - it('app patch', async () => { + // TODO enable this tests once https://github.com/demergent-labs/azle/issues/2404 is resolved + it.skip('app patch', async () => { const response = await fetch(`${origin}/patch`, { method: 'PATCH' }); @@ -133,7 +134,8 @@ export function getTests(canisterId: string): Test { expect(responseText).toBe('dogs put'); }); - it('dogs patch', async () => { + // TODO enable this tests once https://github.com/demergent-labs/azle/issues/2404 is resolved + it.skip('dogs patch', async () => { const response = await fetch(`${origin}/dogs/patch`, { method: 'PATCH' }); @@ -239,7 +241,8 @@ export function getTests(canisterId: string): Test { expect(responseText).toBe('cats put'); }); - it('cats patch', async () => { + // TODO enable this tests once https://github.com/demergent-labs/azle/issues/2404 is resolved + it.skip('cats patch', async () => { const response = await fetch(`${origin}/cats/patch`, { method: 'PATCH' }); diff --git a/package.json b/package.json index e473060f16..d4d79f2c4f 100644 --- a/package.json +++ b/package.json @@ -91,7 +91,7 @@ "wasi2ic": "https://github.com/wasm-forge/wasi2ic?rev=676508667a0c3b9fb900ce19cb33bfafa2ae8f8e#67650866", "node": "22.12.0", "rust": "1.83.0", - "dfx": "0.22.0" + "dfx": "0.24.3" } } } From 2a262c69eba058fef0fc2f908e20100004dbcab7 Mon Sep 17 00:00:00 2001 From: Benjamin DeMann Date: Tue, 31 Dec 2024 12:12:27 -0700 Subject: [PATCH 2/6] add additional server headers to filter list --- .../canister_methods/http_request/test/generate_tests.ts | 5 ++++- .../http_request_update/test/generate_tests.ts | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/examples/experimental/test/property/candid_rpc/canister_methods/http_request/test/generate_tests.ts b/examples/experimental/test/property/candid_rpc/canister_methods/http_request/test/generate_tests.ts index 28b9df4f00..412563a820 100644 --- a/examples/experimental/test/property/candid_rpc/canister_methods/http_request/test/generate_tests.ts +++ b/examples/experimental/test/property/candid_rpc/canister_methods/http_request/test/generate_tests.ts @@ -28,7 +28,10 @@ export function generateTests( ([name]) => name !== 'x-ic-streaming-response' && name !== 'content-length' && - name !== 'date' + name !== 'date' && + name !== 'access-control-allow-origin' && + name !== 'access-control-expose-headers' && + name !== 'vary' ) .sort(); const processedResponse = { diff --git a/examples/experimental/test/property/candid_rpc/canister_methods/http_request_update/test/generate_tests.ts b/examples/experimental/test/property/candid_rpc/canister_methods/http_request_update/test/generate_tests.ts index 597741596a..c1f8e3d435 100644 --- a/examples/experimental/test/property/candid_rpc/canister_methods/http_request_update/test/generate_tests.ts +++ b/examples/experimental/test/property/candid_rpc/canister_methods/http_request_update/test/generate_tests.ts @@ -38,7 +38,10 @@ export function generateTests( ([name]) => name !== 'x-ic-streaming-response' && name !== 'content-length' && - name !== 'date' + name !== 'date' && + name !== 'access-control-allow-origin' && + name !== 'access-control-expose-headers' && + name !== 'vary' ) .sort(); const processedResponse = { From 2bdcf3808b4411454fe220490942847d678a358c Mon Sep 17 00:00:00 2001 From: Benjamin DeMann Date: Tue, 31 Dec 2024 12:21:06 -0700 Subject: [PATCH 3/6] update amount for chunk threshold --- examples/stable/test/property/ic_api/cycles_burn/test/tests.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/stable/test/property/ic_api/cycles_burn/test/tests.ts b/examples/stable/test/property/ic_api/cycles_burn/test/tests.ts index ae5563773c..5c0dd921b6 100644 --- a/examples/stable/test/property/ic_api/cycles_burn/test/tests.ts +++ b/examples/stable/test/property/ic_api/cycles_burn/test/tests.ts @@ -36,7 +36,7 @@ export function getTests(): Test { cycleBalanceBefore - cycleBalanceAfter - cyclesBurned - ).toBeLessThanOrEqual(250_000n); + ).toBeLessThanOrEqual(1_000_000n); } ), defaultPropTestParams() From d7ba3e3ec5ec5fcb47aa86f7b3507f426ea8d198 Mon Sep 17 00:00:00 2001 From: Benjamin DeMann Date: Tue, 31 Dec 2024 12:35:04 -0700 Subject: [PATCH 4/6] apply fix to stable tests and remove unallowed methods from arb --- .../canister_methods/http_request/test/generate_tests.ts | 5 ++++- .../http_request_update/test/generate_tests.ts | 5 ++++- test/property/arbitraries/http/request_arb.ts | 9 +++++---- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/examples/stable/test/property/candid_rpc/canister_methods/http_request/test/generate_tests.ts b/examples/stable/test/property/candid_rpc/canister_methods/http_request/test/generate_tests.ts index 28b9df4f00..412563a820 100644 --- a/examples/stable/test/property/candid_rpc/canister_methods/http_request/test/generate_tests.ts +++ b/examples/stable/test/property/candid_rpc/canister_methods/http_request/test/generate_tests.ts @@ -28,7 +28,10 @@ export function generateTests( ([name]) => name !== 'x-ic-streaming-response' && name !== 'content-length' && - name !== 'date' + name !== 'date' && + name !== 'access-control-allow-origin' && + name !== 'access-control-expose-headers' && + name !== 'vary' ) .sort(); const processedResponse = { diff --git a/examples/stable/test/property/candid_rpc/canister_methods/http_request_update/test/generate_tests.ts b/examples/stable/test/property/candid_rpc/canister_methods/http_request_update/test/generate_tests.ts index 597741596a..c1f8e3d435 100644 --- a/examples/stable/test/property/candid_rpc/canister_methods/http_request_update/test/generate_tests.ts +++ b/examples/stable/test/property/candid_rpc/canister_methods/http_request_update/test/generate_tests.ts @@ -38,7 +38,10 @@ export function generateTests( ([name]) => name !== 'x-ic-streaming-response' && name !== 'content-length' && - name !== 'date' + name !== 'date' && + name !== 'access-control-allow-origin' && + name !== 'access-control-expose-headers' && + name !== 'vary' ) .sort(); const processedResponse = { diff --git a/test/property/arbitraries/http/request_arb.ts b/test/property/arbitraries/http/request_arb.ts index 63b689cceb..1451f2a40a 100644 --- a/test/property/arbitraries/http/request_arb.ts +++ b/test/property/arbitraries/http/request_arb.ts @@ -23,10 +23,11 @@ const RequestMethodArb = fc.constantFrom( 'GET', 'POST', 'PUT', - 'DELETE', - 'OPTIONS', - 'TRACE', - 'PATCH' + 'DELETE' + // TODO add back in when resolved https://github.com/demergent-labs/azle/issues/2404 + // 'OPTIONS', + // 'TRACE', + // 'PATCH' ); const UrlPathArb = fc.webUrl({ withQueryParameters: true }).map((url) => { From 41ad00d469664e80082da25b79465a1a8ebe6331 Mon Sep 17 00:00:00 2001 From: Benjamin DeMann Date: Tue, 31 Dec 2024 15:24:01 -0700 Subject: [PATCH 5/6] fix getCanisterOrigin to use new url --- dfx/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dfx/index.ts b/dfx/index.ts index 567b98c1fb..08aa3bb691 100644 --- a/dfx/index.ts +++ b/dfx/index.ts @@ -19,7 +19,7 @@ export function getWebServerPort(): string { export function getCanisterOrigin(canisterName: string): string { return `http://${getCanisterId( canisterName - )}.localhost:${getWebServerPort()}`; + )}.raw.localhost:${getWebServerPort()}`; } export function getAgentHost(): string { From 0ee4c2c4b83effa5432182b28524cd59e3eddf79 Mon Sep 17 00:00:00 2001 From: Benjamin DeMann Date: Tue, 31 Dec 2024 16:11:54 -0700 Subject: [PATCH 6/6] add raw everywhere --- .../experimental/demo/hello_world_http_server/package.json | 2 +- .../end_to_end/http_server/express/src/frontend/index.ts | 2 +- .../test/end_to_end/http_server/fetch_ic/package.json | 2 +- .../end_to_end/http_server/internet_identity/package.json | 2 +- .../end_to_end/http_server/sqlite/batch_create_users.sh | 2 +- .../http_server/sqlite_drizzle/batch_create_users.sh | 2 +- .../http_server/sqlite_typeorm/batch_create_users.sh | 2 +- .../candid_rpc/canister_methods/http_request/test/fletch.ts | 4 ++-- .../candid_rpc/canister_methods/http_request/test/fletch.ts | 4 ++-- .../canister_methods/http_request_update/test/fletch.ts | 4 ++-- the_azle_book/src/authentication.md | 2 +- the_azle_book/src/deployment.md | 6 +++--- the_azle_book/src/servers.md | 2 +- 13 files changed, 18 insertions(+), 18 deletions(-) diff --git a/examples/experimental/demo/hello_world_http_server/package.json b/examples/experimental/demo/hello_world_http_server/package.json index 6f56fab029..006f6d2e3b 100644 --- a/examples/experimental/demo/hello_world_http_server/package.json +++ b/examples/experimental/demo/hello_world_http_server/package.json @@ -1,6 +1,6 @@ { "scripts": { - "build": "cd src/frontend && VITE_CANISTER_ORIGIN=http://$(dfx canister id backend).localhost:8000 vite build", + "build": "cd src/frontend && VITE_CANISTER_ORIGIN=http://$(dfx canister id backend).raw.localhost:8000 vite build", "pretest": "tsx test/pretest.ts", "test": "jest" }, diff --git a/examples/experimental/test/end_to_end/http_server/express/src/frontend/index.ts b/examples/experimental/test/end_to_end/http_server/express/src/frontend/index.ts index f8b96a0e93..fb2a3fa864 100644 --- a/examples/experimental/test/end_to_end/http_server/express/src/frontend/index.ts +++ b/examples/experimental/test/end_to_end/http_server/express/src/frontend/index.ts @@ -5,7 +5,7 @@ import { customElement, property } from 'lit/decorators.js'; export class AzleApp extends LitElement { canisterOrigin: string = `http://${ import.meta.env.VITE_CANISTER_ID - }.localhost:8000`; + }.raw.localhost:8000`; @property() resSendResponse: string = ''; diff --git a/examples/experimental/test/end_to_end/http_server/fetch_ic/package.json b/examples/experimental/test/end_to_end/http_server/fetch_ic/package.json index 68eee6b647..7e06a763ee 100644 --- a/examples/experimental/test/end_to_end/http_server/fetch_ic/package.json +++ b/examples/experimental/test/end_to_end/http_server/fetch_ic/package.json @@ -1,6 +1,6 @@ { "scripts": { - "build": "cd src/frontend && VITE_CANISTER_ORIGIN=http://$(dfx canister id backend).localhost:$(dfx info webserver-port) VITE_IDENTITY_PROVIDER=http://$(dfx canister id internet_identity).localhost:$(dfx info webserver-port) vite build", + "build": "cd src/frontend && VITE_CANISTER_ORIGIN=http://$(dfx canister id backend).raw.localhost:$(dfx info webserver-port) VITE_IDENTITY_PROVIDER=http://$(dfx canister id internet_identity).localhost:$(dfx info webserver-port) vite build", "pretest": "tsx test/pretest.ts", "test": "jest" }, diff --git a/examples/experimental/test/end_to_end/http_server/internet_identity/package.json b/examples/experimental/test/end_to_end/http_server/internet_identity/package.json index 68eee6b647..7e06a763ee 100644 --- a/examples/experimental/test/end_to_end/http_server/internet_identity/package.json +++ b/examples/experimental/test/end_to_end/http_server/internet_identity/package.json @@ -1,6 +1,6 @@ { "scripts": { - "build": "cd src/frontend && VITE_CANISTER_ORIGIN=http://$(dfx canister id backend).localhost:$(dfx info webserver-port) VITE_IDENTITY_PROVIDER=http://$(dfx canister id internet_identity).localhost:$(dfx info webserver-port) vite build", + "build": "cd src/frontend && VITE_CANISTER_ORIGIN=http://$(dfx canister id backend).raw.localhost:$(dfx info webserver-port) VITE_IDENTITY_PROVIDER=http://$(dfx canister id internet_identity).localhost:$(dfx info webserver-port) vite build", "pretest": "tsx test/pretest.ts", "test": "jest" }, diff --git a/examples/experimental/test/end_to_end/http_server/sqlite/batch_create_users.sh b/examples/experimental/test/end_to_end/http_server/sqlite/batch_create_users.sh index dffdd94b7a..7f5661d0ac 100755 --- a/examples/experimental/test/end_to_end/http_server/sqlite/batch_create_users.sh +++ b/examples/experimental/test/end_to_end/http_server/sqlite/batch_create_users.sh @@ -4,7 +4,7 @@ count=1000 # Change this number as needed # URL to which the POST request will be sent -url="http://$(dfx canister id sqlite).localhost:8000/users/batch/1000" +url="http://$(dfx canister id sqlite).raw.localhost:8000/users/batch/1000" # Loop as many times as specified in the count variable for ((i=0; i