From 4ffda3ff6e6957607d2574fb5256663662047777 Mon Sep 17 00:00:00 2001 From: Benjamin DeMann Date: Wed, 17 Jan 2024 15:32:54 -0700 Subject: [PATCH] simple pr fixes --- property_tests/arbitraries/canister_arb.ts | 13 ++++++------- .../canister_methods/init_method_arb.ts | 2 +- .../canister_methods/post_upgrade_arb.ts | 18 +++++++++--------- .../test/generate_init_tests.ts | 2 +- .../test/generate_post_upgrade_tests.ts | 2 +- .../tests/post_upgrade_method/test/test.ts | 2 +- 6 files changed, 19 insertions(+), 20 deletions(-) diff --git a/property_tests/arbitraries/canister_arb.ts b/property_tests/arbitraries/canister_arb.ts index 719717bd6c..072849682e 100644 --- a/property_tests/arbitraries/canister_arb.ts +++ b/property_tests/arbitraries/canister_arb.ts @@ -72,13 +72,12 @@ export function CanisterArb< ...(config.updateMethods ?? []) ]; - const deployArgs = config.initMethod?.params.map( - ({ value: { value } }) => { - return value.runtimeCandidTypeObject - .getIdl([]) - .valueToString(value.agentArgumentValue); - } - ); + const deployArgs = config.initMethod?.params.map((param) => { + const value = param.value.value; + return value.runtimeCandidTypeObject + .getIdl([]) + .valueToString(value.agentArgumentValue); + }); const sourceCode = generateSourceCode( config.globalDeclarations ?? [], diff --git a/property_tests/arbitraries/canister_methods/init_method_arb.ts b/property_tests/arbitraries/canister_methods/init_method_arb.ts index 9f2bf2f082..29f31ccf78 100644 --- a/property_tests/arbitraries/canister_methods/init_method_arb.ts +++ b/property_tests/arbitraries/canister_methods/init_method_arb.ts @@ -45,7 +45,7 @@ export function InitMethodArb< >; callbackLocation?: CallbackLocation; } -) { +): fc.Arbitrary> { return fc .tuple( UniqueIdentifierArb('canisterMethod'), diff --git a/property_tests/arbitraries/canister_methods/post_upgrade_arb.ts b/property_tests/arbitraries/canister_methods/post_upgrade_arb.ts index e5c7a49efb..1c30e75885 100644 --- a/property_tests/arbitraries/canister_methods/post_upgrade_arb.ts +++ b/property_tests/arbitraries/canister_methods/post_upgrade_arb.ts @@ -45,16 +45,15 @@ export function PostUpgradeMethodArb< >; callbackLocation?: CallbackLocation; } -) { +): fc.Arbitrary< + PostUpgradeMethod +> { return fc .tuple( UniqueIdentifierArb('canisterMethod'), paramTypeArrayArb, VoidArb(), - fc.constantFrom( - 'INLINE', - 'STANDALONE' - ) as fc.Arbitrary, + fc.constantFrom('INLINE', 'STANDALONE'), UniqueIdentifierArb('typeDeclaration') // TODO: This unique id would be better named globalScope or something // But needs to match the same scope as typeDeclarations so I'm using @@ -67,9 +66,10 @@ export function PostUpgradeMethodArb< returnType, defaultCallbackLocation, callbackName - ]) => { - // TODO: Add a return type to this map callback of type PostUpgradeMethod - + ]): PostUpgradeMethod< + ParamAgentArgumentValue, + ParamAgentResponseValue + > => { const callbackLocation = constraints.callbackLocation ?? defaultCallbackLocation; @@ -81,7 +81,7 @@ export function PostUpgradeMethodArb< const namedParams = paramTypes.map( (param: T, index: number): Named => ({ name: `param${index}`, - el: param + value: param }) ); diff --git a/property_tests/tests/post_upgrade_method/test/generate_init_tests.ts b/property_tests/tests/post_upgrade_method/test/generate_init_tests.ts index 5edbaba3ed..f793c94822 100644 --- a/property_tests/tests/post_upgrade_method/test/generate_init_tests.ts +++ b/property_tests/tests/post_upgrade_method/test/generate_init_tests.ts @@ -9,7 +9,7 @@ export function generateTests( ): Test[][] { const expectedResult = [ true, - ...params.map((param) => param.el.value.agentResponseValue) + ...params.map((param) => param.value.value.agentResponseValue) ]; return [ diff --git a/property_tests/tests/post_upgrade_method/test/generate_post_upgrade_tests.ts b/property_tests/tests/post_upgrade_method/test/generate_post_upgrade_tests.ts index c03abd46b2..bde559b716 100644 --- a/property_tests/tests/post_upgrade_method/test/generate_post_upgrade_tests.ts +++ b/property_tests/tests/post_upgrade_method/test/generate_post_upgrade_tests.ts @@ -9,7 +9,7 @@ export function generateTests( ): Test[][] { const expectedResult = [ true, - ...params.map((param) => param.el.value.agentResponseValue) + ...params.map((param) => param.value.value.agentResponseValue) ]; return [ diff --git a/property_tests/tests/post_upgrade_method/test/test.ts b/property_tests/tests/post_upgrade_method/test/test.ts index 13e1913c49..25656215ae 100644 --- a/property_tests/tests/post_upgrade_method/test/test.ts +++ b/property_tests/tests/post_upgrade_method/test/test.ts @@ -1,7 +1,7 @@ import fc from 'fast-check'; import { runPropTests } from 'azle/property_tests'; -import { CandidValueAndMetaArbWithoutFuncs as CandidValueAndMetaArb } from 'azle/property_tests/arbitraries/candid/candid_value_and_meta_arb'; +import { CandidValueAndMetaArb } from 'azle/property_tests/arbitraries/candid/candid_value_and_meta_arb'; import { CandidReturnTypeArb } from 'azle/property_tests/arbitraries/candid/candid_return_type_arb'; import { CanisterArb,