From 751df86a2bcadddfb89d7867253ffb2e215da3a7 Mon Sep 17 00:00:00 2001 From: Benjamin DeMann Date: Wed, 17 Jul 2024 15:57:01 -0600 Subject: [PATCH 1/4] fix ethers base --- package-lock.json | 18 +++++++++--------- package.json | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/package-lock.json b/package-lock.json index 0bb75c3334..5321f005dd 100644 --- a/package-lock.json +++ b/package-lock.json @@ -22,7 +22,7 @@ "deep-is": "^0.1.4", "esbuild": "^0.23.0", "esbuild-plugin-tsc": "^0.4.0", - "ethers": "^6.11.1", + "ethers": "6.11.1", "fs-extra": "^11.2.0", "glob": "^10.3.15", "hash-of-directory": "^1.0.1", @@ -4158,9 +4158,9 @@ } }, "node_modules/ethers": { - "version": "6.13.1", - "resolved": "https://registry.npmjs.org/ethers/-/ethers-6.13.1.tgz", - "integrity": "sha512-hdJ2HOxg/xx97Lm9HdCWk949BfYqYWpyw4//78SiwOLgASyfrNszfMUNB2joKjvGUdwhHfaiMMFFwacVVoLR9A==", + "version": "6.11.1", + "resolved": "https://registry.npmjs.org/ethers/-/ethers-6.11.1.tgz", + "integrity": "sha512-mxTAE6wqJQAbp5QAe/+o+rXOID7Nw91OZXvgpjDa1r4fAbq2Nu314oEZSbjoRLacuCzs7kUC3clEvkCQowffGg==", "funding": [ { "type": "individual", @@ -4178,7 +4178,7 @@ "@types/node": "18.15.13", "aes-js": "4.0.0-beta.5", "tslib": "2.4.0", - "ws": "8.17.1" + "ws": "8.5.0" }, "engines": { "node": ">=14.0.0" @@ -8398,15 +8398,15 @@ } }, "node_modules/ws": { - "version": "8.17.1", - "resolved": "https://registry.npmjs.org/ws/-/ws-8.17.1.tgz", - "integrity": "sha512-6XQFvXTkbfUOZOKKILFG1PDK2NDQs4azKQl26T0YS5CxqWLgXajbPZ+h4gZekJyRqFU8pvnbAbbs/3TgRPy+GQ==", + "version": "8.5.0", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.5.0.tgz", + "integrity": "sha512-BWX0SWVgLPzYwF8lTzEy1egjhS4S4OEAHfsO8o65WOVsrnSRGaSiUaa9e0ggGlkMTtBlmOpEXiie9RUcBO86qg==", "engines": { "node": ">=10.0.0" }, "peerDependencies": { "bufferutil": "^4.0.1", - "utf-8-validate": ">=5.0.2" + "utf-8-validate": "^5.0.2" }, "peerDependenciesMeta": { "bufferutil": { diff --git a/package.json b/package.json index 22101a6954..efd15cedfd 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "deep-is": "^0.1.4", "esbuild": "^0.23.0", "esbuild-plugin-tsc": "^0.4.0", - "ethers": "^6.11.1", + "ethers": "6.11.1", "fs-extra": "^11.2.0", "glob": "^10.3.15", "hash-of-directory": "^1.0.1", From a642ad46d4db82ddecaad2eaadbed85cf2fc6e3b Mon Sep 17 00:00:00 2001 From: Benjamin DeMann Date: Wed, 17 Jul 2024 10:29:20 -0600 Subject: [PATCH 2/4] update service prop tests to be smaller --- property_tests/tests/service/test/test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/property_tests/tests/service/test/test.ts b/property_tests/tests/service/test/test.ts index 1194fc3cc5..c84a29d94f 100644 --- a/property_tests/tests/service/test/test.ts +++ b/property_tests/tests/service/test/test.ts @@ -24,7 +24,7 @@ const AllServicesQueryMethodArb = QueryMethodArb( const CanisterConfigArb = fc .array(AllServicesQueryMethodArb, { ...defaultArrayConstraints, - maxLength: 45 + maxLength: 30 // If the number of generated services is too large we will run out of space in the wasm custom section. }) .map((queryMethods): CanisterConfig => { return { queryMethods }; From db16cf121db0e5fbb7bd07ed503093501564bb31 Mon Sep 17 00:00:00 2001 From: Benjamin DeMann Date: Wed, 17 Jul 2024 16:39:59 -0600 Subject: [PATCH 3/4] remove temp test framework code --- property_tests/test/index.ts | 42 ++++++------------------------------ 1 file changed, 7 insertions(+), 35 deletions(-) diff --git a/property_tests/test/index.ts b/property_tests/test/index.ts index d2a009265a..9a63aba1cf 100644 --- a/property_tests/test/index.ts +++ b/property_tests/test/index.ts @@ -14,13 +14,10 @@ export type Test<> = { test?: () => Promise; }; -// TODO get rid of this union once the jest migration is complete -export type AzleResult = - | Partial<{ - Ok: { isSuccessful: boolean; message?: string }; - Err: string; - }> - | Partial<{ Ok: boolean; Err: string }>; +export type AzleResult = Partial<{ + Ok: { isSuccessful: boolean; message?: string }; + Err: string; +}>; // TODO should this just return a boolean? // TODO then the function calling can decide to throw or not @@ -74,20 +71,10 @@ export async function runTests( } } - // TODO replace this with the below commented out code once jest migration is complete - const message = - typeof result.Ok === 'object' && result.Ok !== null - ? result.Ok.message - : undefined; - const successful = - typeof result.Ok === 'boolean' - ? result.Ok - : result.Ok.isSuccessful; - - if (successful !== true) { + if (result.Ok.isSuccessful !== true) { console.info('\x1b[31m', `test: ${test.name} failed`); - if (message !== undefined) { - console.info('\x1b[31m', `${message}`); + if (result.Ok.message !== undefined) { + console.info('\x1b[31m', `${result.Ok.message}`); } console.info('\x1b[0m'); @@ -98,21 +85,6 @@ export async function runTests( } } - // TODO bring this back once jest migration is complete - // if (result.Ok.isSuccessful !== true) { - // console.info('\x1b[31m', `test: ${test.name} failed`); - // if (result.Ok.message !== undefined) { - // console.info('\x1b[31m', `${result.Ok.message}`); - // } - // console.info('\x1b[0m'); - - // if (exitProcess) { - // process.exit(1); - // } else { - // return false; - // } - // } - console.info('\x1b[32m', `test: ${test.name} passed`); console.info('\x1b[0m'); } catch (error) { From bed003a07d55275679bf3b084eaa5f3ff737d5dd Mon Sep 17 00:00:00 2001 From: Benjamin DeMann Date: Wed, 17 Jul 2024 16:58:15 -0600 Subject: [PATCH 4/4] update stable b tree map to use testEquality --- .../stable_b_tree_map/test/contains_key.ts | 16 ++--- .../tests/stable_b_tree_map/test/get.ts | 20 +++---- .../tests/stable_b_tree_map/test/insert.ts | 8 +-- .../tests/stable_b_tree_map/test/is_empty.ts | 16 ++--- .../tests/stable_b_tree_map/test/items.ts | 36 +++++------- .../tests/stable_b_tree_map/test/keys.ts | 58 +++++++++---------- .../tests/stable_b_tree_map/test/len.ts | 16 ++--- .../tests/stable_b_tree_map/test/remove.ts | 10 ++-- .../tests/stable_b_tree_map/test/values.ts | 58 +++++++++---------- 9 files changed, 99 insertions(+), 139 deletions(-) diff --git a/property_tests/tests/stable_b_tree_map/test/contains_key.ts b/property_tests/tests/stable_b_tree_map/test/contains_key.ts index 74dddc6234..07f0c8d297 100644 --- a/property_tests/tests/stable_b_tree_map/test/contains_key.ts +++ b/property_tests/tests/stable_b_tree_map/test/contains_key.ts @@ -1,8 +1,8 @@ -import { deepEqual, getActor } from 'azle/property_tests'; +import { getActor } from 'azle/property_tests'; import { QueryMethod } from 'azle/property_tests/arbitraries/canister_methods/query_method_arb'; import { StableBTreeMap } from 'azle/property_tests/arbitraries/stable_b_tree_map_arb'; import { UniqueIdentifierArb } from 'azle/property_tests/arbitraries/unique_identifier_arb'; -import { AzleResult, Test } from 'azle/property_tests/test'; +import { AzleResult, Test, testEquality } from 'azle/property_tests/test'; import fc from 'fast-check'; export function ContainsKeyTestArb( @@ -60,9 +60,7 @@ function generateTests( keySampleAgentArgumentValue ); - return { - Ok: deepEqual(result, true) - }; + return testEquality(result, true); } } ], @@ -76,9 +74,7 @@ function generateTests( keySampleAgentArgumentValue ); - return { - Ok: deepEqual(result, true) - }; + return testEquality(result, true); } } ], @@ -92,9 +88,7 @@ function generateTests( keySampleAgentArgumentValue ); - return { - Ok: deepEqual(result, false) - }; + return testEquality(result, false); } } ] diff --git a/property_tests/tests/stable_b_tree_map/test/get.ts b/property_tests/tests/stable_b_tree_map/test/get.ts index 337c9f8f49..7ee9b60622 100644 --- a/property_tests/tests/stable_b_tree_map/test/get.ts +++ b/property_tests/tests/stable_b_tree_map/test/get.ts @@ -1,8 +1,8 @@ -import { deepEqual, getActor } from 'azle/property_tests'; +import { getActor } from 'azle/property_tests'; import { QueryMethod } from 'azle/property_tests/arbitraries/canister_methods/query_method_arb'; import { StableBTreeMap } from 'azle/property_tests/arbitraries/stable_b_tree_map_arb'; import { UniqueIdentifierArb } from 'azle/property_tests/arbitraries/unique_identifier_arb'; -import { AzleResult, Test } from 'azle/property_tests/test'; +import { AzleResult, Test, testEquality } from 'azle/property_tests/test'; import fc from 'fast-check'; export function GetTestArb( @@ -70,9 +70,9 @@ function generateTests( keySampleAgentArgumentValue ); - return { - Ok: deepEqual(result, [valueSampleAgentArgumentValue]) - }; + return testEquality(result, [ + valueSampleAgentArgumentValue + ]); } } ], @@ -86,9 +86,9 @@ function generateTests( keySampleAgentArgumentValue ); - return { - Ok: deepEqual(result, [valueSampleAgentArgumentValue]) - }; + return testEquality(result, [ + valueSampleAgentArgumentValue + ]); } } ], @@ -102,9 +102,7 @@ function generateTests( keySampleAgentArgumentValue ); - return { - Ok: deepEqual(result, []) - }; + return testEquality(result, []); } } ] diff --git a/property_tests/tests/stable_b_tree_map/test/insert.ts b/property_tests/tests/stable_b_tree_map/test/insert.ts index 226f661b40..573aa8228e 100644 --- a/property_tests/tests/stable_b_tree_map/test/insert.ts +++ b/property_tests/tests/stable_b_tree_map/test/insert.ts @@ -1,8 +1,8 @@ -import { deepEqual, getActor } from 'azle/property_tests'; +import { getActor } from 'azle/property_tests'; import { QueryMethod } from 'azle/property_tests/arbitraries/canister_methods/query_method_arb'; import { StableBTreeMap } from 'azle/property_tests/arbitraries/stable_b_tree_map_arb'; import { UniqueIdentifierArb } from 'azle/property_tests/arbitraries/unique_identifier_arb'; -import { AzleResult, Test } from 'azle/property_tests/test'; +import { AzleResult, Test, testEquality } from 'azle/property_tests/test'; import fc from 'fast-check'; export function InsertTestArb( @@ -72,9 +72,7 @@ function generateTests( valueSampleAgentArgumentValue ); - return { - Ok: deepEqual(result, []) - }; + return testEquality(result, []); } } ] diff --git a/property_tests/tests/stable_b_tree_map/test/is_empty.ts b/property_tests/tests/stable_b_tree_map/test/is_empty.ts index 5cfad8dda6..cee6467046 100644 --- a/property_tests/tests/stable_b_tree_map/test/is_empty.ts +++ b/property_tests/tests/stable_b_tree_map/test/is_empty.ts @@ -1,8 +1,8 @@ -import { deepEqual, getActor } from 'azle/property_tests'; +import { getActor } from 'azle/property_tests'; import { QueryMethod } from 'azle/property_tests/arbitraries/canister_methods/query_method_arb'; import { StableBTreeMap } from 'azle/property_tests/arbitraries/stable_b_tree_map_arb'; import { UniqueIdentifierArb } from 'azle/property_tests/arbitraries/unique_identifier_arb'; -import { AzleResult, Test } from 'azle/property_tests/test'; +import { AzleResult, Test, testEquality } from 'azle/property_tests/test'; import fc from 'fast-check'; export function IsEmptyTestArb( @@ -48,9 +48,7 @@ function generateTests(functionName: string): Test[][] { const result = await actor[functionName](); - return { - Ok: deepEqual(result, true) - }; + return testEquality(result, true); } } ], @@ -62,9 +60,7 @@ function generateTests(functionName: string): Test[][] { const result = await actor[functionName](); - return { - Ok: deepEqual(result, false) - }; + return testEquality(result, false); } } ], @@ -76,9 +72,7 @@ function generateTests(functionName: string): Test[][] { const result = await actor[functionName](); - return { - Ok: deepEqual(result, true) - }; + return testEquality(result, true); } } ] diff --git a/property_tests/tests/stable_b_tree_map/test/items.ts b/property_tests/tests/stable_b_tree_map/test/items.ts index d05a6cb122..3948ffeb19 100644 --- a/property_tests/tests/stable_b_tree_map/test/items.ts +++ b/property_tests/tests/stable_b_tree_map/test/items.ts @@ -1,8 +1,8 @@ -import { deepEqual, getActor } from 'azle/property_tests'; +import { getActor } from 'azle/property_tests'; import { QueryMethod } from 'azle/property_tests/arbitraries/canister_methods/query_method_arb'; import { StableBTreeMap } from 'azle/property_tests/arbitraries/stable_b_tree_map_arb'; import { UniqueIdentifierArb } from 'azle/property_tests/arbitraries/unique_identifier_arb'; -import { AzleResult, Test } from 'azle/property_tests/test'; +import { AzleResult, Test, testEquality } from 'azle/property_tests/test'; import fc from 'fast-check'; export function ItemsTestArb( @@ -58,14 +58,12 @@ function generateTests( const result = await actor[functionName](); - return { - Ok: deepEqual(result, [ - [ - keySampleAgentArgumentValue, - valueSampleAgentArgumentValue - ] - ]) - }; + return testEquality(result, [ + [ + keySampleAgentArgumentValue, + valueSampleAgentArgumentValue + ] + ]); } } ], @@ -77,14 +75,12 @@ function generateTests( const result = await actor[functionName](); - return { - Ok: deepEqual(result, [ - [ - keySampleAgentArgumentValue, - valueSampleAgentArgumentValue - ] - ]) - }; + return testEquality(result, [ + [ + keySampleAgentArgumentValue, + valueSampleAgentArgumentValue + ] + ]); } } ], @@ -96,9 +92,7 @@ function generateTests( const result = await actor[functionName](); - return { - Ok: deepEqual(result, []) - }; + return testEquality(result, []); } } ] diff --git a/property_tests/tests/stable_b_tree_map/test/keys.ts b/property_tests/tests/stable_b_tree_map/test/keys.ts index 8777f4f1f2..650b3295e1 100644 --- a/property_tests/tests/stable_b_tree_map/test/keys.ts +++ b/property_tests/tests/stable_b_tree_map/test/keys.ts @@ -1,8 +1,8 @@ -import { deepEqual, getActor } from 'azle/property_tests'; +import { getActor } from 'azle/property_tests'; import { QueryMethod } from 'azle/property_tests/arbitraries/canister_methods/query_method_arb'; import { StableBTreeMap } from 'azle/property_tests/arbitraries/stable_b_tree_map_arb'; import { UniqueIdentifierArb } from 'azle/property_tests/arbitraries/unique_identifier_arb'; -import { AzleResult, Test } from 'azle/property_tests/test'; +import { AzleResult, Test, testEquality } from 'azle/property_tests/test'; import fc from 'fast-check'; import { getArrayForCandidType, getArrayStringForCandidType } from './utils'; @@ -62,16 +62,14 @@ function generateTests( const result = await actor[functionName](); - return { - Ok: deepEqual( - getArrayForCandidType( - keySample.src.candidTypeAnnotation - ).from(result), - getArrayForCandidType( - keySample.src.candidTypeAnnotation - ).from([keySample.value.agentArgumentValue]) - ) - }; + return testEquality( + getArrayForCandidType( + keySample.src.candidTypeAnnotation + ).from(result), + getArrayForCandidType( + keySample.src.candidTypeAnnotation + ).from([keySample.value.agentArgumentValue]) + ); } } ], @@ -83,16 +81,14 @@ function generateTests( const result = await actor[functionName](); - return { - Ok: deepEqual( - getArrayForCandidType( - keySample.src.candidTypeAnnotation - ).from(result), - getArrayForCandidType( - keySample.src.candidTypeAnnotation - ).from([keySample.value.agentArgumentValue]) - ) - }; + return testEquality( + getArrayForCandidType( + keySample.src.candidTypeAnnotation + ).from(result), + getArrayForCandidType( + keySample.src.candidTypeAnnotation + ).from([keySample.value.agentArgumentValue]) + ); } } ], @@ -104,16 +100,14 @@ function generateTests( const result = await actor[functionName](); - return { - Ok: deepEqual( - getArrayForCandidType( - keySample.src.candidTypeAnnotation - ).from(result), - getArrayForCandidType( - keySample.src.candidTypeAnnotation - ).from([]) - ) - }; + return testEquality( + getArrayForCandidType( + keySample.src.candidTypeAnnotation + ).from(result), + getArrayForCandidType( + keySample.src.candidTypeAnnotation + ).from([]) + ); } } ] diff --git a/property_tests/tests/stable_b_tree_map/test/len.ts b/property_tests/tests/stable_b_tree_map/test/len.ts index 5b69ee7bd8..8da1aa9d25 100644 --- a/property_tests/tests/stable_b_tree_map/test/len.ts +++ b/property_tests/tests/stable_b_tree_map/test/len.ts @@ -1,8 +1,8 @@ -import { deepEqual, getActor } from 'azle/property_tests'; +import { getActor } from 'azle/property_tests'; import { QueryMethod } from 'azle/property_tests/arbitraries/canister_methods/query_method_arb'; import { StableBTreeMap } from 'azle/property_tests/arbitraries/stable_b_tree_map_arb'; import { UniqueIdentifierArb } from 'azle/property_tests/arbitraries/unique_identifier_arb'; -import { AzleResult, Test } from 'azle/property_tests/test'; +import { AzleResult, Test, testEquality } from 'azle/property_tests/test'; import fc from 'fast-check'; export function LenTestArb( @@ -49,9 +49,7 @@ function generateTests(functionName: string): Test[][] { const result = await actor[functionName](); - return { - Ok: deepEqual(result, 1n) - }; + return testEquality(result, 1n); } } ], @@ -63,9 +61,7 @@ function generateTests(functionName: string): Test[][] { const result = await actor[functionName](); - return { - Ok: deepEqual(result, 1n) - }; + return testEquality(result, 1n); } } ], @@ -77,9 +73,7 @@ function generateTests(functionName: string): Test[][] { const result = await actor[functionName](); - return { - Ok: deepEqual(result, 0n) - }; + return testEquality(result, 0n); } } ] diff --git a/property_tests/tests/stable_b_tree_map/test/remove.ts b/property_tests/tests/stable_b_tree_map/test/remove.ts index 2d43336bd4..b8c1d0390a 100644 --- a/property_tests/tests/stable_b_tree_map/test/remove.ts +++ b/property_tests/tests/stable_b_tree_map/test/remove.ts @@ -1,8 +1,8 @@ -import { deepEqual, getActor } from 'azle/property_tests'; +import { getActor } from 'azle/property_tests'; import { QueryMethod } from 'azle/property_tests/arbitraries/canister_methods/query_method_arb'; import { StableBTreeMap } from 'azle/property_tests/arbitraries/stable_b_tree_map_arb'; import { UniqueIdentifierArb } from 'azle/property_tests/arbitraries/unique_identifier_arb'; -import { AzleResult, Test } from 'azle/property_tests/test'; +import { AzleResult, Test, testEquality } from 'azle/property_tests/test'; import fc from 'fast-check'; export function RemoveTestArb( @@ -71,9 +71,9 @@ function generateTests( keySampleAgentArgumentValue ); - return { - Ok: deepEqual(result, [valueSampleAgentArgumentValue]) - }; + return testEquality(result, [ + valueSampleAgentArgumentValue + ]); } } ] diff --git a/property_tests/tests/stable_b_tree_map/test/values.ts b/property_tests/tests/stable_b_tree_map/test/values.ts index bf0d75de62..b5dde34e39 100644 --- a/property_tests/tests/stable_b_tree_map/test/values.ts +++ b/property_tests/tests/stable_b_tree_map/test/values.ts @@ -1,8 +1,8 @@ -import { deepEqual, getActor } from 'azle/property_tests'; +import { getActor } from 'azle/property_tests'; import { QueryMethod } from 'azle/property_tests/arbitraries/canister_methods/query_method_arb'; import { StableBTreeMap } from 'azle/property_tests/arbitraries/stable_b_tree_map_arb'; import { UniqueIdentifierArb } from 'azle/property_tests/arbitraries/unique_identifier_arb'; -import { AzleResult, Test } from 'azle/property_tests/test'; +import { AzleResult, Test, testEquality } from 'azle/property_tests/test'; import fc from 'fast-check'; import { getArrayForCandidType, getArrayStringForCandidType } from './utils'; @@ -65,16 +65,14 @@ function generateTests( const result = await actor[functionName](); - return { - Ok: deepEqual( - getArrayForCandidType( - valueSample.src.candidTypeAnnotation - ).from(result), - getArrayForCandidType( - valueSample.src.candidTypeAnnotation - ).from([valueSample.value.agentArgumentValue]) - ) - }; + return testEquality( + getArrayForCandidType( + valueSample.src.candidTypeAnnotation + ).from(result), + getArrayForCandidType( + valueSample.src.candidTypeAnnotation + ).from([valueSample.value.agentArgumentValue]) + ); } } ], @@ -86,16 +84,14 @@ function generateTests( const result = await actor[functionName](); - return { - Ok: deepEqual( - getArrayForCandidType( - valueSample.src.candidTypeAnnotation - ).from(result), - getArrayForCandidType( - valueSample.src.candidTypeAnnotation - ).from([valueSample.value.agentArgumentValue]) - ) - }; + return testEquality( + getArrayForCandidType( + valueSample.src.candidTypeAnnotation + ).from(result), + getArrayForCandidType( + valueSample.src.candidTypeAnnotation + ).from([valueSample.value.agentArgumentValue]) + ); } } ], @@ -107,16 +103,14 @@ function generateTests( const result = await actor[functionName](); - return { - Ok: deepEqual( - getArrayForCandidType( - valueSample.src.candidTypeAnnotation - ).from(result), - getArrayForCandidType( - valueSample.src.candidTypeAnnotation - ).from([]) - ) - }; + return testEquality( + getArrayForCandidType( + valueSample.src.candidTypeAnnotation + ).from(result), + getArrayForCandidType( + valueSample.src.candidTypeAnnotation + ).from([]) + ); } } ]