diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 79ebb1850e..dd0ec0480b 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -149,6 +149,7 @@ jobs: "property_tests/tests/nat64", "property_tests/tests/null", "property_tests/tests/opt", + "property_tests/tests/post_upgrade_method", "property_tests/tests/principal", "property_tests/tests/query_methods", "property_tests/tests/record", diff --git a/property_tests/arbitraries/candid/candid_value_and_meta_arb_generator.ts b/property_tests/arbitraries/candid/candid_value_and_meta_arb_generator.ts index 53072955a6..95544d4db0 100644 --- a/property_tests/arbitraries/candid/candid_value_and_meta_arb_generator.ts +++ b/property_tests/arbitraries/candid/candid_value_and_meta_arb_generator.ts @@ -2,7 +2,7 @@ import fc from 'fast-check'; import { CorrespondingJSType } from './corresponding_js_type'; import { CandidDefinition, WithShapes } from './candid_definition_arb/types'; import { CandidValueAndMeta } from './candid_value_and_meta_arb'; -import { CandidValues } from './candid_values_arb'; +import { CandidValueConstraints, CandidValues } from './candid_values_arb'; import { RecursiveShapes } from './recursive'; export function CandidValueAndMetaArbGenerator< @@ -14,9 +14,9 @@ export function CandidValueAndMetaArbGenerator< ValueArb: ( arb: D, recursiveShapes: RecursiveShapes, - constraints?: any + constraints?: CandidValueConstraints ) => fc.Arbitrary, - valueConstraints?: any + valueConstraints?: CandidValueConstraints ): fc.Arbitrary> { return DefinitionArb.chain((candidDefinitionAndShapes) => { const candidDefinition = candidDefinitionAndShapes.definition; @@ -25,33 +25,35 @@ export function CandidValueAndMetaArbGenerator< fc.constant(candidDefinition), ValueArb(candidDefinition, recursiveShapes, valueConstraints) ); - }).map( - ([ - { - candidMeta: { - candidTypeAnnotation, - candidTypeObject, - runtimeCandidTypeObject, - variableAliasDeclarations, - imports - } - }, - { agentArgumentValue, agentResponseValue, valueLiteral } - ]) => { - return { - src: { - candidTypeAnnotation, - candidTypeObject, - variableAliasDeclarations, - imports, - valueLiteral - }, - value: { - agentArgumentValue, - agentResponseValue, - runtimeCandidTypeObject - } - }; + }).map(([definition, value]) => { + return definitionAndValueToValueAndMeta(definition, value); + }); +} + +export function definitionAndValueToValueAndMeta( + definition: CandidDefinition, + value: CandidValues +): CandidValueAndMeta { + const { + candidTypeAnnotation, + candidTypeObject, + imports, + variableAliasDeclarations, + runtimeCandidTypeObject + } = definition.candidMeta; + const { valueLiteral, agentArgumentValue, agentResponseValue } = value; + return { + src: { + candidTypeAnnotation, + candidTypeObject, + imports, + valueLiteral, + variableAliasDeclarations + }, + value: { + agentArgumentValue, + agentResponseValue, + runtimeCandidTypeObject } - ); + }; } diff --git a/property_tests/arbitraries/candid/candid_values_arb.ts b/property_tests/arbitraries/candid/candid_values_arb.ts index b36794c887..1216110e2a 100644 --- a/property_tests/arbitraries/candid/candid_values_arb.ts +++ b/property_tests/arbitraries/candid/candid_values_arb.ts @@ -2,10 +2,16 @@ import fc from 'fast-check'; import { RecordValuesArb } from './constructed/record_arb/values_arb'; import { BoolValueArb } from './primitive/bool'; import { VecValuesArb } from './constructed/vec_arb/values_arb'; -import { TextValueArb } from './primitive/text'; +import { TextConstraints, TextValueArb } from './primitive/text'; import { NullValueArb } from './primitive/null'; -import { Float32ValueArb } from './primitive/floats/float32_arb'; -import { Float64ValueArb } from './primitive/floats/float64_arb'; +import { + Float32Constraints, + Float32ValueArb +} from './primitive/floats/float32_arb'; +import { + Float64Constraints, + Float64ValueArb +} from './primitive/floats/float64_arb'; import { IntValueArb } from './primitive/ints/int_arb'; import { Int8ValueArb } from './primitive/ints/int8_arb'; import { Int16ValueArb } from './primitive/ints/int16_arb'; @@ -45,10 +51,17 @@ export type CandidValues = { valueLiteral: string; }; +export interface CandidValueConstraints + extends TextConstraints, + Float32Constraints, + Float64Constraints { + depthLevel?: number; +} + export function CandidValueArb( candidTypeMeta: CandidDefinition, recursiveShapes: RecursiveShapes, - depthLevel: number + constraints: CandidValueConstraints ): fc.Arbitrary> { const candidType = candidTypeMeta.candidMeta.candidType; if (candidType === 'blob') { @@ -58,45 +71,45 @@ export function CandidValueArb( return OptValuesArb( candidTypeMeta as OptCandidDefinition, recursiveShapes, - depthLevel + constraints ); } if (candidType === 'Record') { return RecordValuesArb( candidTypeMeta as RecordCandidDefinition, recursiveShapes, - depthLevel + constraints ); } if (candidType === 'Tuple') { return TupleValuesArb( candidTypeMeta as TupleCandidDefinition, recursiveShapes, - depthLevel + constraints ); } if (candidType === 'Variant') { return VariantValuesArb( candidTypeMeta as VariantCandidDefinition, recursiveShapes, - depthLevel + constraints ); } if (candidType === 'Vec') { return VecValuesArb( candidTypeMeta as VecCandidDefinition, recursiveShapes, - depthLevel + constraints ); } if (candidType === 'bool') { return BoolValueArb(); } if (candidType === 'float32') { - return Float32ValueArb(); + return Float32ValueArb(undefined, undefined, constraints); } if (candidType === 'float64') { - return Float64ValueArb(); + return Float64ValueArb(undefined, undefined, constraints); } if (candidType === 'int') { return IntValueArb(); @@ -150,7 +163,7 @@ export function CandidValueArb( return RecursiveNameValuesArb( candidTypeMeta as RecursiveCandidName | RecursiveCandidDefinition, recursiveShapes, - depthLevel + constraints ); } throw new Error('Unreachable'); diff --git a/property_tests/arbitraries/candid/constructed/opt_arb/values_arb.ts b/property_tests/arbitraries/candid/constructed/opt_arb/values_arb.ts index d9b08a154e..b8f3b86580 100644 --- a/property_tests/arbitraries/candid/constructed/opt_arb/values_arb.ts +++ b/property_tests/arbitraries/candid/constructed/opt_arb/values_arb.ts @@ -2,22 +2,33 @@ import fc from 'fast-check'; import { Opt } from '.'; import { CorrespondingJSType } from '../../corresponding_js_type'; import { OptCandidDefinition } from '../../candid_definition_arb/types'; -import { CandidValues, CandidValueArb } from '../../candid_values_arb'; +import { + CandidValues, + CandidValueArb, + CandidValueConstraints +} from '../../candid_values_arb'; import { RecursiveShapes } from '../../recursive'; +import { DEFAULT_VALUE_MAX_DEPTH } from '../../../config'; type SomeOrNone = 'Some' | 'None'; export function OptValuesArb( optDefinition: OptCandidDefinition, recursiveShapes: RecursiveShapes, - depthLevel: number + constraints: CandidValueConstraints = { + depthLevel: DEFAULT_VALUE_MAX_DEPTH + } ): fc.Arbitrary> { + const depthLevel = constraints?.depthLevel ?? DEFAULT_VALUE_MAX_DEPTH; if (depthLevel < 1) { return fc.constant(generateNoneValue()); } const innerValue = fc.tuple( fc.constantFrom('Some', 'None') as fc.Arbitrary, - CandidValueArb(optDefinition.innerType, recursiveShapes, depthLevel - 1) + CandidValueArb(optDefinition.innerType, recursiveShapes, { + ...constraints, + depthLevel: depthLevel - 1 + }) ); return innerValue.map(([someOrNone, innerType]) => { diff --git a/property_tests/arbitraries/candid/constructed/record_arb/values_arb.ts b/property_tests/arbitraries/candid/constructed/record_arb/values_arb.ts index 1f728a63b1..1b54144a4d 100644 --- a/property_tests/arbitraries/candid/constructed/record_arb/values_arb.ts +++ b/property_tests/arbitraries/candid/constructed/record_arb/values_arb.ts @@ -1,9 +1,14 @@ import fc from 'fast-check'; import { Record } from './index'; import { RecordCandidDefinition } from '../../candid_definition_arb/types'; -import { CandidValues, CandidValueArb } from '../../candid_values_arb'; +import { + CandidValues, + CandidValueArb, + CandidValueConstraints +} from '../../candid_values_arb'; import { CorrespondingJSType } from '../../corresponding_js_type'; import { RecursiveShapes } from '../../recursive'; +import { DEFAULT_VALUE_MAX_DEPTH } from '../../../config'; type Field = [string, CandidValues]; type ArbField = [string, fc.Arbitrary>]; @@ -11,12 +16,16 @@ type ArbField = [string, fc.Arbitrary>]; export function RecordValuesArb( recordDefinition: RecordCandidDefinition, recursiveShapes: RecursiveShapes, - depthLevel: number + constraints?: CandidValueConstraints ): fc.Arbitrary> { + const depthLevel = constraints?.depthLevel ?? DEFAULT_VALUE_MAX_DEPTH; const fieldValues = recordDefinition.innerTypes.map(([name, innerType]) => { const result: ArbField = [ name, - CandidValueArb(innerType, recursiveShapes, depthLevel - 1) + CandidValueArb(innerType, recursiveShapes, { + ...constraints, + depthLevel: depthLevel - 1 + }) ]; return result; }); diff --git a/property_tests/arbitraries/candid/constructed/tuple_arb/values_arbs.ts b/property_tests/arbitraries/candid/constructed/tuple_arb/values_arbs.ts index bb70610ca0..7ff3a25626 100644 --- a/property_tests/arbitraries/candid/constructed/tuple_arb/values_arbs.ts +++ b/property_tests/arbitraries/candid/constructed/tuple_arb/values_arbs.ts @@ -2,17 +2,26 @@ import fc from 'fast-check'; import { Tuple, ReturnTuple } from '.'; import { CorrespondingJSType } from '../../corresponding_js_type'; import { TupleCandidDefinition } from '../../candid_definition_arb/types'; -import { CandidValues, CandidValueArb } from '../../candid_values_arb'; +import { + CandidValues, + CandidValueArb, + CandidValueConstraints +} from '../../candid_values_arb'; import { RecursiveShapes } from '../../recursive'; +import { DEFAULT_VALUE_MAX_DEPTH } from '../../../config'; export function TupleValuesArb( tupleDefinition: TupleCandidDefinition, recursiveShapes: RecursiveShapes, - depthLevel: number + constraints?: CandidValueConstraints ): fc.Arbitrary> { + const depthLevel = constraints?.depthLevel ?? DEFAULT_VALUE_MAX_DEPTH; const fieldValues = tupleDefinition.innerTypes.map((innerType) => { const result: fc.Arbitrary> = - CandidValueArb(innerType, recursiveShapes, depthLevel - 1); + CandidValueArb(innerType, recursiveShapes, { + ...constraints, + depthLevel: depthLevel - 1 + }); return result; }); diff --git a/property_tests/arbitraries/candid/constructed/variant_arb/values_arb.ts b/property_tests/arbitraries/candid/constructed/variant_arb/values_arb.ts index c63a642634..613ab7e6ad 100644 --- a/property_tests/arbitraries/candid/constructed/variant_arb/values_arb.ts +++ b/property_tests/arbitraries/candid/constructed/variant_arb/values_arb.ts @@ -1,17 +1,23 @@ import fc from 'fast-check'; import { Variant } from '.'; import { VariantCandidDefinition } from '../../candid_definition_arb/types'; -import { CandidValues, CandidValueArb } from '../../candid_values_arb'; +import { + CandidValues, + CandidValueArb, + CandidValueConstraints +} from '../../candid_values_arb'; import { CorrespondingJSType } from '../../corresponding_js_type'; import { RecursiveShapes } from '../../recursive'; +import { DEFAULT_VALUE_MAX_DEPTH } from '../../../config'; type Field = [string, CandidValues]; export function VariantValuesArb( variantDefinition: VariantCandidDefinition, recursiveShapes: RecursiveShapes, - depthLevel: number + constraints?: CandidValueConstraints ): fc.Arbitrary> { + const depthLevel = constraints?.depthLevel ?? DEFAULT_VALUE_MAX_DEPTH; return fc .nat(depthLevel < 1 ? 0 : variantDefinition.innerTypes.length - 1) .chain((randomIndex) => { @@ -25,11 +31,10 @@ export function VariantValuesArb( const [name, innerType] = variantDefinition.innerTypes[randomIndex]; - const fieldValues = CandidValueArb( - innerType, - recursiveShapes, - depthLevel - 1 - ).map((values): Field => { + const fieldValues = CandidValueArb(innerType, recursiveShapes, { + ...constraints, + depthLevel: depthLevel - 1 + }).map((values): Field => { return [name, values]; }); diff --git a/property_tests/arbitraries/candid/constructed/vec_arb/values_arb.ts b/property_tests/arbitraries/candid/constructed/vec_arb/values_arb.ts index 1273433097..80bda3b580 100644 --- a/property_tests/arbitraries/candid/constructed/vec_arb/values_arb.ts +++ b/property_tests/arbitraries/candid/constructed/vec_arb/values_arb.ts @@ -10,8 +10,13 @@ import { VariantCandidDefinition, VecCandidDefinition } from '../../candid_definition_arb/types'; -import { CandidValues, CandidValueArb } from '../../candid_values_arb'; +import { + CandidValues, + CandidValueArb, + CandidValueConstraints +} from '../../candid_values_arb'; import { RecursiveShapes } from '../../recursive'; +import { DEFAULT_VALUE_MAX_DEPTH } from '../../../config'; /* https://github.com/dfinity/candid/blob/491969f34dd791e51f69c5f8d3c6192ae405b839/spec/Candid.md#memory @@ -24,8 +29,11 @@ const EMPTYISH_VEC_SIZE_LIMIT = 0; export function VecValuesArb( vecDefinition: VecCandidDefinition, recursiveShapes: RecursiveShapes, - depthLevel: number + constraints: CandidValueConstraints = { + depthLevel: DEFAULT_VALUE_MAX_DEPTH + } ): fc.Arbitrary> { + const depthLevel = constraints.depthLevel ?? DEFAULT_VALUE_MAX_DEPTH; if (depthLevel < 1) { return fc.constant( generateEmptyVec(vecDefinition.innerType.candidMeta.candidType) @@ -39,7 +47,10 @@ export function VecValuesArb( .chain(([arrayTemplate, innerType]) => fc.tuple( ...arrayTemplate.map(() => - CandidValueArb(innerType, recursiveShapes, depthLevel - 1) + CandidValueArb(innerType, recursiveShapes, { + ...constraints, + depthLevel: depthLevel - 1 + }) ) ) ); diff --git a/property_tests/arbitraries/candid/primitive/floats/float32_arb.ts b/property_tests/arbitraries/candid/primitive/floats/float32_arb.ts index e16c06bd67..e31a551c74 100644 --- a/property_tests/arbitraries/candid/primitive/floats/float32_arb.ts +++ b/property_tests/arbitraries/candid/primitive/floats/float32_arb.ts @@ -1,4 +1,4 @@ -import fc, { sample } from 'fast-check'; +import fc from 'fast-check'; import { floatToSrcLiteral } from '../../to_src_literal/float'; import { SimpleCandidDefinitionArb } from '../../simple_type_arbs/definition_arb'; import { SimpleCandidValuesArb } from '../../simple_type_arbs/values_arb'; @@ -9,11 +9,19 @@ import { WithShapesArb } from '../../candid_definition_arb/types'; import { CandidValues } from '../../candid_values_arb'; +import { RecursiveShapes } from '../../recursive'; -export function Float32Arb(): fc.Arbitrary> { +export interface Float32Constraints extends fc.Float32ArrayConstraints { + noNegativeZero?: boolean; +} + +export function Float32Arb( + constraints?: Float32Constraints +): fc.Arbitrary> { return CandidValueAndMetaArbGenerator( Float32DefinitionArb(), - Float32ValueArb + Float32ValueArb, + constraints ); } @@ -21,15 +29,21 @@ export function Float32DefinitionArb(): WithShapesArb { return SimpleCandidDefinitionArb('float32'); } -// TODO multiplying by zero is to remove -0 -// TODO we should open an issue with agent-js -// TODO the agent should encode and decode -0 correctly -export function Float32ValueArb(): fc.Arbitrary> { - return SimpleCandidValuesArb(float32(), floatToSrcLiteral); +export function Float32ValueArb( + _?: FloatCandidDefinition, + _recShapes?: RecursiveShapes, + constraints?: C +): fc.Arbitrary> { + return SimpleCandidValuesArb(float32(constraints), floatToSrcLiteral); } -function float32(): fc.Arbitrary { +function float32(constraints?: Float32Constraints): fc.Arbitrary { return fc - .float32Array({ maxLength: 1, minLength: 1 }) - .map((sample) => (sample[0] === 0 ? sample[0] * 0 : sample[0])); + .float32Array({ ...constraints, maxLength: 1, minLength: 1 }) + .map((sample) => { + if (constraints?.noNegativeZero) { + return sample[0] === 0 ? 0 : sample[0]; + } + return sample[0]; + }); } diff --git a/property_tests/arbitraries/candid/primitive/floats/float64_arb.ts b/property_tests/arbitraries/candid/primitive/floats/float64_arb.ts index f06ddf16bf..ec3d765a0f 100644 --- a/property_tests/arbitraries/candid/primitive/floats/float64_arb.ts +++ b/property_tests/arbitraries/candid/primitive/floats/float64_arb.ts @@ -9,6 +9,11 @@ import { } from '../../candid_definition_arb/types'; import { CandidValues } from '../../candid_values_arb'; import { CandidValueAndMeta } from '../../candid_value_and_meta_arb'; +import { RecursiveShapes } from '../../recursive'; + +export interface Float64Constraints extends fc.Float64ArrayConstraints { + noNegativeZero?: boolean; +} export function Float64Arb(): fc.Arbitrary> { return CandidValueAndMetaArbGenerator( @@ -21,15 +26,21 @@ export function Float64DefinitionArb(): WithShapesArb { return SimpleCandidDefinitionArb('float64'); } -export function Float64ValueArb(): fc.Arbitrary> { - return SimpleCandidValuesArb(float64(), floatToSrcLiteral); +export function Float64ValueArb( + _?: FloatCandidDefinition, + _recShapes?: RecursiveShapes, + constraints?: C +): fc.Arbitrary> { + return SimpleCandidValuesArb(float64(constraints), floatToSrcLiteral); } -// TODO multiplying by zero is to remove -0 -// TODO we should open an issue with agent-js -// TODO the agent should encode and decode -0 correctly -function float64(): fc.Arbitrary { +function float64(constraints?: Float64Constraints): fc.Arbitrary { return fc - .float64Array({ maxLength: 1, minLength: 1 }) - .map((sample) => (sample[0] === 0 ? sample[0] * 0 : sample[0])); + .float64Array({ ...constraints, maxLength: 1, minLength: 1 }) + .map((sample) => { + if (constraints?.noNegativeZero) { + return sample[0] === 0 ? 0 : sample[0]; + } + return sample[0]; + }); } diff --git a/property_tests/arbitraries/candid/recursive/values_arb.ts b/property_tests/arbitraries/candid/recursive/values_arb.ts index a819f93897..132bb50aeb 100644 --- a/property_tests/arbitraries/candid/recursive/values_arb.ts +++ b/property_tests/arbitraries/candid/recursive/values_arb.ts @@ -4,21 +4,32 @@ import { RecursiveCandidName, RecursiveCandidDefinition } from '../candid_definition_arb/types'; -import { CandidValues, CandidValueArb } from '../candid_values_arb'; +import { + CandidValues, + CandidValueArb, + CandidValueConstraints +} from '../candid_values_arb'; +import { DEFAULT_VALUE_MAX_DEPTH } from '../../config'; export function RecursiveNameValuesArb( recDefinition: RecursiveCandidName | RecursiveCandidDefinition, recursiveShapes: RecursiveShapes, - depthLevel: number + constraints: CandidValueConstraints ): fc.Arbitrary> { const recShape = recursiveShapes[recDefinition.name]; - return RecursiveValuesArb(recShape, recursiveShapes, depthLevel); + return RecursiveValuesArb(recShape, recursiveShapes, constraints); } export function RecursiveValuesArb( recDefinition: RecursiveCandidDefinition, recursiveShapes: RecursiveShapes, - depthLevel: number + constraints: CandidValueConstraints = { + depthLevel: DEFAULT_VALUE_MAX_DEPTH + } ): fc.Arbitrary> { - return CandidValueArb(recDefinition.innerType, recursiveShapes, depthLevel); + return CandidValueArb( + recDefinition.innerType, + recursiveShapes, + constraints + ); } diff --git a/property_tests/arbitraries/canister_arb.ts b/property_tests/arbitraries/canister_arb.ts index 4a438b984a..c5ff815277 100644 --- a/property_tests/arbitraries/canister_arb.ts +++ b/property_tests/arbitraries/canister_arb.ts @@ -3,6 +3,7 @@ import { QueryMethod } from './canister_methods/query_method_arb'; import { Test } from '../../test'; import { UpdateMethod } from './canister_methods/update_method_arb'; import { InitMethod } from './canister_methods/init_method_arb'; +import { PostUpgradeMethod } from './canister_methods/post_upgrade_arb'; import { CorrespondingJSType } from './candid/corresponding_js_type'; import { TextClass, FloatClass } from '@dfinity/candid/lib/cjs/idl'; @@ -23,17 +24,31 @@ FloatClass.prototype.valueToString = (x): string => { }; export type Canister = { - deployArgs: string[] | undefined; + initArgs: string[] | undefined; + postUpgradeArgs: string[] | undefined; sourceCode: string; tests: Test[][]; }; +export type CanisterMethod< + ParamAgentArgumentValue extends CorrespondingJSType, + ParamAgentResponseValue +> = + | QueryMethod + | UpdateMethod + | InitMethod + | PostUpgradeMethod; + export type CanisterConfig< ParamAgentArgumentValue extends CorrespondingJSType = undefined, ParamAgentResponseValue = undefined > = { globalDeclarations?: string[]; initMethod?: InitMethod; + postUpgradeMethod?: PostUpgradeMethod< + ParamAgentArgumentValue, + ParamAgentResponseValue + >; queryMethods?: QueryMethod[]; updateMethods?: UpdateMethod[]; }; @@ -48,18 +63,26 @@ export function CanisterArb< > ) { return configArb.map((config): Canister => { - const canisterMethods: ( - | QueryMethod - | UpdateMethod - | InitMethod - )[] = [ + const canisterMethods: CanisterMethod< + ParamAgentArgumentValue, + ParamAgentResponseValue + >[] = [ ...(config.initMethod ? [config.initMethod] : []), + ...(config.postUpgradeMethod ? [config.postUpgradeMethod] : []), ...(config.queryMethods ?? []), ...(config.updateMethods ?? []) ]; - const deployArgs = config.initMethod?.params.map( - ({ value: { value } }) => { + const initArgs = config.initMethod?.params.map((param) => { + const value = param.value.value; + return value.runtimeCandidTypeObject + .getIdl([]) + .valueToString(value.agentArgumentValue); + }); + + const postUpgradeArgs = config.postUpgradeMethod?.params.map( + (param) => { + const value = param.value.value; return value.runtimeCandidTypeObject .getIdl([]) .valueToString(value.agentArgumentValue); @@ -95,7 +118,8 @@ export function CanisterArb< ); return { - deployArgs, + initArgs, + postUpgradeArgs, sourceCode, tests }; @@ -107,14 +131,10 @@ function generateSourceCode( canisterMethods: (UpdateMethod | QueryMethod)[] ) { const imports = [ - ...new Set( - canisterMethods.reduce( - (acc, method) => { - return [...acc, ...method.imports]; - }, - ['Canister', 'query', 'update'] - ) - ) + ...new Set([ + 'Canister', + ...canisterMethods.flatMap((method) => [...method.imports]) + ]) ] .sort((a, b) => a.localeCompare(b, 'en', { sensitivity: 'base' })) .join(); @@ -124,8 +144,7 @@ function generateSourceCode( ); const declarations = [ - ...globalDeclarations, - ...declarationsFromCanisterMethods + ...new Set([...globalDeclarations, ...declarationsFromCanisterMethods]) ].join('\n'); const sourceCodes = canisterMethods.map((method) => method.sourceCode); 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 new file mode 100644 index 0000000000..1c30e75885 --- /dev/null +++ b/property_tests/arbitraries/canister_methods/post_upgrade_arb.ts @@ -0,0 +1,141 @@ +import fc from 'fast-check'; + +import { CandidValueAndMeta } from '../candid/candid_value_and_meta_arb'; +import { CorrespondingJSType } from '../candid/corresponding_js_type'; +import { UniqueIdentifierArb } from '../unique_identifier_arb'; +import { Named } from '../..'; +import { + BodyGenerator, + TestsGenerator, + CallbackLocation, + isDefined, + generateCallback +} from '.'; +import { Test } from '../../../test'; +import { VoidArb } from '../candid/primitive/void'; + +export type PostUpgradeMethod< + ParamAgentArgumentValue extends CorrespondingJSType, + ParamAgentResponseValue +> = { + imports: Set; + globalDeclarations: string[]; + params: Named< + CandidValueAndMeta + >[]; + sourceCode: string; + tests: Test[][]; +}; + +export function PostUpgradeMethodArb< + ParamAgentArgumentValue extends CorrespondingJSType, + ParamAgentResponseValue +>( + paramTypeArrayArb: fc.Arbitrary< + CandidValueAndMeta[] + >, + constraints: { + generateBody: BodyGenerator< + ParamAgentArgumentValue, + ParamAgentResponseValue + >; + generateTests: TestsGenerator< + ParamAgentArgumentValue, + ParamAgentResponseValue + >; + callbackLocation?: CallbackLocation; + } +): fc.Arbitrary< + PostUpgradeMethod +> { + return fc + .tuple( + UniqueIdentifierArb('canisterMethod'), + paramTypeArrayArb, + VoidArb(), + 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 + // that for now. + ) + .map( + ([ + functionName, + paramTypes, + returnType, + defaultCallbackLocation, + callbackName + ]): PostUpgradeMethod< + ParamAgentArgumentValue, + ParamAgentResponseValue + > => { + const callbackLocation = + constraints.callbackLocation ?? defaultCallbackLocation; + + const imports = new Set([ + 'postUpgrade', + ...paramTypes.flatMap((param) => [...param.src.imports]) + ]); + + const namedParams = paramTypes.map( + (param: T, index: number): Named => ({ + name: `param${index}`, + value: param + }) + ); + + const callback = generateCallback( + namedParams, + returnType, + constraints.generateBody, + callbackLocation, + callbackName + ); + + const variableAliasDeclarations = paramTypes + .flatMap((param) => param.src.variableAliasDeclarations) + .filter(isDefined); + + const globalDeclarations = + callbackLocation === 'STANDALONE' + ? [...variableAliasDeclarations, callback] + : variableAliasDeclarations; + + const sourceCode = generateSourceCode( + functionName, + paramTypes, + callbackLocation === 'STANDALONE' ? callbackName : callback + ); + + const tests = constraints.generateTests( + functionName, + namedParams, + returnType + ); + + return { + imports, + globalDeclarations, + params: namedParams, + sourceCode, + tests + }; + } + ); +} + +function generateSourceCode< + ParamType extends CorrespondingJSType, + ParamAgentType +>( + functionName: string, + paramTypes: CandidValueAndMeta[], + callback: string +): string { + const paramCandidTypeObjects = paramTypes + .map((param) => param.src.candidTypeObject) + .join(', '); + + return `${functionName}: postUpgrade([${paramCandidTypeObjects}], ${callback})`; +} diff --git a/property_tests/arbitraries/canister_methods/query_method_arb.ts b/property_tests/arbitraries/canister_methods/query_method_arb.ts index d6e18900af..7f67c6c051 100644 --- a/property_tests/arbitraries/canister_methods/query_method_arb.ts +++ b/property_tests/arbitraries/canister_methods/query_method_arb.ts @@ -78,6 +78,7 @@ export function QueryMethodArb< constraints.callbackLocation ?? defaultCallbackLocation; const imports = new Set([ + 'query', ...paramTypes.flatMap((param) => [...param.src.imports]), ...returnType.src.imports ]); diff --git a/property_tests/arbitraries/canister_methods/update_method_arb.ts b/property_tests/arbitraries/canister_methods/update_method_arb.ts index 633eb4d59f..11fa0244de 100644 --- a/property_tests/arbitraries/canister_methods/update_method_arb.ts +++ b/property_tests/arbitraries/canister_methods/update_method_arb.ts @@ -79,6 +79,7 @@ export function UpdateMethodArb< constraints.callbackLocation ?? defaultCallbackLocation; const imports = new Set([ + 'update', ...paramTypes.flatMap((param) => [...param.src.imports]), ...returnType.src.imports ]); diff --git a/property_tests/are_params_correctly_ordered.ts b/property_tests/are_params_correctly_ordered.ts index 7fec6a500d..fec852875e 100644 --- a/property_tests/are_params_correctly_ordered.ts +++ b/property_tests/are_params_correctly_ordered.ts @@ -11,8 +11,7 @@ export function areParamsCorrectlyOrdered( ${name}, ${value.src.valueLiteral} )`; - - return `if (!${areEqual}) {console.log('value', ${name}); throw new Error('${name} is incorrectly ordered');}`; + return `if (!${areEqual}) {console.log('value', ${name}, 'expected', ${value.src.valueLiteral}); throw new Error('${name} is incorrectly ordered');}`; }) .join('\n'); } diff --git a/property_tests/index.ts b/property_tests/index.ts index 25b8f0da6e..4128720cbd 100644 --- a/property_tests/index.ts +++ b/property_tests/index.ts @@ -55,17 +55,21 @@ export async function runPropTests( }); for (let i = 0; i < canister.tests.length; i++) { + const args = + i === 0 + ? canister.initArgs + : canister.postUpgradeArgs; const argumentsString = - canister.deployArgs !== undefined && - canister.deployArgs.length > 0 - ? `--argument '(${canister.deployArgs.join( - ', ' - )})'` + args !== undefined && args.length > 0 + ? `--argument '(${args.join(', ')})'` : ''; - execSync(`dfx deploy canister ${argumentsString}`, { - stdio: 'inherit' - }); + execSync( + `dfx deploy canister ${argumentsString} --upgrade-unchanged`, + { + stdio: 'inherit' + } + ); execSync(`dfx generate canister`, { stdio: 'inherit' diff --git a/property_tests/tests/init_method/test/test.ts b/property_tests/tests/init_method/test/test.ts index 9ea7fa6a81..719c1b9681 100644 --- a/property_tests/tests/init_method/test/test.ts +++ b/property_tests/tests/init_method/test/test.ts @@ -96,7 +96,7 @@ function generateGetInitValuesCanisterMethod( globalInitVariableNames: string[] ): QueryMethod { return { - imports: new Set(['Tuple', 'bool']), + imports: new Set(['bool', 'query', 'Tuple']), globalDeclarations: [], sourceCode: /*TS*/ `getInitValues: query( [], diff --git a/property_tests/tests/post_upgrade_method/dfx.json b/property_tests/tests/post_upgrade_method/dfx.json new file mode 100644 index 0000000000..6ab9fbd7e4 --- /dev/null +++ b/property_tests/tests/post_upgrade_method/dfx.json @@ -0,0 +1,16 @@ +{ + "canisters": { + "canister": { + "type": "custom", + "main": "src/index.ts", + "candid": "src/index.did", + "build": "npx azle canister", + "wasm": ".azle/canister/canister.wasm", + "gzip": true, + "declarations": { + "output": "test/dfx_generated/canister", + "node_compatibility": true + } + } + } +} diff --git a/property_tests/tests/post_upgrade_method/package-lock.json b/property_tests/tests/post_upgrade_method/package-lock.json new file mode 100644 index 0000000000..708fcab575 --- /dev/null +++ b/property_tests/tests/post_upgrade_method/package-lock.json @@ -0,0 +1,996 @@ +{ + "name": "post_upgrade_method", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "dependencies": { + "azle": "^0.18.5" + }, + "devDependencies": { + "ts-node": "^10.9.1", + "typescript": "^5.2.2" + } + }, + "node_modules/@cspotcode/source-map-consumer": { + "version": "0.8.0", + "resolved": "https://registry.npmjs.org/@cspotcode/source-map-consumer/-/source-map-consumer-0.8.0.tgz", + "integrity": "sha512-41qniHzTU8yAGbCp04ohlmSrZf8bkf/iJsl3V0dRGsQN/5GFfx+LbCSsCpp2gqrqjTVg/K6O8ycoV35JIwAzAg==", + "engines": { + "node": ">= 12" + } + }, + "node_modules/@cspotcode/source-map-support": { + "version": "0.8.1", + "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz", + "integrity": "sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==", + "dev": true, + "dependencies": { + "@jridgewell/trace-mapping": "0.3.9" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/@dfinity/principal": { + "version": "0.19.3", + "resolved": "https://registry.npmjs.org/@dfinity/principal/-/principal-0.19.3.tgz", + "integrity": "sha512-+nixVvdGt7ECxRvLXDXsvU9q9sSPssBtDQ4bXa149SK6gcYcmZ6lfWIi3DJNqj3tGROxILVBsguel9tECappsA==", + "dependencies": { + "@noble/hashes": "^1.3.1" + } + }, + "node_modules/@esbuild/android-arm": { + "version": "0.19.5", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.19.5.tgz", + "integrity": "sha512-bhvbzWFF3CwMs5tbjf3ObfGqbl/17ict2/uwOSfr3wmxDE6VdS2GqY/FuzIPe0q0bdhj65zQsvqfArI9MY6+AA==", + "cpu": [ + "arm" + ], + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/android-arm64": { + "version": "0.19.5", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.19.5.tgz", + "integrity": "sha512-5d1OkoJxnYQfmC+Zd8NBFjkhyCNYwM4n9ODrycTFY6Jk1IGiZ+tjVJDDSwDt77nK+tfpGP4T50iMtVi4dEGzhQ==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/android-x64": { + "version": "0.19.5", + "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.19.5.tgz", + "integrity": "sha512-9t+28jHGL7uBdkBjL90QFxe7DVA+KGqWlHCF8ChTKyaKO//VLuoBricQCgwhOjA1/qOczsw843Fy4cbs4H3DVA==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/darwin-arm64": { + "version": "0.19.5", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.19.5.tgz", + "integrity": "sha512-mvXGcKqqIqyKoxq26qEDPHJuBYUA5KizJncKOAf9eJQez+L9O+KfvNFu6nl7SCZ/gFb2QPaRqqmG0doSWlgkqw==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/darwin-x64": { + "version": "0.19.5", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.19.5.tgz", + "integrity": "sha512-Ly8cn6fGLNet19s0X4unjcniX24I0RqjPv+kurpXabZYSXGM4Pwpmf85WHJN3lAgB8GSth7s5A0r856S+4DyiA==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/freebsd-arm64": { + "version": "0.19.5", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.19.5.tgz", + "integrity": "sha512-GGDNnPWTmWE+DMchq1W8Sd0mUkL+APvJg3b11klSGUDvRXh70JqLAO56tubmq1s2cgpVCSKYywEiKBfju8JztQ==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/freebsd-x64": { + "version": "0.19.5", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.19.5.tgz", + "integrity": "sha512-1CCwDHnSSoA0HNwdfoNY0jLfJpd7ygaLAp5EHFos3VWJCRX9DMwWODf96s9TSse39Br7oOTLryRVmBoFwXbuuQ==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-arm": { + "version": "0.19.5", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.19.5.tgz", + "integrity": "sha512-lrWXLY/vJBzCPC51QN0HM71uWgIEpGSjSZZADQhq7DKhPcI6NH1IdzjfHkDQws2oNpJKpR13kv7/pFHBbDQDwQ==", + "cpu": [ + "arm" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-arm64": { + "version": "0.19.5", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.19.5.tgz", + "integrity": "sha512-o3vYippBmSrjjQUCEEiTZ2l+4yC0pVJD/Dl57WfPwwlvFkrxoSO7rmBZFii6kQB3Wrn/6GwJUPLU5t52eq2meA==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-ia32": { + "version": "0.19.5", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.19.5.tgz", + "integrity": "sha512-MkjHXS03AXAkNp1KKkhSKPOCYztRtK+KXDNkBa6P78F8Bw0ynknCSClO/ztGszILZtyO/lVKpa7MolbBZ6oJtQ==", + "cpu": [ + "ia32" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-loong64": { + "version": "0.19.5", + "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.19.5.tgz", + "integrity": "sha512-42GwZMm5oYOD/JHqHska3Jg0r+XFb/fdZRX+WjADm3nLWLcIsN27YKtqxzQmGNJgu0AyXg4HtcSK9HuOk3v1Dw==", + "cpu": [ + "loong64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-mips64el": { + "version": "0.19.5", + "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.19.5.tgz", + "integrity": "sha512-kcjndCSMitUuPJobWCnwQ9lLjiLZUR3QLQmlgaBfMX23UEa7ZOrtufnRds+6WZtIS9HdTXqND4yH8NLoVVIkcg==", + "cpu": [ + "mips64el" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-ppc64": { + "version": "0.19.5", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.19.5.tgz", + "integrity": "sha512-yJAxJfHVm0ZbsiljbtFFP1BQKLc8kUF6+17tjQ78QjqjAQDnhULWiTA6u0FCDmYT1oOKS9PzZ2z0aBI+Mcyj7Q==", + "cpu": [ + "ppc64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-riscv64": { + "version": "0.19.5", + "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.19.5.tgz", + "integrity": "sha512-5u8cIR/t3gaD6ad3wNt1MNRstAZO+aNyBxu2We8X31bA8XUNyamTVQwLDA1SLoPCUehNCymhBhK3Qim1433Zag==", + "cpu": [ + "riscv64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-s390x": { + "version": "0.19.5", + "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.19.5.tgz", + "integrity": "sha512-Z6JrMyEw/EmZBD/OFEFpb+gao9xJ59ATsoTNlj39jVBbXqoZm4Xntu6wVmGPB/OATi1uk/DB+yeDPv2E8PqZGw==", + "cpu": [ + "s390x" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-x64": { + "version": "0.19.5", + "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.19.5.tgz", + "integrity": "sha512-psagl+2RlK1z8zWZOmVdImisMtrUxvwereIdyJTmtmHahJTKb64pAcqoPlx6CewPdvGvUKe2Jw+0Z/0qhSbG1A==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/netbsd-x64": { + "version": "0.19.5", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.19.5.tgz", + "integrity": "sha512-kL2l+xScnAy/E/3119OggX8SrWyBEcqAh8aOY1gr4gPvw76la2GlD4Ymf832UCVbmuWeTf2adkZDK+h0Z/fB4g==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/openbsd-x64": { + "version": "0.19.5", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.19.5.tgz", + "integrity": "sha512-sPOfhtzFufQfTBgRnE1DIJjzsXukKSvZxloZbkJDG383q0awVAq600pc1nfqBcl0ice/WN9p4qLc39WhBShRTA==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/sunos-x64": { + "version": "0.19.5", + "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.19.5.tgz", + "integrity": "sha512-dGZkBXaafuKLpDSjKcB0ax0FL36YXCvJNnztjKV+6CO82tTYVDSH2lifitJ29jxRMoUhgkg9a+VA/B03WK5lcg==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "sunos" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/win32-arm64": { + "version": "0.19.5", + "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.19.5.tgz", + "integrity": "sha512-dWVjD9y03ilhdRQ6Xig1NWNgfLtf2o/STKTS+eZuF90fI2BhbwD6WlaiCGKptlqXlURVB5AUOxUj09LuwKGDTg==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/win32-ia32": { + "version": "0.19.5", + "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.19.5.tgz", + "integrity": "sha512-4liggWIA4oDgUxqpZwrDhmEfAH4d0iljanDOK7AnVU89T6CzHon/ony8C5LeOdfgx60x5cnQJFZwEydVlYx4iw==", + "cpu": [ + "ia32" + ], + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/win32-x64": { + "version": "0.19.5", + "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.19.5.tgz", + "integrity": "sha512-czTrygUsB/jlM8qEW5MD8bgYU2Xg14lo6kBDXW6HdxKjh8M5PzETGiSHaz9MtbXBYDloHNUAUW2tMiKW4KM9Mw==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@jridgewell/resolve-uri": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.1.tgz", + "integrity": "sha512-dSYZh7HhCDtCKm4QakX0xFpsRDqjjtZf/kjI/v3T3Nwt5r8/qz/M19F9ySyOqU94SXBmeG9ttTul+YnR4LOxFA==", + "dev": true, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@jridgewell/sourcemap-codec": { + "version": "1.4.15", + "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.15.tgz", + "integrity": "sha512-eF2rxCRulEKXHTRiDrDy6erMYWqNw4LPdQ8UQA4huuxaQsVeRPFl2oM8oDGxMFhJUWZf9McpLtJasDDZb/Bpeg==", + "dev": true + }, + "node_modules/@jridgewell/trace-mapping": { + "version": "0.3.9", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.9.tgz", + "integrity": "sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==", + "dev": true, + "dependencies": { + "@jridgewell/resolve-uri": "^3.0.3", + "@jridgewell/sourcemap-codec": "^1.4.10" + } + }, + "node_modules/@noble/hashes": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.3.2.tgz", + "integrity": "sha512-MVC8EAQp7MvEcm30KWENFjgR+Mkmf+D189XJTkFIlwohU5hcBbn1ZkKq7KVTi2Hme3PMGF390DaL52beVrIihQ==", + "engines": { + "node": ">= 16" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, + "node_modules/@swc/core": { + "version": "1.3.93", + "resolved": "https://registry.npmjs.org/@swc/core/-/core-1.3.93.tgz", + "integrity": "sha512-690GRr1wUGmGYZHk7fUduX/JUwViMF2o74mnZYIWEcJaCcd9MQfkhsxPBtjeg6tF+h266/Cf3RPYhsFBzzxXcA==", + "hasInstallScript": true, + "dependencies": { + "@swc/counter": "^0.1.1", + "@swc/types": "^0.1.5" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/swc" + }, + "optionalDependencies": { + "@swc/core-darwin-arm64": "1.3.93", + "@swc/core-darwin-x64": "1.3.93", + "@swc/core-linux-arm-gnueabihf": "1.3.93", + "@swc/core-linux-arm64-gnu": "1.3.93", + "@swc/core-linux-arm64-musl": "1.3.93", + "@swc/core-linux-x64-gnu": "1.3.93", + "@swc/core-linux-x64-musl": "1.3.93", + "@swc/core-win32-arm64-msvc": "1.3.93", + "@swc/core-win32-ia32-msvc": "1.3.93", + "@swc/core-win32-x64-msvc": "1.3.93" + }, + "peerDependencies": { + "@swc/helpers": "^0.5.0" + }, + "peerDependenciesMeta": { + "@swc/helpers": { + "optional": true + } + } + }, + "node_modules/@swc/core-darwin-arm64": { + "version": "1.3.93", + "resolved": "https://registry.npmjs.org/@swc/core-darwin-arm64/-/core-darwin-arm64-1.3.93.tgz", + "integrity": "sha512-gEKgk7FVIgltnIfDO6GntyuQBBlAYg5imHpRgLxB1zSI27ijVVkksc6QwISzFZAhKYaBWIsFSVeL9AYSziAF7A==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/core-darwin-x64": { + "version": "1.3.93", + "resolved": "https://registry.npmjs.org/@swc/core-darwin-x64/-/core-darwin-x64-1.3.93.tgz", + "integrity": "sha512-ZQPxm/fXdDQtn3yrYSL/gFfA8OfZ5jTi33yFQq6vcg/Y8talpZ+MgdSlYM0FkLrZdMTYYTNFiuBQuuvkA+av+Q==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/core-linux-arm-gnueabihf": { + "version": "1.3.93", + "resolved": "https://registry.npmjs.org/@swc/core-linux-arm-gnueabihf/-/core-linux-arm-gnueabihf-1.3.93.tgz", + "integrity": "sha512-OYFMMI2yV+aNe3wMgYhODxHdqUB/jrK0SEMHHS44GZpk8MuBXEF+Mcz4qjkY5Q1EH7KVQqXb/gVWwdgTHpjM2A==", + "cpu": [ + "arm" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/core-linux-arm64-gnu": { + "version": "1.3.93", + "resolved": "https://registry.npmjs.org/@swc/core-linux-arm64-gnu/-/core-linux-arm64-gnu-1.3.93.tgz", + "integrity": "sha512-BT4dT78odKnJMNiq5HdjBsv29CiIdcCcImAPxeFqAeFw1LL6gh9nzI8E96oWc+0lVT5lfhoesCk4Qm7J6bty8w==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/core-linux-arm64-musl": { + "version": "1.3.93", + "resolved": "https://registry.npmjs.org/@swc/core-linux-arm64-musl/-/core-linux-arm64-musl-1.3.93.tgz", + "integrity": "sha512-yH5fWEl1bktouC0mhh0Chuxp7HEO4uCtS/ly1Vmf18gs6wZ8DOOkgAEVv2dNKIryy+Na++ljx4Ym7C8tSJTrLw==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/core-linux-x64-gnu": { + "version": "1.3.93", + "resolved": "https://registry.npmjs.org/@swc/core-linux-x64-gnu/-/core-linux-x64-gnu-1.3.93.tgz", + "integrity": "sha512-OFUdx64qvrGJhXKEyxosHxgoUVgba2ztYh7BnMiU5hP8lbI8G13W40J0SN3CmFQwPP30+3oEbW7LWzhKEaYjlg==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/core-linux-x64-musl": { + "version": "1.3.93", + "resolved": "https://registry.npmjs.org/@swc/core-linux-x64-musl/-/core-linux-x64-musl-1.3.93.tgz", + "integrity": "sha512-4B8lSRwEq1XYm6xhxHhvHmKAS7pUp1Q7E33NQ2TlmFhfKvCOh86qvThcjAOo57x8DRwmpvEVrqvpXtYagMN6Ig==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/core-win32-arm64-msvc": { + "version": "1.3.93", + "resolved": "https://registry.npmjs.org/@swc/core-win32-arm64-msvc/-/core-win32-arm64-msvc-1.3.93.tgz", + "integrity": "sha512-BHShlxtkven8ZjjvZ5QR6sC5fZCJ9bMujEkiha6W4cBUTY7ce7qGFyHmQd+iPC85d9kD/0cCiX/Xez8u0BhO7w==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/core-win32-ia32-msvc": { + "version": "1.3.93", + "resolved": "https://registry.npmjs.org/@swc/core-win32-ia32-msvc/-/core-win32-ia32-msvc-1.3.93.tgz", + "integrity": "sha512-nEwNWnz4JzYAK6asVvb92yeylfxMYih7eMQOnT7ZVlZN5ba9WF29xJ6kcQKs9HRH6MvWhz9+wRgv3FcjlU6HYA==", + "cpu": [ + "ia32" + ], + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/core-win32-x64-msvc": { + "version": "1.3.93", + "resolved": "https://registry.npmjs.org/@swc/core-win32-x64-msvc/-/core-win32-x64-msvc-1.3.93.tgz", + "integrity": "sha512-jibQ0zUr4kwJaQVwgmH+svS04bYTPnPw/ZkNInzxS+wFAtzINBYcU8s2PMWbDb2NGYiRSEeoSGyAvS9H+24JFA==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/counter": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/@swc/counter/-/counter-0.1.2.tgz", + "integrity": "sha512-9F4ys4C74eSTEUNndnER3VJ15oru2NumfQxS8geE+f3eB5xvfxpWyqE5XlVnxb/R14uoXi6SLbBwwiDSkv+XEw==" + }, + "node_modules/@swc/types": { + "version": "0.1.5", + "resolved": "https://registry.npmjs.org/@swc/types/-/types-0.1.5.tgz", + "integrity": "sha512-myfUej5naTBWnqOCc/MdVOLVjXUXtIA+NpDrDBKJtLLg2shUjBu3cZmB/85RyitKc55+lUUyl7oRfLOvkr2hsw==" + }, + "node_modules/@tsconfig/node10": { + "version": "1.0.9", + "resolved": "https://registry.npmjs.org/@tsconfig/node10/-/node10-1.0.9.tgz", + "integrity": "sha512-jNsYVVxU8v5g43Erja32laIDHXeoNvFEpX33OK4d6hljo3jDhCBDhx5dhCCTMWUojscpAagGiRkBKxpdl9fxqA==" + }, + "node_modules/@tsconfig/node12": { + "version": "1.0.11", + "resolved": "https://registry.npmjs.org/@tsconfig/node12/-/node12-1.0.11.tgz", + "integrity": "sha512-cqefuRsh12pWyGsIoBKJA9luFu3mRxCA+ORZvA4ktLSzIuCUtWVxGIuXigEwO5/ywWFMZ2QEGKWvkZG1zDMTag==" + }, + "node_modules/@tsconfig/node14": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/@tsconfig/node14/-/node14-1.0.3.tgz", + "integrity": "sha512-ysT8mhdixWK6Hw3i1V2AeRqZ5WfXg1G43mqoYlM2nc6388Fq5jcXyr5mRsqViLx/GJYdoL0bfXD8nmF+Zn/Iow==" + }, + "node_modules/@tsconfig/node16": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/@tsconfig/node16/-/node16-1.0.4.tgz", + "integrity": "sha512-vxhUy4J8lyeyinH7Azl1pdd43GJhZH/tP2weN8TntQblOY+A0XbT8DJk1/oCPuOOyg/Ja757rG0CgHcWC8OfMA==" + }, + "node_modules/@types/node": { + "version": "20.8.7", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.8.7.tgz", + "integrity": "sha512-21TKHHh3eUHIi2MloeptJWALuCu5H7HQTdTrWIFReA8ad+aggoX+lRes3ex7/FtpC+sVUpFMQ+QTfYr74mruiQ==", + "peer": true, + "dependencies": { + "undici-types": "~5.25.1" + } + }, + "node_modules/@types/uuid": { + "version": "9.0.6", + "resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-9.0.6.tgz", + "integrity": "sha512-BT2Krtx4xaO6iwzwMFUYvWBWkV2pr37zD68Vmp1CDV196MzczBRxuEpD6Pr395HAgebC/co7hOphs53r8V7jew==" + }, + "node_modules/acorn": { + "version": "8.10.0", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.10.0.tgz", + "integrity": "sha512-F0SAmZ8iUtS//m8DmCTA0jlh6TDKkHQyK6xc6V4KDTyZKA9dnvX9/3sRTVQrWm79glUAZbnmmNcdYwUIHWVybw==", + "bin": { + "acorn": "bin/acorn" + }, + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/acorn-walk": { + "version": "8.2.0", + "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.2.0.tgz", + "integrity": "sha512-k+iyHEuPgSw6SbuDpGQM+06HQUa04DZ3o+F6CSzXMvvI5KMvnaEqXe+YVe555R9nn6GPt404fos4wcgpw12SDA==", + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/arg": { + "version": "4.1.3", + "resolved": "https://registry.npmjs.org/arg/-/arg-4.1.3.tgz", + "integrity": "sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA==" + }, + "node_modules/azle": { + "version": "0.18.5", + "resolved": "https://registry.npmjs.org/azle/-/azle-0.18.5.tgz", + "integrity": "sha512-9lLhVKwexVCd8OOYMXgjk06L+Mu0q29Rpchmz07HYV6idwF5kg+8QCxzytpU9GpnUeoADTQNkEkyLABtkd2hCA==", + "dependencies": { + "@dfinity/candid": "github:demergent-labs/candid#minimum_viable", + "@dfinity/principal": "^0.19.0", + "@swc/core": "^1.3.86", + "@types/uuid": "^9.0.4", + "buffer": "^6.0.3", + "esbuild": "^0.19.3", + "fs-extra": "10.0.1", + "js-sha256": "0.9.0", + "text-encoding": "0.7.0", + "ts-node": "10.3.1", + "typescript": "^5.2.2", + "uuid": "^9.0.1" + }, + "bin": { + "azle": "bin.js" + } + }, + "node_modules/azle/node_modules/@cspotcode/source-map-support": { + "version": "0.7.0", + "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.7.0.tgz", + "integrity": "sha512-X4xqRHqN8ACt2aHVe51OxeA2HjbcL4MqFqXkrmQszJ1NOUuUu5u6Vqx/0lZSVNku7velL5FC/s5uEAj1lsBMhA==", + "dependencies": { + "@cspotcode/source-map-consumer": "0.8.0" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/azle/node_modules/@dfinity/candid": { + "version": "0.19.2", + "resolved": "git+ssh://git@github.com/demergent-labs/candid.git#5797fa906b1a7cc30c161dbb0eb919283ce2f80d", + "license": "Apache-2.0", + "peerDependencies": { + "@dfinity/principal": "^0.19.2" + } + }, + "node_modules/azle/node_modules/ts-node": { + "version": "10.3.1", + "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.3.1.tgz", + "integrity": "sha512-Yw3W2mYzhHfCHOICGNJqa0i+rbL0rAyg7ZIHxU+K4pgY8gd2Lh1j+XbHCusJMykbj6RZMJVOY0MlHVd+GOivcw==", + "dependencies": { + "@cspotcode/source-map-support": "0.7.0", + "@tsconfig/node10": "^1.0.7", + "@tsconfig/node12": "^1.0.7", + "@tsconfig/node14": "^1.0.0", + "@tsconfig/node16": "^1.0.2", + "acorn": "^8.4.1", + "acorn-walk": "^8.1.1", + "arg": "^4.1.0", + "create-require": "^1.1.0", + "diff": "^4.0.1", + "make-error": "^1.1.1", + "yn": "3.1.1" + }, + "bin": { + "ts-node": "dist/bin.js", + "ts-node-cwd": "dist/bin-cwd.js", + "ts-node-script": "dist/bin-script.js", + "ts-node-transpile-only": "dist/bin-transpile.js", + "ts-script": "dist/bin-script-deprecated.js" + }, + "peerDependencies": { + "@swc/core": ">=1.2.50", + "@swc/wasm": ">=1.2.50", + "@types/node": "*", + "typescript": ">=2.7" + }, + "peerDependenciesMeta": { + "@swc/core": { + "optional": true + }, + "@swc/wasm": { + "optional": true + } + } + }, + "node_modules/base64-js": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz", + "integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] + }, + "node_modules/buffer": { + "version": "6.0.3", + "resolved": "https://registry.npmjs.org/buffer/-/buffer-6.0.3.tgz", + "integrity": "sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "dependencies": { + "base64-js": "^1.3.1", + "ieee754": "^1.2.1" + } + }, + "node_modules/create-require": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/create-require/-/create-require-1.1.1.tgz", + "integrity": "sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==" + }, + "node_modules/diff": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz", + "integrity": "sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==", + "engines": { + "node": ">=0.3.1" + } + }, + "node_modules/esbuild": { + "version": "0.19.5", + "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.19.5.tgz", + "integrity": "sha512-bUxalY7b1g8vNhQKdB24QDmHeY4V4tw/s6Ak5z+jJX9laP5MoQseTOMemAr0gxssjNcH0MCViG8ONI2kksvfFQ==", + "hasInstallScript": true, + "bin": { + "esbuild": "bin/esbuild" + }, + "engines": { + "node": ">=12" + }, + "optionalDependencies": { + "@esbuild/android-arm": "0.19.5", + "@esbuild/android-arm64": "0.19.5", + "@esbuild/android-x64": "0.19.5", + "@esbuild/darwin-arm64": "0.19.5", + "@esbuild/darwin-x64": "0.19.5", + "@esbuild/freebsd-arm64": "0.19.5", + "@esbuild/freebsd-x64": "0.19.5", + "@esbuild/linux-arm": "0.19.5", + "@esbuild/linux-arm64": "0.19.5", + "@esbuild/linux-ia32": "0.19.5", + "@esbuild/linux-loong64": "0.19.5", + "@esbuild/linux-mips64el": "0.19.5", + "@esbuild/linux-ppc64": "0.19.5", + "@esbuild/linux-riscv64": "0.19.5", + "@esbuild/linux-s390x": "0.19.5", + "@esbuild/linux-x64": "0.19.5", + "@esbuild/netbsd-x64": "0.19.5", + "@esbuild/openbsd-x64": "0.19.5", + "@esbuild/sunos-x64": "0.19.5", + "@esbuild/win32-arm64": "0.19.5", + "@esbuild/win32-ia32": "0.19.5", + "@esbuild/win32-x64": "0.19.5" + } + }, + "node_modules/fs-extra": { + "version": "10.0.1", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-10.0.1.tgz", + "integrity": "sha512-NbdoVMZso2Lsrn/QwLXOy6rm0ufY2zEOKCDzJR/0kBsb0E6qed0P3iYK+Ath3BfvXEeu4JhEtXLgILx5psUfag==", + "dependencies": { + "graceful-fs": "^4.2.0", + "jsonfile": "^6.0.1", + "universalify": "^2.0.0" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/graceful-fs": { + "version": "4.2.11", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz", + "integrity": "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==" + }, + "node_modules/ieee754": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz", + "integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] + }, + "node_modules/js-sha256": { + "version": "0.9.0", + "resolved": "https://registry.npmjs.org/js-sha256/-/js-sha256-0.9.0.tgz", + "integrity": "sha512-sga3MHh9sgQN2+pJ9VYZ+1LPwXOxuBJBA5nrR5/ofPfuiJBE2hnjsaN8se8JznOmGLN2p49Pe5U/ttafcs/apA==" + }, + "node_modules/jsonfile": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.1.0.tgz", + "integrity": "sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ==", + "dependencies": { + "universalify": "^2.0.0" + }, + "optionalDependencies": { + "graceful-fs": "^4.1.6" + } + }, + "node_modules/make-error": { + "version": "1.3.6", + "resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.6.tgz", + "integrity": "sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==" + }, + "node_modules/text-encoding": { + "version": "0.7.0", + "resolved": "https://registry.npmjs.org/text-encoding/-/text-encoding-0.7.0.tgz", + "integrity": "sha512-oJQ3f1hrOnbRLOcwKz0Liq2IcrvDeZRHXhd9RgLrsT+DjWY/nty1Hi7v3dtkaEYbPYe0mUoOfzRrMwfXXwgPUA==", + "deprecated": "no longer maintained" + }, + "node_modules/ts-node": { + "version": "10.9.1", + "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.9.1.tgz", + "integrity": "sha512-NtVysVPkxxrwFGUUxGYhfux8k78pQB3JqYBXlLRZgdGUqTO5wU/UyHop5p70iEbGhB7q5KmiZiU0Y3KlJrScEw==", + "dev": true, + "dependencies": { + "@cspotcode/source-map-support": "^0.8.0", + "@tsconfig/node10": "^1.0.7", + "@tsconfig/node12": "^1.0.7", + "@tsconfig/node14": "^1.0.0", + "@tsconfig/node16": "^1.0.2", + "acorn": "^8.4.1", + "acorn-walk": "^8.1.1", + "arg": "^4.1.0", + "create-require": "^1.1.0", + "diff": "^4.0.1", + "make-error": "^1.1.1", + "v8-compile-cache-lib": "^3.0.1", + "yn": "3.1.1" + }, + "bin": { + "ts-node": "dist/bin.js", + "ts-node-cwd": "dist/bin-cwd.js", + "ts-node-esm": "dist/bin-esm.js", + "ts-node-script": "dist/bin-script.js", + "ts-node-transpile-only": "dist/bin-transpile.js", + "ts-script": "dist/bin-script-deprecated.js" + }, + "peerDependencies": { + "@swc/core": ">=1.2.50", + "@swc/wasm": ">=1.2.50", + "@types/node": "*", + "typescript": ">=2.7" + }, + "peerDependenciesMeta": { + "@swc/core": { + "optional": true + }, + "@swc/wasm": { + "optional": true + } + } + }, + "node_modules/typescript": { + "version": "5.2.2", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.2.2.tgz", + "integrity": "sha512-mI4WrpHsbCIcwT9cF4FZvr80QUeKvsUsUvKDoR+X/7XHQH98xYD8YHZg7ANtz2GtZt/CBq2QJ0thkGJMHfqc1w==", + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=14.17" + } + }, + "node_modules/undici-types": { + "version": "5.25.3", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.25.3.tgz", + "integrity": "sha512-Ga1jfYwRn7+cP9v8auvEXN1rX3sWqlayd4HP7OKk4mZWylEmu3KzXDUGrQUN6Ol7qo1gPvB2e5gX6udnyEPgdA==", + "peer": true + }, + "node_modules/universalify": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.0.tgz", + "integrity": "sha512-hAZsKq7Yy11Zu1DE0OzWjw7nnLZmJZYTDZZyEFHZdUhV8FkH5MCfoU1XMaxXovpyW5nq5scPqq0ZDP9Zyl04oQ==", + "engines": { + "node": ">= 10.0.0" + } + }, + "node_modules/uuid": { + "version": "9.0.1", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-9.0.1.tgz", + "integrity": "sha512-b+1eJOlsR9K8HJpow9Ok3fiWOWSIcIzXodvv0rQjVoOVNpWMpxf1wZNpt4y9h10odCNrqnYp1OBzRktckBe3sA==", + "funding": [ + "https://github.com/sponsors/broofa", + "https://github.com/sponsors/ctavan" + ], + "bin": { + "uuid": "dist/bin/uuid" + } + }, + "node_modules/v8-compile-cache-lib": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz", + "integrity": "sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg==", + "dev": true + }, + "node_modules/yn": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/yn/-/yn-3.1.1.tgz", + "integrity": "sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q==", + "engines": { + "node": ">=6" + } + } + } +} diff --git a/property_tests/tests/post_upgrade_method/package.json b/property_tests/tests/post_upgrade_method/package.json new file mode 100644 index 0000000000..e5b0aa2544 --- /dev/null +++ b/property_tests/tests/post_upgrade_method/package.json @@ -0,0 +1,12 @@ +{ + "scripts": { + "test": "ts-node --transpile-only --ignore=false test/test.ts" + }, + "dependencies": { + "azle": "^0.18.5" + }, + "devDependencies": { + "ts-node": "^10.9.1", + "typescript": "^5.2.2" + } +} diff --git a/property_tests/tests/post_upgrade_method/test/generate_callable_method_body.ts b/property_tests/tests/post_upgrade_method/test/generate_callable_method_body.ts new file mode 100644 index 0000000000..d1adc9fbb2 --- /dev/null +++ b/property_tests/tests/post_upgrade_method/test/generate_callable_method_body.ts @@ -0,0 +1,10 @@ +import { Named } from 'azle/property_tests'; +import { CorrespondingJSType } from 'azle/property_tests/arbitraries/candid/corresponding_js_type'; +import { CandidValueAndMeta } from 'azle/property_tests/arbitraries/candid/candid_value_and_meta_arb'; + +export function generateBody( + _namedParams: Named>[], + returnType: CandidValueAndMeta +) { + return `return ${returnType.src.valueLiteral}`; +} diff --git a/property_tests/tests/post_upgrade_method/test/generate_init_method_body.ts b/property_tests/tests/post_upgrade_method/test/generate_init_method_body.ts new file mode 100644 index 0000000000..048b4afac6 --- /dev/null +++ b/property_tests/tests/post_upgrade_method/test/generate_init_method_body.ts @@ -0,0 +1,23 @@ +import { Named } from 'azle/property_tests'; +import { CorrespondingJSType } from 'azle/property_tests/arbitraries/candid/corresponding_js_type'; +import { CandidValueAndMeta } from 'azle/property_tests/arbitraries/candid/candid_value_and_meta_arb'; +import { areParamsCorrectlyOrdered } from 'azle/property_tests/are_params_correctly_ordered'; +import { globalInitVarName } from './global_var_name'; + +export function generateBody( + namedParams: Named>[] +) { + const paramsAreCorrectlyOrdered = areParamsCorrectlyOrdered(namedParams); + + const storeVariablesGlobally = namedParams + .map((param, i) => `${globalInitVarName(i)} = ${param.name};`) + .join('\n'); + + return ` + initExecuted = true; + + ${paramsAreCorrectlyOrdered} + + ${storeVariablesGlobally} + `; +} 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 new file mode 100644 index 0000000000..d4396ada63 --- /dev/null +++ b/property_tests/tests/post_upgrade_method/test/generate_init_tests.ts @@ -0,0 +1,43 @@ +import { deepEqual, Named, getActor } from 'azle/property_tests'; +import { CandidValueAndMeta } from 'azle/property_tests/arbitraries/candid/candid_value_and_meta_arb'; +import { CorrespondingJSType } from 'azle/property_tests/arbitraries/candid/corresponding_js_type'; +import { Test } from 'azle/test'; + +export function generateTests( + _functionName: string, + params: Named>[] +): Test[][] { + const expectedResult = [ + true, + ...params.map((param) => param.value.value.agentResponseValue) + ]; + + return [ + [ + { + name: `init method`, + test: async () => { + const actor = getActor('./tests/post_upgrade_method/test'); + + const initValues = await actor.getInitValues(); + const isPostUpgradeCalled = + await actor.isPostUpgradeCalled(); + + const valuesAreEqual = + deepEqual(initValues, expectedResult) && + isPostUpgradeCalled === false; + + return valuesAreEqual + ? { Ok: true } + : { + Err: `\n +Incorrect return value + expected: ${expectedResult} + received: ${initValues} + isPostUpgradeCalled: ${isPostUpgradeCalled}` + }; + } + } + ] + ]; +} diff --git a/property_tests/tests/post_upgrade_method/test/generate_post_deploy_method_body.ts b/property_tests/tests/post_upgrade_method/test/generate_post_deploy_method_body.ts new file mode 100644 index 0000000000..3b75533aa7 --- /dev/null +++ b/property_tests/tests/post_upgrade_method/test/generate_post_deploy_method_body.ts @@ -0,0 +1,23 @@ +import { Named } from 'azle/property_tests'; +import { CorrespondingJSType } from 'azle/property_tests/arbitraries/candid/corresponding_js_type'; +import { CandidValueAndMeta } from 'azle/property_tests/arbitraries/candid/candid_value_and_meta_arb'; +import { areParamsCorrectlyOrdered } from 'azle/property_tests/are_params_correctly_ordered'; +import { globalPostUpgradeVarName } from './global_var_name'; + +export function generateBody( + namedParams: Named>[] +) { + const paramsAreCorrectlyOrdered = areParamsCorrectlyOrdered(namedParams); + + const storeVariablesGlobally = namedParams + .map((param, i) => `${globalPostUpgradeVarName(i)} = ${param.name};`) + .join('\n'); + + return ` + postUpgradeExecuted = true; + + ${paramsAreCorrectlyOrdered} + + ${storeVariablesGlobally} + `; +} 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 new file mode 100644 index 0000000000..f292061381 --- /dev/null +++ b/property_tests/tests/post_upgrade_method/test/generate_post_upgrade_tests.ts @@ -0,0 +1,44 @@ +import { deepEqual, Named, getActor } from 'azle/property_tests'; +import { CandidValueAndMeta } from 'azle/property_tests/arbitraries/candid/candid_value_and_meta_arb'; +import { CorrespondingJSType } from 'azle/property_tests/arbitraries/candid/corresponding_js_type'; +import { Test } from 'azle/test'; + +export function generateTests( + _functionName: string, + params: Named>[] +): Test[][] { + const expectedResult = [ + true, + ...params.map((param) => param.value.value.agentResponseValue) + ]; + + return [ + [], // Don't test on the first deploy, test after a re-deploy + [ + { + name: `post upgrade method`, + test: async () => { + const actor = getActor('./tests/post_upgrade_method/test'); + + const postUpgradeValues = + await actor.getPostUpgradeValues(); + const isInitCalled = await actor.isInitCalled(); + + const valuesAreEqual = + deepEqual(postUpgradeValues, expectedResult) && + isInitCalled === false; + + return valuesAreEqual + ? { Ok: true } + : { + Err: `\n +Incorrect return value +expected: ${expectedResult} +received: ${postUpgradeValues} +isInitCalled: ${isInitCalled}` + }; + } + } + ] + ]; +} diff --git a/property_tests/tests/post_upgrade_method/test/global_var_name.ts b/property_tests/tests/post_upgrade_method/test/global_var_name.ts new file mode 100644 index 0000000000..1b18abce87 --- /dev/null +++ b/property_tests/tests/post_upgrade_method/test/global_var_name.ts @@ -0,0 +1,7 @@ +export function globalInitVarName(i: number) { + return `initParam${i}`; +} + +export function globalPostUpgradeVarName(i: number) { + return `postUpgradeParam${i}`; +} diff --git a/property_tests/tests/post_upgrade_method/test/test.ts b/property_tests/tests/post_upgrade_method/test/test.ts new file mode 100644 index 0000000000..870ddd150c --- /dev/null +++ b/property_tests/tests/post_upgrade_method/test/test.ts @@ -0,0 +1,285 @@ +import fc from 'fast-check'; + +import { runPropTests } from 'azle/property_tests'; +import { + CandidValueAndMeta, + 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, + CanisterConfig +} from 'azle/property_tests/arbitraries/canister_arb'; +import { UpdateMethodArb } from 'azle/property_tests/arbitraries/canister_methods/update_method_arb'; +import { + QueryMethod, + QueryMethodArb +} from 'azle/property_tests/arbitraries/canister_methods/query_method_arb'; +import { PostUpgradeMethodArb } from 'azle/property_tests/arbitraries/canister_methods/post_upgrade_arb'; + +import { generateBody as callableMethodBodyGenerator } from './generate_callable_method_body'; +import { generateBody as postUpgradeMethodBodyGenerator } from './generate_post_deploy_method_body'; +import { generateBody as initMethodBodyGenerator } from './generate_init_method_body'; +import { generateTests as generateInitTests } from './generate_init_tests'; +import { generateTests as generatePostUpgradeTests } from './generate_post_upgrade_tests'; +import { CorrespondingJSType } from '../../../arbitraries/candid/corresponding_js_type'; +import { InitMethodArb } from 'azle/property_tests/arbitraries/canister_methods/init_method_arb'; +import { globalInitVarName, globalPostUpgradeVarName } from './global_var_name'; +import { candidDefinitionArb } from '../../../arbitraries/candid/candid_definition_arb'; +import { CandidValueArb } from '../../../arbitraries/candid/candid_values_arb'; +import { definitionAndValueToValueAndMeta } from '../../../arbitraries/candid/candid_value_and_meta_arb_generator'; +import { + CandidDefinition, + WithShapes +} from '../../../arbitraries/candid/candid_definition_arb/types'; +import { DEFAULT_VALUE_MAX_DEPTH } from '../../../arbitraries/config'; + +const CanisterConfigArb = fc + .array(candidDefinitionArb({})) + .chain((paramDefinitionsWithShapes) => { + const initParamValues = definitionsToValueAndMetaArb( + paramDefinitionsWithShapes + ); + const postUpgradeParamValues = definitionsToValueAndMetaArb( + paramDefinitionsWithShapes + ); + return fc.tuple(initParamValues, postUpgradeParamValues); + }) + .chain(([initParams, postUpgradeParams]) => { + const initDeployParamsArb = fc.constant(initParams); + const postUpgradeParamsArb = fc.constant(postUpgradeParams); + + const SimpleInitMethodArb = InitMethodArb(initDeployParamsArb, { + generateBody: initMethodBodyGenerator, + generateTests: generateInitTests + }); + + const SimplePostUpgradeMethodArb = PostUpgradeMethodArb( + postUpgradeParamsArb, + { + generateBody: postUpgradeMethodBodyGenerator, + generateTests: generatePostUpgradeTests + } + ); + + const HeterogeneousQueryMethodArb = QueryMethodArb( + fc.array(CandidValueAndMetaArb()), + CandidReturnTypeArb(), + { + generateBody: callableMethodBodyGenerator, + generateTests: () => [] + } + ); + + const HeterogeneousUpdateMethodArb = UpdateMethodArb( + fc.array(CandidValueAndMetaArb()), + CandidReturnTypeArb(), + { + generateBody: callableMethodBodyGenerator, + generateTests: () => [] + } + ); + + const small = { + minLength: 0, + maxLength: 20 + }; + + return fc.tuple( + initDeployParamsArb, + postUpgradeParamsArb, + SimpleInitMethodArb, + SimplePostUpgradeMethodArb, + fc.array(HeterogeneousQueryMethodArb, small), + fc.array(HeterogeneousUpdateMethodArb, small) + ); + }) + .map( + ([ + initParams, + postUpgradeParams, + initMethod, + postUpgradeMethod, + queryMethods, + updateMethods + ]): CanisterConfig => { + const paramCandidTypeObjects = postUpgradeParams.map( + // The candidTypeObjects ought to be the same so it doesn't mater which we use to generate this list + (param) => param.src.candidTypeObject + ); + + const globalInitVariableNames = initParams.map((_, i) => + globalInitVarName(i) + ); + const globalPostUpgradeVariableNames = postUpgradeParams.map( + (_, i) => globalPostUpgradeVarName(i) + ); + const globalInitVariableDeclarations = initParams.map( + (param, i) => + `let ${globalInitVarName(i)}: ${ + param.src.candidTypeAnnotation + };` + ); + const globalPostUpgradeVariableDeclarations = postUpgradeParams.map( + (param, i) => + `let ${globalPostUpgradeVarName(i)}: ${ + param.src.candidTypeAnnotation + };` + ); + + const globalDeclarations = [ + 'let postUpgradeExecuted: boolean = false;', + 'let initExecuted: boolean = false;', + ...globalInitVariableDeclarations, + ...globalPostUpgradeVariableDeclarations + ]; + + const getPostUpgradeValues = + generateGetPostUpgradeValuesCanisterMethod( + paramCandidTypeObjects, + globalPostUpgradeVariableNames + ); + + const getInitValues = generateGetInitValuesCanisterMethod( + paramCandidTypeObjects, + globalInitVariableNames + ); + + const isPostUpgradeCalled = generateIsPostUpgradeCalled( + globalPostUpgradeVariableNames + ); + + const isInitCalled = generateIsInitCalled(globalInitVariableNames); + + return { + globalDeclarations, + initMethod, + postUpgradeMethod, + queryMethods: [ + getInitValues, + getPostUpgradeValues, + isPostUpgradeCalled, + isInitCalled, + ...queryMethods + ], + updateMethods + }; + } + ); + +function generateGetPostUpgradeValuesCanisterMethod( + paramCandidTypeObjects: string[], + globalVariableNames: string[] +): QueryMethod { + return { + imports: new Set(['Tuple', 'bool', 'query']), + globalDeclarations: [], + sourceCode: /*TS*/ `getPostUpgradeValues: query( + [], + Tuple(bool, ${paramCandidTypeObjects.join()}), + () => {return [postUpgradeExecuted, ${globalVariableNames.join()}]} + )`, + tests: [] + }; +} + +function generateGetInitValuesCanisterMethod( + paramCandidTypeObjects: string[], + globalVariableNames: string[] +): QueryMethod { + return { + imports: new Set(['Tuple', 'bool', 'query']), + globalDeclarations: [], + sourceCode: /*TS*/ `getInitValues: query( + [], + Tuple(bool, ${paramCandidTypeObjects.join()}), + () => {return [initExecuted, ${globalVariableNames.join()}]} + )`, + tests: [] + }; +} + +function generateIsInitCalled(globalVariableNames: string[]): QueryMethod { + const areAllParamsUndefined = globalVariableNames + .map((name) => `${name} === undefined`) + .join(' && '); + const isInitCalled = `initExecuted${ + globalVariableNames.length === 0 + ? '' + : ` || !(${areAllParamsUndefined})` + }`; + return { + imports: new Set(['bool', 'query']), + globalDeclarations: [], + sourceCode: /*TS*/ `isInitCalled: query([], bool, () => ${isInitCalled})`, + tests: [] + }; +} + +function generateIsPostUpgradeCalled( + globalVariableNames: string[] +): QueryMethod { + const areAllParamsUndefined = globalVariableNames + .map((name) => `${name} === undefined`) + .join(' && '); + const isPostUpgradeCalled = `postUpgradeExecuted${ + globalVariableNames.length === 0 + ? '' + : ` || !(${areAllParamsUndefined})` + }`; + return { + imports: new Set(['bool', 'query']), + globalDeclarations: [], + sourceCode: /*TS*/ `isPostUpgradeCalled: query([], bool, () => ${isPostUpgradeCalled})`, + tests: [] + }; +} + +function definitionsToValueAndMetaArb( + definitionsWithShapes: WithShapes[] +): fc.Arbitrary[]> { + const definitions = definitionsWithShapes.map( + (definitionWithShapes) => definitionWithShapes.definition + ); + const recursiveShapes = definitionsWithShapes.reduce( + (acc, definitionsWithShapes) => { + return { ...acc, ...definitionsWithShapes.recursiveShapes }; + }, + {} + ); + return fc + .tuple( + fc.constant(definitions), + fc.tuple( + ...definitions.map((definition) => + // TODO multiplying by zero is to remove -0 + // TODO we should open an issue with agent-js + // TODO the agent should encode and decode -0 correctly + // https://github.com/demergent-labs/azle/issues/1511 + // TODO Infinity and NaN can't be used in this context + // https://github.com/dfinity/candid/issues/499 + CandidValueArb(definition, recursiveShapes, { + noDefaultInfinity: true, + noNaN: true, + noNegativeZero: true, + depthLevel: DEFAULT_VALUE_MAX_DEPTH + }) + ) + ) + ) + .map( + ([ + definitions, + values + ]): CandidValueAndMeta[] => { + return values.map((value, index) => { + return definitionAndValueToValueAndMeta( + definitions[index], + value + ); + }); + } + ); +} + +runPropTests(CanisterArb(CanisterConfigArb)); diff --git a/property_tests/tests/post_upgrade_method/tsconfig.json b/property_tests/tests/post_upgrade_method/tsconfig.json new file mode 100644 index 0000000000..d20bea88d9 --- /dev/null +++ b/property_tests/tests/post_upgrade_method/tsconfig.json @@ -0,0 +1,10 @@ +{ + "compilerOptions": { + "strict": true, + "target": "ES2020", + "moduleResolution": "node", + "allowJs": true, + "outDir": "HACK_BECAUSE_OF_ALLOW_JS", + "esModuleInterop": true + } +} 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 bcdaaf6491..fe60edb010 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 @@ -10,7 +10,11 @@ export function ContainsKeyTestArb(stableBTreeMap: StableBTreeMap) { return fc .tuple(UniqueIdentifierArb('stableBTreeMap')) .map(([functionName]): QueryMethod => { - const imports = new Set([...stableBTreeMap.imports, 'bool']); + const imports = new Set([ + ...stableBTreeMap.imports, + 'bool', + 'query' + ]); const paramCandidTypeObjects = [ stableBTreeMap.keySample.src.candidTypeObject 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 233aaa7ea6..5839e55c3b 100644 --- a/property_tests/tests/stable_b_tree_map/test/get.ts +++ b/property_tests/tests/stable_b_tree_map/test/get.ts @@ -10,7 +10,11 @@ export function GetTestArb(stableBTreeMap: StableBTreeMap) { return fc .tuple(UniqueIdentifierArb('stableBTreeMap')) .map(([functionName]): QueryMethod => { - const imports = new Set([...stableBTreeMap.imports, 'Opt']); + const imports = new Set([ + ...stableBTreeMap.imports, + 'Opt', + 'query' + ]); const paramCandidTypeObjects = [ stableBTreeMap.keySample.src.candidTypeObject 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 2951e43fba..4ca836fb1a 100644 --- a/property_tests/tests/stable_b_tree_map/test/insert.ts +++ b/property_tests/tests/stable_b_tree_map/test/insert.ts @@ -10,7 +10,11 @@ export function InsertTestArb(stableBTreeMap: StableBTreeMap) { return fc .tuple(UniqueIdentifierArb('stableBTreeMap')) .map(([functionName]): QueryMethod => { - const imports = new Set([...stableBTreeMap.imports, 'Opt']); + const imports = new Set([ + ...stableBTreeMap.imports, + 'Opt', + 'update' + ]); const paramCandidTypeObjects = [ stableBTreeMap.keySample.src.candidTypeObject, 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 2029c5ee48..e279549d53 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 @@ -10,7 +10,11 @@ export function IsEmptyTestArb(stableBTreeMap: StableBTreeMap) { return fc .tuple(UniqueIdentifierArb('stableBTreeMap')) .map(([functionName]): QueryMethod => { - const imports = new Set([...stableBTreeMap.imports, 'bool']); + const imports = new Set([ + ...stableBTreeMap.imports, + 'bool', + 'query' + ]); const body = generateBody(stableBTreeMap.name); 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 d358ecfb99..17dbfcf5ba 100644 --- a/property_tests/tests/stable_b_tree_map/test/items.ts +++ b/property_tests/tests/stable_b_tree_map/test/items.ts @@ -13,7 +13,8 @@ export function ItemsTestArb(stableBTreeMap: StableBTreeMap) { const imports = new Set([ ...stableBTreeMap.imports, 'Vec', - 'Tuple' + 'Tuple', + 'query' ]); const returnCandidTypeObject = `Vec(Tuple(${stableBTreeMap.keySample.src.candidTypeObject}, ${stableBTreeMap.valueSample.src.candidTypeObject}))`; 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 798a88f780..eaf894c109 100644 --- a/property_tests/tests/stable_b_tree_map/test/keys.ts +++ b/property_tests/tests/stable_b_tree_map/test/keys.ts @@ -11,7 +11,11 @@ export function KeysTestArb(stableBTreeMap: StableBTreeMap) { return fc .tuple(UniqueIdentifierArb('stableBTreeMap')) .map(([functionName]): QueryMethod => { - const imports = new Set([...stableBTreeMap.imports, 'Vec']); + const imports = new Set([ + ...stableBTreeMap.imports, + 'Vec', + 'query' + ]); const returnCandidTypeObject = `Vec(${stableBTreeMap.keySample.src.candidTypeObject})`; const body = generateBody( 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 377639e131..d55b031bc6 100644 --- a/property_tests/tests/stable_b_tree_map/test/len.ts +++ b/property_tests/tests/stable_b_tree_map/test/len.ts @@ -10,7 +10,11 @@ export function LenTestArb(stableBTreeMap: StableBTreeMap) { return fc .tuple(UniqueIdentifierArb('stableBTreeMap')) .map(([functionName]): QueryMethod => { - const imports = new Set([...stableBTreeMap.imports, 'nat64']); + const imports = new Set([ + ...stableBTreeMap.imports, + 'nat64', + 'query' + ]); const returnCandidTypeObject = `nat64`; const body = generateBody(stableBTreeMap.name); 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 02d0720b9a..a22917ddda 100644 --- a/property_tests/tests/stable_b_tree_map/test/remove.ts +++ b/property_tests/tests/stable_b_tree_map/test/remove.ts @@ -10,7 +10,11 @@ export function RemoveTestArb(stableBTreeMap: StableBTreeMap) { return fc .tuple(UniqueIdentifierArb('stableBTreeMap')) .map(([functionName]): QueryMethod => { - const imports = new Set([...stableBTreeMap.imports, 'Opt']); + const imports = new Set([ + ...stableBTreeMap.imports, + 'Opt', + 'update' + ]); const paramCandidTypeObjects = [ stableBTreeMap.keySample.src.candidTypeObject 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 8b1ae5d1f4..ee71580fac 100644 --- a/property_tests/tests/stable_b_tree_map/test/values.ts +++ b/property_tests/tests/stable_b_tree_map/test/values.ts @@ -11,7 +11,11 @@ export function ValuesTestArb(stableBTreeMap: StableBTreeMap) { return fc .tuple(UniqueIdentifierArb('stableBTreeMap')) .map(([functionName]): QueryMethod => { - const imports = new Set([...stableBTreeMap.imports, 'Vec']); + const imports = new Set([ + ...stableBTreeMap.imports, + 'Vec', + 'query' + ]); const returnCandidTypeObject = `Vec(${stableBTreeMap.valueSample.src.candidTypeObject})`; const body = generateBody(