diff --git a/property_tests/arbitraries/candid/candid_definition_arb/complex_candid_definition_memo.ts b/property_tests/arbitraries/candid/candid_definition_arb/complex_candid_definition_memo.ts index a21b187fdf..adee69b61a 100644 --- a/property_tests/arbitraries/candid/candid_definition_arb/complex_candid_definition_memo.ts +++ b/property_tests/arbitraries/candid/candid_definition_arb/complex_candid_definition_memo.ts @@ -11,7 +11,7 @@ import { ServiceDefinitionArb } from '../reference/service_arb/definition_arb'; import { CandidDefinitionMemo, DefinitionConstraints, - RecursiveCandidDefinition + RecursiveCandidName } from './types'; export type ComplexDefinitionWeights = Partial<{ @@ -29,7 +29,7 @@ export type ComplexDefinitionWeights = Partial<{ export const COMPLEX_ARB_COUNT = 8; export function complexCandidDefinitionMemo( - parents: RecursiveCandidDefinition[], + parents: RecursiveCandidName[], constraints: DefinitionConstraints = {} ): CandidDefinitionMemo { const weights = constraints.weights ?? {}; diff --git a/property_tests/arbitraries/candid/candid_definition_arb/index.ts b/property_tests/arbitraries/candid/candid_definition_arb/index.ts index 3af430af0e..ca4c68984c 100644 --- a/property_tests/arbitraries/candid/candid_definition_arb/index.ts +++ b/property_tests/arbitraries/candid/candid_definition_arb/index.ts @@ -1,7 +1,7 @@ import fc from 'fast-check'; import { CandidDefinitionArb, - RecursiveCandidDefinition, + RecursiveCandidName, CandidDefinitionMemo, DefinitionConstraints } from './types'; @@ -21,14 +21,14 @@ import { DEFAULT_DEF_MAX_DEPTH } from '../../config'; export function candidDefinitionArb( maxDepth: number = DEFAULT_DEF_MAX_DEPTH, - parents: RecursiveCandidDefinition[] = [], + parents: RecursiveCandidName[] = [], constraints: DefinitionConstraints = {} ): CandidDefinitionArb { return candidDefinitionMemo(parents, constraints)(maxDepth); } export function candidDefinitionMemo( - parents: RecursiveCandidDefinition[], + parents: RecursiveCandidName[], constraints: DefinitionConstraints = {} ): CandidDefinitionMemo { return fc.memo((n) => { diff --git a/property_tests/arbitraries/candid/candid_definition_arb/recursive_candid_definition_memo.ts b/property_tests/arbitraries/candid/candid_definition_arb/recursive_candid_definition_memo.ts index f8e2c41dcc..604b72eb51 100644 --- a/property_tests/arbitraries/candid/candid_definition_arb/recursive_candid_definition_memo.ts +++ b/property_tests/arbitraries/candid/candid_definition_arb/recursive_candid_definition_memo.ts @@ -1,7 +1,7 @@ import fc from 'fast-check'; import { RecursiveDefinitionArb } from '../recursive/definition_arb'; import { complexCandidDefinitionMemo } from './complex_candid_definition_memo'; -import { RecursiveCandidDefinition, CandidDefinitionMemo } from './types'; +import { RecursiveCandidName, CandidDefinitionMemo } from './types'; // The number of options below (it's just recursive) export const REC_ARB_COUNT = 0; @@ -11,7 +11,7 @@ export const REC_ARB_COUNT = 0; // https://github.com/demergent-labs/azle/issues/1525 export function recursiveCandidDefinitionMemo( - parents: RecursiveCandidDefinition[] + parents: RecursiveCandidName[] ): CandidDefinitionMemo { return fc.memo((n) => RecursiveDefinitionArb(complexCandidDefinitionMemo, parents, { n }) diff --git a/property_tests/arbitraries/candid/candid_definition_arb/types.ts b/property_tests/arbitraries/candid/candid_definition_arb/types.ts index 73866248c5..e776117dc4 100644 --- a/property_tests/arbitraries/candid/candid_definition_arb/types.ts +++ b/property_tests/arbitraries/candid/candid_definition_arb/types.ts @@ -5,7 +5,7 @@ import { ComplexDefinitionWeights } from './complex_candid_definition_memo'; export type CandidDefinitionMemo = (n: number) => CandidDefinitionArb; export type RecursiveCandidDefinitionMemo = ( - parents: RecursiveCandidDefinition[], + parents: RecursiveCandidName[], constraints?: DefinitionConstraints ) => CandidDefinitionMemo; @@ -88,11 +88,11 @@ export type ServiceMethodDefinition = { }; // Recursive -export type RecursiveCandidDefinition = { +export type RecursiveCandidName = { candidMeta: CandidMeta; name: string; }; -export type RecursiveGlobalDefinition = { +export type RecursiveCandidDefinition = { candidMeta: CandidMeta; name: string; innerType: CandidDefinition; diff --git a/property_tests/arbitraries/candid/candid_values_arb.ts b/property_tests/arbitraries/candid/candid_values_arb.ts index 20b4c82374..96ceba0b21 100644 --- a/property_tests/arbitraries/candid/candid_values_arb.ts +++ b/property_tests/arbitraries/candid/candid_values_arb.ts @@ -27,8 +27,8 @@ import { CandidDefinition, OptCandidDefinition, RecordCandidDefinition, + RecursiveCandidName, RecursiveCandidDefinition, - RecursiveGlobalDefinition, ServiceCandidDefinition, TupleCandidDefinition, VariantCandidDefinition, @@ -126,9 +126,7 @@ export function CandidValueArb( } if (candidType === 'Recursive') { return RecursivePlaceHolderValuesArb( - candidTypeMeta as - | RecursiveCandidDefinition - | RecursiveGlobalDefinition, + candidTypeMeta as RecursiveCandidName | RecursiveCandidDefinition, n ); } diff --git a/property_tests/arbitraries/candid/constructed/opt_arb/definition_arb.ts b/property_tests/arbitraries/candid/constructed/opt_arb/definition_arb.ts index 23fc3dcbe1..d053a7a259 100644 --- a/property_tests/arbitraries/candid/constructed/opt_arb/definition_arb.ts +++ b/property_tests/arbitraries/candid/constructed/opt_arb/definition_arb.ts @@ -5,12 +5,12 @@ import { DefinitionConstraints, OptCandidDefinition, RecursiveCandidDefinitionMemo, - RecursiveCandidDefinition + RecursiveCandidName } from '../../candid_definition_arb/types'; export function OptDefinitionArb( candidTypeArbForInnerType: RecursiveCandidDefinitionMemo, - parents: RecursiveCandidDefinition[], + parents: RecursiveCandidName[], constraints: DefinitionConstraints ): fc.Arbitrary { return fc @@ -59,7 +59,7 @@ export function OptDefinitionArb( function possiblyRecursiveArb( candidArb: RecursiveCandidDefinitionMemo, - parents: RecursiveCandidDefinition[], + parents: RecursiveCandidName[], constraints: DefinitionConstraints ): fc.Arbitrary { const n = constraints.n ?? 0; diff --git a/property_tests/arbitraries/candid/constructed/variant_arb/definition_arbs.ts b/property_tests/arbitraries/candid/constructed/variant_arb/definition_arbs.ts index 308a057015..6c7a51c443 100644 --- a/property_tests/arbitraries/candid/constructed/variant_arb/definition_arbs.ts +++ b/property_tests/arbitraries/candid/constructed/variant_arb/definition_arbs.ts @@ -4,7 +4,7 @@ import { CandidDefinition, DefinitionConstraints, RecursiveCandidDefinitionMemo, - RecursiveCandidDefinition, + RecursiveCandidName, VariantCandidDefinition } from '../../candid_definition_arb/types'; import { JsFunctionNameArb } from '../../../js_function_name_arb'; @@ -13,7 +13,7 @@ type Field = [string, CandidDefinition]; export function VariantDefinitionArb( candidTypeArbForFields: RecursiveCandidDefinitionMemo, - parents: RecursiveCandidDefinition[], + parents: RecursiveCandidName[], constraints: DefinitionConstraints ): fc.Arbitrary { return fc @@ -58,7 +58,7 @@ export function VariantDefinitionArb( function VariantFieldsArb( candidTypeArb: RecursiveCandidDefinitionMemo, - parents: RecursiveCandidDefinition[], + parents: RecursiveCandidName[], constraints: DefinitionConstraints ): fc.Arbitrary { // Although no minLength is technically required (according to the @@ -98,7 +98,7 @@ function VariantFieldsArb( function possiblyRecursiveArb( candidArb: RecursiveCandidDefinitionMemo, index: number, - parents: RecursiveCandidDefinition[], + parents: RecursiveCandidName[], constraints: DefinitionConstraints ): fc.Arbitrary { const n = constraints.n ?? 0; diff --git a/property_tests/arbitraries/candid/constructed/vec_arb/definition_arb.ts b/property_tests/arbitraries/candid/constructed/vec_arb/definition_arb.ts index 3b3c580843..23dde9d070 100644 --- a/property_tests/arbitraries/candid/constructed/vec_arb/definition_arb.ts +++ b/property_tests/arbitraries/candid/constructed/vec_arb/definition_arb.ts @@ -4,13 +4,13 @@ import { CandidDefinition, DefinitionConstraints, RecursiveCandidDefinitionMemo, - RecursiveCandidDefinition, + RecursiveCandidName, VecCandidDefinition } from '../../candid_definition_arb/types'; export function VecDefinitionArb( candidTypeArb: RecursiveCandidDefinitionMemo, - parents: RecursiveCandidDefinition[], + parents: RecursiveCandidName[], constraints: DefinitionConstraints ): fc.Arbitrary { return fc @@ -55,7 +55,7 @@ export function VecDefinitionArb( function possiblyRecursiveArb( candidArb: RecursiveCandidDefinitionMemo, - parents: RecursiveCandidDefinition[], + parents: RecursiveCandidName[], constraints: DefinitionConstraints ): fc.Arbitrary { const n = constraints.n ?? 0; diff --git a/property_tests/arbitraries/candid/recursive/definition_arb.ts b/property_tests/arbitraries/candid/recursive/definition_arb.ts index 222d44a5df..075c268b6c 100644 --- a/property_tests/arbitraries/candid/recursive/definition_arb.ts +++ b/property_tests/arbitraries/candid/recursive/definition_arb.ts @@ -4,19 +4,19 @@ import { CandidDefinition, DefinitionConstraints, RecursiveCandidDefinitionMemo, - RecursiveCandidDefinition, - RecursiveGlobalDefinition + RecursiveCandidName, + RecursiveCandidDefinition } from '../candid_definition_arb/types'; import { recursive } from '.'; export function RecursiveDefinitionArb( candidTypeArbForInnerType: RecursiveCandidDefinitionMemo, - parents: RecursiveCandidDefinition[], + parents: RecursiveCandidName[], constraints: DefinitionConstraints -): fc.Arbitrary { +): fc.Arbitrary { return UniqueIdentifierArb('typeDeclaration') - .chain((name): fc.Arbitrary => { - const recCanDef: RecursiveCandidDefinition = { + .chain((name): fc.Arbitrary => { + const recCanDef: RecursiveCandidName = { candidMeta: { candidType: 'Recursive', candidTypeObject: name, @@ -57,7 +57,7 @@ export function RecursiveDefinitionArb( const imports = generateImports(innerType); - const shape: RecursiveGlobalDefinition = { + const shape: RecursiveCandidDefinition = { candidMeta: { candidTypeObject, candidTypeAnnotation, diff --git a/property_tests/arbitraries/candid/recursive/index.ts b/property_tests/arbitraries/candid/recursive/index.ts index 02c516eb9f..2383691fd4 100644 --- a/property_tests/arbitraries/candid/recursive/index.ts +++ b/property_tests/arbitraries/candid/recursive/index.ts @@ -1,6 +1,6 @@ import fc from 'fast-check'; import { CandidValueAndMeta } from '../candid_value_and_meta_arb'; -import { RecursiveGlobalDefinition } from '../candid_definition_arb/types'; +import { RecursiveCandidDefinition } from '../candid_definition_arb/types'; import { RecursiveDefinitionArb } from './definition_arb'; import { RecursiveValuesArb } from './values_arb'; import { CandidValueAndMetaArbGenerator } from '../candid_value_and_meta_arb_generator'; @@ -8,7 +8,7 @@ import { complexCandidDefinitionMemo } from '../candid_definition_arb/complex_ca import { DEFAULT_DEF_MAX_DEPTH } from '../../config'; export const recursive: { - shapes: { [key: string]: RecursiveGlobalDefinition }; + shapes: { [key: string]: RecursiveCandidDefinition }; } = { shapes: {} }; diff --git a/property_tests/arbitraries/candid/recursive/values_arb.ts b/property_tests/arbitraries/candid/recursive/values_arb.ts index 9a9b800979..ec2f0d195e 100644 --- a/property_tests/arbitraries/candid/recursive/values_arb.ts +++ b/property_tests/arbitraries/candid/recursive/values_arb.ts @@ -1,13 +1,13 @@ import fc from 'fast-check'; import { Recursive, recursive } from '.'; import { - RecursiveCandidDefinition, - RecursiveGlobalDefinition + RecursiveCandidName, + RecursiveCandidDefinition } from '../candid_definition_arb/types'; import { CandidValues, CandidValueArb } from '../candid_values_arb'; export function RecursivePlaceHolderValuesArb( - recDefinition: RecursiveCandidDefinition | RecursiveGlobalDefinition, + recDefinition: RecursiveCandidName | RecursiveCandidDefinition, n: number ): fc.Arbitrary> { const recShape = recursive.shapes[recDefinition.name]; @@ -15,7 +15,7 @@ export function RecursivePlaceHolderValuesArb( } export function RecursiveValuesArb( - recDefinition: RecursiveGlobalDefinition, + recDefinition: RecursiveCandidDefinition, n: number ): fc.Arbitrary> { return CandidValueArb(recDefinition.innerType, n);