diff --git a/property_tests/arbitraries/candid/candid_arb.ts b/property_tests/arbitraries/candid/candid_arb.ts index b95968dfad..414dd32838 100644 --- a/property_tests/arbitraries/candid/candid_arb.ts +++ b/property_tests/arbitraries/candid/candid_arb.ts @@ -3,7 +3,7 @@ import { deepEqual } from 'fast-equals'; import { CandidType } from './candid_type_arb'; // TODO we're thinking that Candid is not the best name for this. What is better? -export type Candid = { +export type CandidMeta = { value: T; src: { candidType: string; @@ -14,14 +14,14 @@ export type Candid = { equals(a: T, b: T): boolean; }; -export const CandidArb = ( +export const CandidMetaArb = ( arb: fc.Arbitrary, candidType: string, toLiteral: (value: T) => string, equals: (a: T, b: T) => boolean = (a: T, b: T) => deepEqual(a, b) ) => { return arb.map( - (value): Candid => ({ + (value): CandidMeta => ({ src: { candidType, imports: new Set([candidType]), diff --git a/property_tests/arbitraries/candid/candid_type_arb.ts b/property_tests/arbitraries/candid/candid_type_arb.ts index e41d410eb6..ffdd5482b7 100644 --- a/property_tests/arbitraries/candid/candid_type_arb.ts +++ b/property_tests/arbitraries/candid/candid_type_arb.ts @@ -17,9 +17,12 @@ import { Float32Arb } from './primitive/floats/float32_arb'; import { Float64Arb } from './primitive/floats/float64_arb'; import { TextArb } from './primitive/text'; import { BlobArb } from './constructed/blob_arb'; -import { Candid } from './candid_arb'; +import { CandidMeta } from './candid_arb'; import { Func } from './reference/func_arb'; import { Opt } from './constructed/opt_arb'; +import { Variant } from './constructed/variant_arb'; +import { Record } from './constructed/record_arb'; +import { Tuple } from './constructed/tuple_arb'; export type CandidType = | number @@ -30,14 +33,18 @@ export type CandidType = | Uint8Array | string | Func - | Opt; + | Opt + | Variant + | Record + | Tuple + | undefined; /** * An arbitrary representing all possible Candid types. * * **Note:** This currently only supports ints, nats, and null arbitraries */ -export const CandidTypeArb: fc.Arbitrary> = fc.oneof( +export const CandidTypeArb: fc.Arbitrary> = fc.oneof( Float32Arb, Float64Arb, IntArb, diff --git a/property_tests/arbitraries/candid/constructed/blob_arb.ts b/property_tests/arbitraries/candid/constructed/blob_arb.ts index fd668fd69d..6090071e99 100644 --- a/property_tests/arbitraries/candid/constructed/blob_arb.ts +++ b/property_tests/arbitraries/candid/constructed/blob_arb.ts @@ -1,11 +1,11 @@ import fc from 'fast-check'; -import { CandidArb } from '../candid_arb'; +import { CandidMetaArb } from '../candid_arb'; import { blobToSrcLiteral } from '../to_src_literal/blob'; export const BlobArb = fc .oneof( - CandidArb(fc.uint8Array(), 'Vec(nat8)', blobToSrcLiteral), - CandidArb(fc.uint8Array(), 'blob', blobToSrcLiteral) + CandidMetaArb(fc.uint8Array(), 'Vec(nat8)', blobToSrcLiteral), + CandidMetaArb(fc.uint8Array(), 'blob', blobToSrcLiteral) ) .map((sample) => ({ ...sample, diff --git a/property_tests/arbitraries/candid/constructed/opt_arb.ts b/property_tests/arbitraries/candid/constructed/opt_arb.ts index 05c272befe..1ccdc63e1e 100644 --- a/property_tests/arbitraries/candid/constructed/opt_arb.ts +++ b/property_tests/arbitraries/candid/constructed/opt_arb.ts @@ -1,11 +1,11 @@ import fc from 'fast-check'; import { CandidType, CandidTypeArb } from '../candid_type_arb'; -import { Candid } from '../candid_arb'; +import { CandidMeta } from '../candid_arb'; type SomeOrNone = 'Some' | 'None'; type Base = { someOrNone: SomeOrNone; - candid: Candid; + candid: CandidMeta; }; type RecursiveOpt = { base: T } | { nextLayer: RecursiveOpt }; @@ -34,7 +34,7 @@ export const OptArb = fc }) ) })) - .RecursiveOptArb.map((recursiveOptArb): Candid => { + .RecursiveOptArb.map((recursiveOptArb): CandidMeta => { return { src: { candidType: generateCandidType(recursiveOptArb), diff --git a/property_tests/arbitraries/candid/constructed/record_arb.ts b/property_tests/arbitraries/candid/constructed/record_arb.ts index d82a3604c0..d3796737fb 100644 --- a/property_tests/arbitraries/candid/constructed/record_arb.ts +++ b/property_tests/arbitraries/candid/constructed/record_arb.ts @@ -1,6 +1,6 @@ import fc from 'fast-check'; -import { Candid } from '../candid_arb'; +import { CandidMeta } from '../candid_arb'; import { CandidType, CandidTypeArb } from '../candid_type_arb'; import { UniqueIdentifierArb } from '../../unique_identifier_arb'; import { JsFunctionNameArb } from '../../js_function_name_arb'; @@ -9,7 +9,7 @@ export type Record = { [x: string]: CandidType; }; -type Field = [string, Candid]; +type Field = [string, CandidMeta]; export const RecordArb = fc .tuple( @@ -18,7 +18,7 @@ export const RecordArb = fc selector: (entry) => entry[0] }) ) - .map(([name, fields]): Candid => { + .map(([name, fields]): CandidMeta => { const typeDeclaration = generateTypeDeclaration(name, fields); const imports = generateImports(fields); diff --git a/property_tests/arbitraries/candid/constructed/tuple_arb.ts b/property_tests/arbitraries/candid/constructed/tuple_arb.ts index 6c24944f40..e2ca939493 100644 --- a/property_tests/arbitraries/candid/constructed/tuple_arb.ts +++ b/property_tests/arbitraries/candid/constructed/tuple_arb.ts @@ -1,6 +1,6 @@ import fc from 'fast-check'; -import { Candid } from '../candid_arb'; +import { CandidMeta } from '../candid_arb'; import { CandidType, CandidTypeArb } from '../candid_type_arb'; import { UniqueIdentifierArb } from '../../unique_identifier_arb'; @@ -8,7 +8,7 @@ export type Tuple = CandidType[]; export const TupleArb = fc .tuple(UniqueIdentifierArb('typeDeclaration'), fc.array(CandidTypeArb)) - .map(([name, fields]): Candid => { + .map(([name, fields]): CandidMeta => { const innerTypes = fields.map((field) => field.src.candidType); const typeDeclaration = `const ${name} = Tuple(${innerTypes.join( @@ -35,12 +35,12 @@ export const TupleArb = fc }; }); -function generateImports(fields: Candid[]): Set { +function generateImports(fields: CandidMeta[]): Set { const fieldImports = fields.flatMap((field) => [...field.src.imports]); return new Set([...fieldImports, 'Tuple']); } -function generateValueLiteral(fields: Candid[]) { +function generateValueLiteral(fields: CandidMeta[]) { const fieldLiterals = fields .map((field) => field.src.valueLiteral) .join(',\n'); @@ -51,7 +51,7 @@ function generateValueLiteral(fields: Candid[]) { } function generateEqualsMethod( - fields: Candid[] + fields: CandidMeta[] ): (a: Tuple, b: Tuple) => boolean { return (a: Tuple, b: Tuple): boolean => { if (typeof a !== typeof b) { diff --git a/property_tests/arbitraries/candid/constructed/variant_arb.ts b/property_tests/arbitraries/candid/constructed/variant_arb.ts index 6fd0203342..6a5bc92cf3 100644 --- a/property_tests/arbitraries/candid/constructed/variant_arb.ts +++ b/property_tests/arbitraries/candid/constructed/variant_arb.ts @@ -1,5 +1,5 @@ import fc from 'fast-check'; -import { Candid } from '../candid_arb'; +import { CandidMeta } from '../candid_arb'; import { CandidType, CandidTypeArb } from '../candid_type_arb'; import { UniqueIdentifierArb } from '../../unique_identifier_arb'; import { JsFunctionNameArb } from '../../js_function_name_arb'; @@ -7,7 +7,7 @@ import { JsFunctionNameArb } from '../../js_function_name_arb'; export type Variant = { [x: string]: CandidType; }; -type Field = [string, Candid]; +type Field = [string, CandidMeta]; export const VariantArb = fc .tuple( @@ -20,7 +20,7 @@ export const VariantArb = fc // an empty object. }) ) - .map(([name, fields]): Candid => { + .map(([name, fields]): CandidMeta => { const randomIndex = Math.floor(Math.random() * fields.length); const typeDeclaration = generateTypeDeclaration(name, fields); diff --git a/property_tests/arbitraries/candid/constructed/vec_arb.ts b/property_tests/arbitraries/candid/constructed/vec_arb.ts index b48076eeee..a90afaa271 100644 --- a/property_tests/arbitraries/candid/constructed/vec_arb.ts +++ b/property_tests/arbitraries/candid/constructed/vec_arb.ts @@ -10,7 +10,7 @@ import { Nat16Arb } from '../primitive/nats/nat16_arb'; import { Nat32Arb } from '../primitive/nats/nat32_arb'; import { Nat64Arb } from '../primitive/nats/nat64_arb'; import { PrincipalArb } from '../reference/principal_arb'; -import { Candid } from '../candid_arb'; +import { CandidMeta } from '../candid_arb'; import { BoolArb } from '../primitive/bool'; import { Float32Arb } from '../primitive/floats/float32_arb'; import { Float64Arb } from '../primitive/floats/float64_arb'; @@ -18,32 +18,37 @@ import { NullArb } from '../primitive/null'; import { TextArb } from '../primitive/text'; import { deepEqual } from 'fast-equals'; import { BlobArb } from './blob_arb'; +import { CandidType } from '../candid_type_arb'; -const VecInnerArb = (arb: fc.Arbitrary>) => { - return fc.tuple(fc.array(arb), arb).map(([sample, src]): Candid => { - const equals = generateEquals(sample); - const valueLiteral = generateValueLiteral(sample); +const VecInnerArb = ( + arb: fc.Arbitrary> +) => { + return fc + .tuple(fc.array(arb), arb) + .map(([sample, src]): CandidMeta => { + const equals = generateEquals(sample); + const valueLiteral = generateValueLiteral(sample); - return { - value: sample.map((sample) => sample.value), - src: { - candidType: `Vec(${src.src.candidType})`, - imports: new Set([...src.src.imports, 'Vec']), - valueLiteral - }, - equals - }; - }); + return { + value: sample.map((sample) => sample.value), + src: { + candidType: `Vec(${src.src.candidType})`, + imports: new Set([...src.src.imports, 'Vec']), + valueLiteral + }, + equals + }; + }); }; -function generateValueLiteral(sample: Candid[]) { +function generateValueLiteral(sample: CandidMeta[]) { const valueLiterals = sample .map((sample) => sample.src.valueLiteral) .join(','); return `[${valueLiterals}]`; } -function generateEquals(sample: Candid[]) { +function generateEquals(sample: CandidMeta[]) { return (a: T[], b: T[]) => arraysAreEqual(a, b, sample[0]?.equals ?? deepEqual); } diff --git a/property_tests/arbitraries/candid/primitive/bool.ts b/property_tests/arbitraries/candid/primitive/bool.ts index 41cac87d3d..b2c914b567 100644 --- a/property_tests/arbitraries/candid/primitive/bool.ts +++ b/property_tests/arbitraries/candid/primitive/bool.ts @@ -1,5 +1,5 @@ import fc from 'fast-check'; -import { CandidArb } from '../candid_arb'; +import { CandidMetaArb } from '../candid_arb'; import { booleanToSrcLiteral } from '../to_src_literal/boolean'; -export const BoolArb = CandidArb(fc.boolean(), 'bool', booleanToSrcLiteral); +export const BoolArb = CandidMetaArb(fc.boolean(), 'bool', booleanToSrcLiteral); diff --git a/property_tests/arbitraries/candid/primitive/floats/float32_arb.ts b/property_tests/arbitraries/candid/primitive/floats/float32_arb.ts index 28c6a9d76f..5fe72a91fa 100644 --- a/property_tests/arbitraries/candid/primitive/floats/float32_arb.ts +++ b/property_tests/arbitraries/candid/primitive/floats/float32_arb.ts @@ -1,5 +1,9 @@ import fc from 'fast-check'; -import { CandidArb } from '../../candid_arb'; +import { CandidMetaArb } from '../../candid_arb'; import { floatToSrcLiteral } from '../../to_src_literal/float'; -export const Float32Arb = CandidArb(fc.float(), 'float32', floatToSrcLiteral); +export const Float32Arb = CandidMetaArb( + fc.float(), + 'float32', + floatToSrcLiteral +); diff --git a/property_tests/arbitraries/candid/primitive/floats/float64_arb.ts b/property_tests/arbitraries/candid/primitive/floats/float64_arb.ts index 4a917e0e58..4f4078c972 100644 --- a/property_tests/arbitraries/candid/primitive/floats/float64_arb.ts +++ b/property_tests/arbitraries/candid/primitive/floats/float64_arb.ts @@ -1,8 +1,8 @@ import fc from 'fast-check'; -import { CandidArb } from '../../candid_arb'; +import { CandidMetaArb } from '../../candid_arb'; import { floatToSrcLiteral } from '../../to_src_literal/float'; -export const Float64Arb = CandidArb( +export const Float64Arb = CandidMetaArb( fc.float64Array({ maxLength: 1, minLength: 1 }).map((sample) => sample[0]), 'float64', floatToSrcLiteral diff --git a/property_tests/arbitraries/candid/primitive/ints/int16_arb.ts b/property_tests/arbitraries/candid/primitive/ints/int16_arb.ts index 12bfe53cf2..6c7a54032a 100644 --- a/property_tests/arbitraries/candid/primitive/ints/int16_arb.ts +++ b/property_tests/arbitraries/candid/primitive/ints/int16_arb.ts @@ -1,5 +1,9 @@ import { numberToSrcLiteral } from '../../to_src_literal/number'; -import { CandidArb } from '../../candid_arb'; +import { CandidMetaArb } from '../../candid_arb'; import { NumberArb } from './'; -export const Int16Arb = CandidArb(NumberArb(16), 'int16', numberToSrcLiteral); +export const Int16Arb = CandidMetaArb( + NumberArb(16), + 'int16', + numberToSrcLiteral +); diff --git a/property_tests/arbitraries/candid/primitive/ints/int32_arb.ts b/property_tests/arbitraries/candid/primitive/ints/int32_arb.ts index aefdcf411b..6396827d36 100644 --- a/property_tests/arbitraries/candid/primitive/ints/int32_arb.ts +++ b/property_tests/arbitraries/candid/primitive/ints/int32_arb.ts @@ -1,5 +1,9 @@ import { numberToSrcLiteral } from '../../to_src_literal/number'; -import { CandidArb } from '../../candid_arb'; +import { CandidMetaArb } from '../../candid_arb'; import { NumberArb } from './'; -export const Int32Arb = CandidArb(NumberArb(32), 'int32', numberToSrcLiteral); +export const Int32Arb = CandidMetaArb( + NumberArb(32), + 'int32', + numberToSrcLiteral +); diff --git a/property_tests/arbitraries/candid/primitive/ints/int64_arb.ts b/property_tests/arbitraries/candid/primitive/ints/int64_arb.ts index 34509ba3d8..88b269430c 100644 --- a/property_tests/arbitraries/candid/primitive/ints/int64_arb.ts +++ b/property_tests/arbitraries/candid/primitive/ints/int64_arb.ts @@ -1,5 +1,9 @@ import fc from 'fast-check'; -import { CandidArb } from '../../candid_arb'; +import { CandidMetaArb } from '../../candid_arb'; import { bigintToSrcLiteral } from '../../to_src_literal/bigint'; -export const Int64Arb = CandidArb(fc.bigIntN(64), 'int64', bigintToSrcLiteral); +export const Int64Arb = CandidMetaArb( + fc.bigIntN(64), + 'int64', + bigintToSrcLiteral +); diff --git a/property_tests/arbitraries/candid/primitive/ints/int8_arb.ts b/property_tests/arbitraries/candid/primitive/ints/int8_arb.ts index bd4ecb668f..d2506756ac 100644 --- a/property_tests/arbitraries/candid/primitive/ints/int8_arb.ts +++ b/property_tests/arbitraries/candid/primitive/ints/int8_arb.ts @@ -1,5 +1,5 @@ import { numberToSrcLiteral } from '../../to_src_literal/number'; -import { CandidArb } from '../../candid_arb'; +import { CandidMetaArb } from '../../candid_arb'; import { NumberArb } from './'; -export const Int8Arb = CandidArb(NumberArb(8), 'int8', numberToSrcLiteral); +export const Int8Arb = CandidMetaArb(NumberArb(8), 'int8', numberToSrcLiteral); diff --git a/property_tests/arbitraries/candid/primitive/ints/int_arb.ts b/property_tests/arbitraries/candid/primitive/ints/int_arb.ts index 5556213dc6..92a310ce64 100644 --- a/property_tests/arbitraries/candid/primitive/ints/int_arb.ts +++ b/property_tests/arbitraries/candid/primitive/ints/int_arb.ts @@ -1,5 +1,5 @@ import fc from 'fast-check'; -import { CandidArb } from '../../candid_arb'; +import { CandidMetaArb } from '../../candid_arb'; import { bigintToSrcLiteral } from '../../to_src_literal/bigint'; -export const IntArb = CandidArb(fc.bigInt(), 'int', bigintToSrcLiteral); +export const IntArb = CandidMetaArb(fc.bigInt(), 'int', bigintToSrcLiteral); diff --git a/property_tests/arbitraries/candid/primitive/nats/nat16_arb.ts b/property_tests/arbitraries/candid/primitive/nats/nat16_arb.ts index 563859bfe1..9e108e1380 100644 --- a/property_tests/arbitraries/candid/primitive/nats/nat16_arb.ts +++ b/property_tests/arbitraries/candid/primitive/nats/nat16_arb.ts @@ -1,5 +1,9 @@ import { numberToSrcLiteral } from '../../to_src_literal/number'; -import { CandidArb } from '../../candid_arb'; +import { CandidMetaArb } from '../../candid_arb'; import { UNumberArb } from './index'; -export const Nat16Arb = CandidArb(UNumberArb(16), 'nat16', numberToSrcLiteral); +export const Nat16Arb = CandidMetaArb( + UNumberArb(16), + 'nat16', + numberToSrcLiteral +); diff --git a/property_tests/arbitraries/candid/primitive/nats/nat32_arb.ts b/property_tests/arbitraries/candid/primitive/nats/nat32_arb.ts index 1602c9d05b..83671ce36f 100644 --- a/property_tests/arbitraries/candid/primitive/nats/nat32_arb.ts +++ b/property_tests/arbitraries/candid/primitive/nats/nat32_arb.ts @@ -1,5 +1,9 @@ import { numberToSrcLiteral } from '../../to_src_literal/number'; -import { CandidArb } from '../../candid_arb'; +import { CandidMetaArb } from '../../candid_arb'; import { UNumberArb } from './index'; -export const Nat32Arb = CandidArb(UNumberArb(32), 'nat32', numberToSrcLiteral); +export const Nat32Arb = CandidMetaArb( + UNumberArb(32), + 'nat32', + numberToSrcLiteral +); diff --git a/property_tests/arbitraries/candid/primitive/nats/nat64_arb.ts b/property_tests/arbitraries/candid/primitive/nats/nat64_arb.ts index 01988e5791..e616bfec8a 100644 --- a/property_tests/arbitraries/candid/primitive/nats/nat64_arb.ts +++ b/property_tests/arbitraries/candid/primitive/nats/nat64_arb.ts @@ -1,5 +1,9 @@ import fc from 'fast-check'; -import { CandidArb } from '../../candid_arb'; +import { CandidMetaArb } from '../../candid_arb'; import { bigintToSrcLiteral } from '../../to_src_literal/bigint'; -export const Nat64Arb = CandidArb(fc.bigUintN(64), 'nat64', bigintToSrcLiteral); +export const Nat64Arb = CandidMetaArb( + fc.bigUintN(64), + 'nat64', + bigintToSrcLiteral +); diff --git a/property_tests/arbitraries/candid/primitive/nats/nat8_arb.ts b/property_tests/arbitraries/candid/primitive/nats/nat8_arb.ts index 4f8aba1af1..7ca00e794b 100644 --- a/property_tests/arbitraries/candid/primitive/nats/nat8_arb.ts +++ b/property_tests/arbitraries/candid/primitive/nats/nat8_arb.ts @@ -1,5 +1,5 @@ import { numberToSrcLiteral } from '../../to_src_literal/number'; -import { CandidArb } from '../../candid_arb'; +import { CandidMetaArb } from '../../candid_arb'; import { UNumberArb } from './index'; -export const Nat8Arb = CandidArb(UNumberArb(8), 'nat8', numberToSrcLiteral); +export const Nat8Arb = CandidMetaArb(UNumberArb(8), 'nat8', numberToSrcLiteral); diff --git a/property_tests/arbitraries/candid/primitive/nats/nat_arb.ts b/property_tests/arbitraries/candid/primitive/nats/nat_arb.ts index 29cdd0dddd..e1592dc47b 100644 --- a/property_tests/arbitraries/candid/primitive/nats/nat_arb.ts +++ b/property_tests/arbitraries/candid/primitive/nats/nat_arb.ts @@ -1,5 +1,5 @@ import fc from 'fast-check'; -import { CandidArb } from '../../candid_arb'; +import { CandidMetaArb } from '../../candid_arb'; import { bigintToSrcLiteral } from '../../to_src_literal/bigint'; -export const NatArb = CandidArb(fc.bigUint(), 'nat', bigintToSrcLiteral); +export const NatArb = CandidMetaArb(fc.bigUint(), 'nat', bigintToSrcLiteral); diff --git a/property_tests/arbitraries/candid/primitive/null.ts b/property_tests/arbitraries/candid/primitive/null.ts index 82f7df8232..c98466cd17 100644 --- a/property_tests/arbitraries/candid/primitive/null.ts +++ b/property_tests/arbitraries/candid/primitive/null.ts @@ -1,5 +1,9 @@ import fc from 'fast-check'; -import { CandidArb } from '../candid_arb'; +import { CandidMetaArb } from '../candid_arb'; import { nullToSrcLiteral } from '../to_src_literal/null'; -export const NullArb = CandidArb(fc.constant(null), 'Null', nullToSrcLiteral); +export const NullArb = CandidMetaArb( + fc.constant(null), + 'Null', + nullToSrcLiteral +); diff --git a/property_tests/arbitraries/candid/primitive/text.ts b/property_tests/arbitraries/candid/primitive/text.ts index 970686d23a..b68a28d6a8 100644 --- a/property_tests/arbitraries/candid/primitive/text.ts +++ b/property_tests/arbitraries/candid/primitive/text.ts @@ -1,5 +1,5 @@ import fc from 'fast-check'; -import { CandidArb } from '../candid_arb'; +import { CandidMetaArb } from '../candid_arb'; import { stringToSrcLiteral } from '../to_src_literal/string'; -export const TextArb = CandidArb(fc.string(), 'text', stringToSrcLiteral); +export const TextArb = CandidMetaArb(fc.string(), 'text', stringToSrcLiteral); diff --git a/property_tests/arbitraries/candid/primitive/void.ts b/property_tests/arbitraries/candid/primitive/void.ts index 0e9f2f4153..d39c1339d2 100644 --- a/property_tests/arbitraries/candid/primitive/void.ts +++ b/property_tests/arbitraries/candid/primitive/void.ts @@ -1,8 +1,8 @@ import fc from 'fast-check'; -import { CandidArb } from '../candid_arb'; +import { CandidMetaArb } from '../candid_arb'; import { voidToSrcLiteral } from '../to_src_literal/void'; -export const VoidArb = CandidArb( +export const VoidArb = CandidMetaArb( fc.constant(undefined), 'Void', voidToSrcLiteral diff --git a/property_tests/arbitraries/candid/reference/func_arb.ts b/property_tests/arbitraries/candid/reference/func_arb.ts index c5dc244958..28563251a9 100644 --- a/property_tests/arbitraries/candid/reference/func_arb.ts +++ b/property_tests/arbitraries/candid/reference/func_arb.ts @@ -3,7 +3,7 @@ import { Principal } from '@dfinity/principal'; import { PrincipalArb } from './principal_arb'; import { VoidArb } from '../primitive/void'; -import { Candid } from '../candid_arb'; +import { CandidMeta } from '../candid_arb'; import { CandidType, CandidTypeArb } from '../candid_type_arb'; import { UniqueIdentifierArb } from '../../unique_identifier_arb'; @@ -24,7 +24,7 @@ export const FuncArb = ( PrincipalArb ); }) - .map(([name, params, returnFunc, mode, principal]): Candid => { + .map(([name, params, returnFunc, mode, principal]): CandidMeta => { const typeDeclaration = generateTypeDeclaration( name, params, @@ -56,7 +56,7 @@ export const FuncArb = ( function generateTypeDeclaration( name: string, - paramCandids: Candid[], + paramCandids: CandidMeta[], returnType: string, mode: Mode ): string { diff --git a/property_tests/arbitraries/candid/reference/principal_arb.ts b/property_tests/arbitraries/candid/reference/principal_arb.ts index c9725ecc0e..2807ac105b 100644 --- a/property_tests/arbitraries/candid/reference/principal_arb.ts +++ b/property_tests/arbitraries/candid/reference/principal_arb.ts @@ -1,9 +1,9 @@ import fc from 'fast-check'; import { Principal } from '@dfinity/principal'; -import { CandidArb } from '../candid_arb'; +import { CandidMetaArb } from '../candid_arb'; import { principalToSrcLiteral } from '../to_src_literal/principal'; -export const PrincipalArb = CandidArb( +export const PrincipalArb = CandidMetaArb( fc .uint8Array({ minLength: 29, diff --git a/property_tests/tests/blob/test/test.ts b/property_tests/tests/blob/test/test.ts index 12ab385ae6..9d40974a7f 100644 --- a/property_tests/tests/blob/test/test.ts +++ b/property_tests/tests/blob/test/test.ts @@ -5,7 +5,7 @@ import { JsFunctionNameArb } from '../../../arbitraries/js_function_name_arb'; import { TestSample } from '../../../arbitraries/test_sample_arb'; import { createUniquePrimitiveArb } from '../../../arbitraries/unique_primitive_arb'; import { getActor, runPropTests } from '../../../../property_tests'; -import { Candid } from '../../../arbitraries/candid/candid_arb'; +import { CandidMeta } from '../../../arbitraries/candid/candid_arb'; import { Test } from '../../../../test'; const BlobTestArb = fc @@ -39,8 +39,8 @@ runPropTests(BlobTestArb); function generateBody( paramNames: string[], - paramBlobs: Candid[], - returnBlob: Candid + paramBlobs: CandidMeta[], + returnBlob: CandidMeta ): string { // TODO these checks should be much more precise probably, imagine checking the elements inside of the arrays const paramsAreUint8Arrays = paramNames @@ -77,8 +77,8 @@ function generateBody( function generateTest( functionName: string, - paramBlobs: Candid[], - returnBlob: Candid + paramBlobs: CandidMeta[], + returnBlob: CandidMeta ): Test { const expectedResult = Uint8Array.from( paramBlobs diff --git a/property_tests/tests/bool/test/test.ts b/property_tests/tests/bool/test/test.ts index 0efb1c854a..236785d67b 100644 --- a/property_tests/tests/bool/test/test.ts +++ b/property_tests/tests/bool/test/test.ts @@ -5,7 +5,7 @@ import { JsFunctionNameArb } from '../../../arbitraries/js_function_name_arb'; import { TestSample } from '../../../arbitraries/test_sample_arb'; import { createUniquePrimitiveArb } from '../../../arbitraries/unique_primitive_arb'; import { getActor, runPropTests } from '../../../../property_tests'; -import { Candid } from '../../../arbitraries/candid/candid_arb'; +import { CandidMeta } from '../../../arbitraries/candid/candid_arb'; import { Test } from '../../../../test'; const BoolTestArb = fc @@ -43,8 +43,8 @@ runPropTests(BoolTestArb); function generateBody( paramNames: string[], - paramBools: Candid[], - returnBool: Candid + paramBools: CandidMeta[], + returnBool: CandidMeta ): string { // TODO do we want to encapsulate 'boolean' in the CandidArb? Like an agentType instead of a candidType, like azleValue and agentValue? // TODO or will this not matter anymore once we start using a deep equal library @@ -76,8 +76,8 @@ function generateBody( function generateTest( functionName: string, - paramBools: Candid[], - returnBool: Candid + paramBools: CandidMeta[], + returnBool: CandidMeta ): Test { const expectedResult = paramBools.reduce( (acc, bool) => acc && bool.value, diff --git a/property_tests/tests/float32/test/test.ts b/property_tests/tests/float32/test/test.ts index 6403bd579e..7b73a530b1 100644 --- a/property_tests/tests/float32/test/test.ts +++ b/property_tests/tests/float32/test/test.ts @@ -6,7 +6,7 @@ import { JsFunctionNameArb } from '../../../arbitraries/js_function_name_arb'; import { TestSample } from '../../../arbitraries/test_sample_arb'; import { createUniquePrimitiveArb } from '../../../arbitraries/unique_primitive_arb'; import { getActor, runPropTests } from '../../../../property_tests'; -import { Candid } from '../../../arbitraries/candid/candid_arb'; +import { CandidMeta } from '../../../arbitraries/candid/candid_arb'; import { Test } from '../../../../test'; const Float32TestArb = fc @@ -52,8 +52,8 @@ runPropTests(Float32TestArb); function generateBody( paramNames: string[], - paramFloat32s: Candid[], - returnFloat32: Candid + paramFloat32s: CandidMeta[], + returnFloat32: CandidMeta ): string { const paramsAreNumbers = paramNames .map((paramName) => { @@ -90,8 +90,8 @@ function generateBody( function generateTest( functionName: string, - paramFloat32s: Candid[], - returnFloat32: Candid + paramFloat32s: CandidMeta[], + returnFloat32: CandidMeta ): Test { const expectedResult = paramFloat32s.length === 0 diff --git a/property_tests/tests/float64/test/test.ts b/property_tests/tests/float64/test/test.ts index f7dd9d1f86..c178659fa3 100644 --- a/property_tests/tests/float64/test/test.ts +++ b/property_tests/tests/float64/test/test.ts @@ -6,7 +6,7 @@ import { JsFunctionNameArb } from '../../../arbitraries/js_function_name_arb'; import { TestSample } from '../../../arbitraries/test_sample_arb'; import { createUniquePrimitiveArb } from '../../../arbitraries/unique_primitive_arb'; import { getActor, runPropTests } from '../../../../property_tests'; -import { Candid } from '../../../arbitraries/candid/candid_arb'; +import { CandidMeta } from '../../../arbitraries/candid/candid_arb'; import { Test } from '../../../../test'; const Float64TestArb = fc @@ -52,8 +52,8 @@ runPropTests(Float64TestArb); function generateBody( paramNames: string[], - paramFloat64s: Candid[], - returnFloat64: Candid + paramFloat64s: CandidMeta[], + returnFloat64: CandidMeta ): string { const paramsAreNumbers = paramNames .map((paramName) => { @@ -91,8 +91,8 @@ function generateBody( function generateTest( functionName: string, - paramFloat64s: Candid[], - returnFloat64: Candid + paramFloat64s: CandidMeta[], + returnFloat64: CandidMeta ): Test { const count = paramFloat64s.length + 1; const expectedResult = diff --git a/property_tests/tests/func/test/test.ts b/property_tests/tests/func/test/test.ts index 3ccb140704..17aa0d22d3 100644 --- a/property_tests/tests/func/test/test.ts +++ b/property_tests/tests/func/test/test.ts @@ -1,7 +1,7 @@ import fc from 'fast-check'; import { getActor, runPropTests } from '../../..'; -import { Candid } from '../../../arbitraries/candid/candid_arb'; +import { CandidMeta } from '../../../arbitraries/candid/candid_arb'; import { FuncArb, Func } from '../../../arbitraries/candid/reference/func_arb'; import { TestSample } from '../../../arbitraries/test_sample_arb'; import { UniqueIdentifierArb } from '../../../arbitraries/unique_identifier_arb'; @@ -61,7 +61,10 @@ const FuncTestArb = fc runPropTests(FuncTestArb); -function generateBody(funcs: Candid[], returnFunc: Candid): string { +function generateBody( + funcs: CandidMeta[], + returnFunc: CandidMeta +): string { const paramsAreFuncs = funcs .map((_, index) => { const paramName = `param${index}`; @@ -112,8 +115,8 @@ function generateBody(funcs: Candid[], returnFunc: Candid): string { function generateTest( functionName: string, - funcs: Candid[], - returnFunc: Candid + funcs: CandidMeta[], + returnFunc: CandidMeta ): Test { return { name: `func ${functionName}`, diff --git a/property_tests/tests/int/test/test.ts b/property_tests/tests/int/test/test.ts index 201b5423de..e56811b83e 100644 --- a/property_tests/tests/int/test/test.ts +++ b/property_tests/tests/int/test/test.ts @@ -5,7 +5,7 @@ import { JsFunctionNameArb } from '../../../arbitraries/js_function_name_arb'; import { TestSample } from '../../../arbitraries/test_sample_arb'; import { createUniquePrimitiveArb } from '../../../arbitraries/unique_primitive_arb'; import { getActor, runPropTests } from '../../../../property_tests'; -import { Candid } from '../../../arbitraries/candid/candid_arb'; +import { CandidMeta } from '../../../arbitraries/candid/candid_arb'; import { Test } from '../../../../test'; const IntTestArb = fc @@ -43,8 +43,8 @@ runPropTests(IntTestArb); function generateBody( paramNames: string[], - paramInts: Candid[], - returnInt: Candid + paramInts: CandidMeta[], + returnInt: CandidMeta ): string { const paramsAreBigInts = paramNames .map((paramName) => { @@ -74,8 +74,8 @@ function generateBody( function generateTest( functionName: string, - paramInts: Candid[], - returnInt: Candid + paramInts: CandidMeta[], + returnInt: CandidMeta ): Test { const expectedResult = paramInts.reduce( (acc, int) => acc + int.value, diff --git a/property_tests/tests/int16/test/test.ts b/property_tests/tests/int16/test/test.ts index 6e36f54491..6048748e77 100644 --- a/property_tests/tests/int16/test/test.ts +++ b/property_tests/tests/int16/test/test.ts @@ -5,7 +5,7 @@ import { JsFunctionNameArb } from '../../../arbitraries/js_function_name_arb'; import { TestSample } from '../../../arbitraries/test_sample_arb'; import { createUniquePrimitiveArb } from '../../../arbitraries/unique_primitive_arb'; import { getActor, runPropTests } from '../../../../property_tests'; -import { Candid } from '../../../arbitraries/candid/candid_arb'; +import { CandidMeta } from '../../../arbitraries/candid/candid_arb'; import { Test } from '../../../../test'; const Int16TestArb = fc @@ -47,8 +47,8 @@ runPropTests(Int16TestArb); function generateBody( paramNames: string[], - paramInt16s: Candid[], - returnInt16: Candid + paramInt16s: CandidMeta[], + returnInt16: CandidMeta ): string { const paramsAreNumbers = paramNames .map((paramName) => { @@ -82,8 +82,8 @@ function generateBody( function generateTest( functionName: string, - paramInt16s: Candid[], - returnInt16: Candid + paramInt16s: CandidMeta[], + returnInt16: CandidMeta ): Test { const count = paramInt16s.length + 1; const expectedResult = Math.floor( diff --git a/property_tests/tests/int32/test/test.ts b/property_tests/tests/int32/test/test.ts index 7453504286..11c736d144 100644 --- a/property_tests/tests/int32/test/test.ts +++ b/property_tests/tests/int32/test/test.ts @@ -5,7 +5,7 @@ import { JsFunctionNameArb } from '../../../arbitraries/js_function_name_arb'; import { TestSample } from '../../../arbitraries/test_sample_arb'; import { createUniquePrimitiveArb } from '../../../arbitraries/unique_primitive_arb'; import { getActor, runPropTests } from '../../../../property_tests'; -import { Candid } from '../../../arbitraries/candid/candid_arb'; +import { CandidMeta } from '../../../arbitraries/candid/candid_arb'; import { Test } from '../../../../test'; const Int32TestArb = fc @@ -47,8 +47,8 @@ runPropTests(Int32TestArb); function generateBody( paramNames: string[], - paramInt32s: Candid[], - returnInt32: Candid + paramInt32s: CandidMeta[], + returnInt32: CandidMeta ): string { const paramsAreNumbers = paramNames .map((paramName) => { @@ -80,8 +80,8 @@ function generateBody( function generateTest( functionName: string, - paramInt32s: Candid[], - returnInt32: Candid + paramInt32s: CandidMeta[], + returnInt32: CandidMeta ): Test { const count = paramInt32s.length + 1; const expectedResult = Math.floor( diff --git a/property_tests/tests/int64/test/test.ts b/property_tests/tests/int64/test/test.ts index 7b05d08064..0c432809b9 100644 --- a/property_tests/tests/int64/test/test.ts +++ b/property_tests/tests/int64/test/test.ts @@ -5,7 +5,7 @@ import { JsFunctionNameArb } from '../../../arbitraries/js_function_name_arb'; import { TestSample } from '../../../arbitraries/test_sample_arb'; import { createUniquePrimitiveArb } from '../../../arbitraries/unique_primitive_arb'; import { getActor, runPropTests } from '../../../../property_tests'; -import { Candid } from '../../../arbitraries/candid/candid_arb'; +import { CandidMeta } from '../../../arbitraries/candid/candid_arb'; import { Test } from '../../../../test'; const Int64TestArb = fc @@ -47,8 +47,8 @@ runPropTests(Int64TestArb); function generateBody( paramNames: string[], - paramInt64s: Candid[], - returnInt64: Candid + paramInt64s: CandidMeta[], + returnInt64: CandidMeta ): string { const paramsAreBigInts = paramNames .map((paramName) => { @@ -81,8 +81,8 @@ function generateBody( function generateTest( functionName: string, - paramInt64s: Candid[], - returnInt64: Candid + paramInt64s: CandidMeta[], + returnInt64: CandidMeta ): Test { const count = paramInt64s.length + 1; const expectedResult = diff --git a/property_tests/tests/int8/test/test.ts b/property_tests/tests/int8/test/test.ts index c1ac17d2f2..735652cc50 100644 --- a/property_tests/tests/int8/test/test.ts +++ b/property_tests/tests/int8/test/test.ts @@ -5,7 +5,7 @@ import { JsFunctionNameArb } from '../../../arbitraries/js_function_name_arb'; import { TestSample } from '../../../arbitraries/test_sample_arb'; import { createUniquePrimitiveArb } from '../../../arbitraries/unique_primitive_arb'; import { getActor, runPropTests } from '../../../../property_tests'; -import { Candid } from '../../../arbitraries/candid/candid_arb'; +import { CandidMeta } from '../../../arbitraries/candid/candid_arb'; import { Test } from '../../../../test'; const Int8TestArb = fc @@ -43,8 +43,8 @@ runPropTests(Int8TestArb); function generateBody( paramNames: string[], - paramInt8s: Candid[], - returnInt8: Candid + paramInt8s: CandidMeta[], + returnInt8: CandidMeta ): string { const paramsAreNumbers = paramNames .map((paramName) => { @@ -77,8 +77,8 @@ function generateBody( function generateTest( functionName: string, - paramInt8s: Candid[], - returnInt8: Candid + paramInt8s: CandidMeta[], + returnInt8: CandidMeta ): Test { const count = paramInt8s.length + 1; const expectedResult = Math.floor( diff --git a/property_tests/tests/nat/test/test.ts b/property_tests/tests/nat/test/test.ts index 6ce8897a31..5466e9bfbc 100644 --- a/property_tests/tests/nat/test/test.ts +++ b/property_tests/tests/nat/test/test.ts @@ -5,7 +5,7 @@ import { JsFunctionNameArb } from '../../../arbitraries/js_function_name_arb'; import { TestSample } from '../../../arbitraries/test_sample_arb'; import { createUniquePrimitiveArb } from '../../../arbitraries/unique_primitive_arb'; import { getActor, runPropTests } from '../../../../property_tests'; -import { Candid } from '../../../arbitraries/candid/candid_arb'; +import { CandidMeta } from '../../../arbitraries/candid/candid_arb'; import { Test } from '../../../../test'; const NatTestArb = fc @@ -43,8 +43,8 @@ runPropTests(NatTestArb); function generateBody( paramNames: string[], - paramNats: Candid[], - returnNat: Candid + paramNats: CandidMeta[], + returnNat: CandidMeta ): string { const paramsAreBigInts = paramNames .map((paramName) => { @@ -74,8 +74,8 @@ function generateBody( function generateTest( functionName: string, - paramNats: Candid[], - returnNat: Candid + paramNats: CandidMeta[], + returnNat: CandidMeta ): Test { const expectedResult = paramNats.reduce( (acc, nat) => acc + nat.value, diff --git a/property_tests/tests/nat16/test/test.ts b/property_tests/tests/nat16/test/test.ts index 7391077466..585209e7be 100644 --- a/property_tests/tests/nat16/test/test.ts +++ b/property_tests/tests/nat16/test/test.ts @@ -5,7 +5,7 @@ import { JsFunctionNameArb } from '../../../arbitraries/js_function_name_arb'; import { TestSample } from '../../../arbitraries/test_sample_arb'; import { createUniquePrimitiveArb } from '../../../arbitraries/unique_primitive_arb'; import { getActor, runPropTests } from '../../../../property_tests'; -import { Candid } from '../../../arbitraries/candid/candid_arb'; +import { CandidMeta } from '../../../arbitraries/candid/candid_arb'; import { Test } from '../../../../test'; const Nat16TestArb = fc @@ -47,8 +47,8 @@ runPropTests(Nat16TestArb); function generateBody( paramNames: string[], - paramNat16s: Candid[], - returnNat16: Candid + paramNat16s: CandidMeta[], + returnNat16: CandidMeta ): string { const paramsAreNumbers = paramNames .map((paramName) => { @@ -80,8 +80,8 @@ function generateBody( function generateTest( functionName: string, - paramNat16s: Candid[], - returnNat16: Candid + paramNat16s: CandidMeta[], + returnNat16: CandidMeta ): Test { const count = paramNat16s.length + 1; const expectedResult = Math.floor( diff --git a/property_tests/tests/nat32/test/test.ts b/property_tests/tests/nat32/test/test.ts index 758b0c9688..3fd3bd2c0b 100644 --- a/property_tests/tests/nat32/test/test.ts +++ b/property_tests/tests/nat32/test/test.ts @@ -5,7 +5,7 @@ import { JsFunctionNameArb } from '../../../arbitraries/js_function_name_arb'; import { TestSample } from '../../../arbitraries/test_sample_arb'; import { createUniquePrimitiveArb } from '../../../arbitraries/unique_primitive_arb'; import { getActor, runPropTests } from '../../..'; -import { Candid } from '../../../arbitraries/candid/candid_arb'; +import { CandidMeta } from '../../../arbitraries/candid/candid_arb'; import { Test } from '../../../../test'; const Nat32TestArb = fc @@ -47,8 +47,8 @@ runPropTests(Nat32TestArb); function generateBody( paramNames: string[], - paramNat32s: Candid[], - returnNat32: Candid + paramNat32s: CandidMeta[], + returnNat32: CandidMeta ): string { const paramsAreNumbers = paramNames .map((paramName) => { @@ -81,8 +81,8 @@ function generateBody( function generateTest( functionName: string, - paramNat32s: Candid[], - returnNat32: Candid + paramNat32s: CandidMeta[], + returnNat32: CandidMeta ): Test { const count = paramNat32s.length + 1; const expectedResult = Math.floor( diff --git a/property_tests/tests/nat64/test/test.ts b/property_tests/tests/nat64/test/test.ts index 5923238510..3b443ba58a 100644 --- a/property_tests/tests/nat64/test/test.ts +++ b/property_tests/tests/nat64/test/test.ts @@ -5,7 +5,7 @@ import { JsFunctionNameArb } from '../../../arbitraries/js_function_name_arb'; import { TestSample } from '../../../arbitraries/test_sample_arb'; import { createUniquePrimitiveArb } from '../../../arbitraries/unique_primitive_arb'; import { getActor, runPropTests } from '../../../../property_tests'; -import { Candid } from '../../../arbitraries/candid/candid_arb'; +import { CandidMeta } from '../../../arbitraries/candid/candid_arb'; import { Test } from '../../../../test'; const Nat64TestArb = fc @@ -47,8 +47,8 @@ runPropTests(Nat64TestArb); function generateBody( paramNames: string[], - paramNat64s: Candid[], - returnNat64: Candid + paramNat64s: CandidMeta[], + returnNat64: CandidMeta ): string { const paramsAreBigInts = paramNames .map((paramName) => { @@ -80,8 +80,8 @@ function generateBody( function generateTest( functionName: string, - paramNat64s: Candid[], - returnNat64: Candid + paramNat64s: CandidMeta[], + returnNat64: CandidMeta ): Test { const count = paramNat64s.length + 1; const expectedResult = diff --git a/property_tests/tests/nat8/test/test.ts b/property_tests/tests/nat8/test/test.ts index c8acd849ef..1c337c78e2 100644 --- a/property_tests/tests/nat8/test/test.ts +++ b/property_tests/tests/nat8/test/test.ts @@ -5,7 +5,7 @@ import { JsFunctionNameArb } from '../../../arbitraries/js_function_name_arb'; import { TestSample } from '../../../arbitraries/test_sample_arb'; import { createUniquePrimitiveArb } from '../../../arbitraries/unique_primitive_arb'; import { getActor, runPropTests } from '../../../../property_tests'; -import { Candid } from '../../../arbitraries/candid/candid_arb'; +import { CandidMeta } from '../../../arbitraries/candid/candid_arb'; import { Test } from '../../../../test'; const Nat8TestArb = fc @@ -43,8 +43,8 @@ runPropTests(Nat8TestArb); function generateBody( paramNames: string[], - paramNat8s: Candid[], - returnNat8: Candid + paramNat8s: CandidMeta[], + returnNat8: CandidMeta ): string { const paramsAreNumbers = paramNames .map((paramName) => { @@ -76,8 +76,8 @@ function generateBody( function generateTest( functionName: string, - paramNat8s: Candid[], - returnNat8: Candid + paramNat8s: CandidMeta[], + returnNat8: CandidMeta ): Test { const count = paramNat8s.length + 1; const expectedResult = Math.floor( diff --git a/property_tests/tests/null/test/test.ts b/property_tests/tests/null/test/test.ts index 790212e58e..c39527a259 100644 --- a/property_tests/tests/null/test/test.ts +++ b/property_tests/tests/null/test/test.ts @@ -5,7 +5,7 @@ import { JsFunctionNameArb } from '../../../arbitraries/js_function_name_arb'; import { TestSample } from '../../../arbitraries/test_sample_arb'; import { createUniquePrimitiveArb } from '../../../arbitraries/unique_primitive_arb'; import { getActor, runPropTests } from '../../../../property_tests'; -import { Candid } from '../../../arbitraries/candid/candid_arb'; +import { CandidMeta } from '../../../arbitraries/candid/candid_arb'; import { Test } from '../../../../test'; const NullTestArb = fc @@ -41,7 +41,10 @@ const NullTestArb = fc runPropTests(NullTestArb); -function generateBody(paramNames: string[], returnNull: Candid): string { +function generateBody( + paramNames: string[], + returnNull: CandidMeta +): string { const areAllNull = paramNames.reduce((acc, paramName) => { return `${acc} && ${paramName} === null`; }, 'true'); @@ -57,8 +60,8 @@ function generateBody(paramNames: string[], returnNull: Candid): string { function generateTest( functionName: string, - paramNulls: Candid[], - returnNull: Candid + paramNulls: CandidMeta[], + returnNull: CandidMeta ): Test { return { name: `test ${functionName}`, diff --git a/property_tests/tests/opt/test/test.ts b/property_tests/tests/opt/test/test.ts index e9cb31dd90..1cdeb0524a 100644 --- a/property_tests/tests/opt/test/test.ts +++ b/property_tests/tests/opt/test/test.ts @@ -9,7 +9,7 @@ import { JsFunctionNameArb } from '../../../arbitraries/js_function_name_arb'; import { TestSample } from '../../../arbitraries/test_sample_arb'; import { createUniquePrimitiveArb } from '../../../arbitraries/unique_primitive_arb'; import { getActor, runPropTests } from '../../../../property_tests'; -import { Candid } from '../../../arbitraries/candid/candid_arb'; +import { CandidMeta } from '../../../arbitraries/candid/candid_arb'; import { Test } from '../../../../test'; const OptTestArb = fc @@ -58,8 +58,8 @@ function isParamOpt(paramName: string): string { function generateBody( paramNames: string[], - paramOpts: Candid[], - returnOpt: Candid + paramOpts: CandidMeta[], + returnOpt: CandidMeta ): string { const areParamsOpts = paramNames .map((paramName) => { @@ -93,8 +93,8 @@ function generateBody( function generateTest( functionName: string, - paramOpts: Candid[], - returnOpt: Candid + paramOpts: CandidMeta[], + returnOpt: CandidMeta ): Test { const expectedResult = paramOpts.length === 0 ? returnOpt.value : paramOpts[0].value; diff --git a/property_tests/tests/principal/test/test.ts b/property_tests/tests/principal/test/test.ts index ca7843d9dd..e5349d8a92 100644 --- a/property_tests/tests/principal/test/test.ts +++ b/property_tests/tests/principal/test/test.ts @@ -8,7 +8,7 @@ import { TestSample } from '../../../arbitraries/test_sample_arb'; import { createUniquePrimitiveArb } from '../../../arbitraries/unique_primitive_arb'; import { getActor, runPropTests } from '../../../../property_tests'; import { Principal } from '@dfinity/principal'; -import { Candid } from '../../../arbitraries/candid/candid_arb'; +import { CandidMeta } from '../../../arbitraries/candid/candid_arb'; import { Test } from '../../../../test'; const PrincipalTestArb = fc @@ -62,8 +62,8 @@ runPropTests(PrincipalTestArb); function generateBody( paramNames: string[], - paramPrincipals: Candid[], - returnPrincipal: Candid + paramPrincipals: CandidMeta[], + returnPrincipal: CandidMeta ): string { const paramsArePrincipals = paramNames .map((paramName) => { @@ -98,8 +98,8 @@ function generateBody( function generateTest( functionName: string, - paramPrincipals: Candid[], - returnPrincipal: Candid + paramPrincipals: CandidMeta[], + returnPrincipal: CandidMeta ): Test { const expectedResult = paramPrincipals.length > 0 diff --git a/property_tests/tests/record/test/test.ts b/property_tests/tests/record/test/test.ts index 4f90f408bc..30d5d04442 100644 --- a/property_tests/tests/record/test/test.ts +++ b/property_tests/tests/record/test/test.ts @@ -8,7 +8,7 @@ import { TestSample } from '../../../arbitraries/test_sample_arb'; import { UniqueIdentifierArb } from '../../../arbitraries/unique_identifier_arb'; import { getActor, runPropTests } from '../../..'; import { AzleResult, Test } from '../../../../test'; -import { Candid } from '../../../arbitraries/candid/candid_arb'; +import { CandidMeta } from '../../../arbitraries/candid/candid_arb'; const RecordTestArb = fc .tuple( @@ -58,8 +58,8 @@ const RecordTestArb = fc runPropTests(RecordTestArb); function generateBody( - paramRecords: Candid[], - returnRecord: Candid + paramRecords: CandidMeta[], + returnRecord: CandidMeta ): string { const paramsAreRecords = paramRecords .map((record, index) => { @@ -108,8 +108,8 @@ function generateBody( function generateTest( functionName: string, - paramRecords: Candid[], - returnRecord: Candid + paramRecords: CandidMeta[], + returnRecord: CandidMeta ): Test { return { name: `record ${functionName}`, diff --git a/property_tests/tests/text/test/test.ts b/property_tests/tests/text/test/test.ts index dd55927f8c..291a16f7d7 100644 --- a/property_tests/tests/text/test/test.ts +++ b/property_tests/tests/text/test/test.ts @@ -5,7 +5,7 @@ import { JsFunctionNameArb } from '../../../arbitraries/js_function_name_arb'; import { createUniquePrimitiveArb } from '../../../arbitraries/unique_primitive_arb'; import { TestSample } from '../../../arbitraries/test_sample_arb'; import { getActor, runPropTests } from '../../../../property_tests'; -import { Candid } from '../../../arbitraries/candid/candid_arb'; +import { CandidMeta } from '../../../arbitraries/candid/candid_arb'; import { Test } from '../../../../test'; const TextTestArb = fc @@ -43,8 +43,8 @@ runPropTests(TextTestArb); function generateBody( paramNames: string[], - paramTexts: Candid[], - returnText: Candid + paramTexts: CandidMeta[], + returnText: CandidMeta ): string { const paramsAreStrings = paramNames .map((paramName) => { @@ -75,8 +75,8 @@ function generateBody( function generateTest( functionName: string, - paramTexts: Candid[], - returnTexts: Candid + paramTexts: CandidMeta[], + returnTexts: CandidMeta ): Test { const expectedResult = paramTexts.reduce( (acc, text) => acc + text.value, diff --git a/property_tests/tests/tuple/test/test.ts b/property_tests/tests/tuple/test/test.ts index fbf730e414..b869abf765 100644 --- a/property_tests/tests/tuple/test/test.ts +++ b/property_tests/tests/tuple/test/test.ts @@ -8,7 +8,7 @@ import { TestSample } from '../../../arbitraries/test_sample_arb'; import { UniqueIdentifierArb } from '../../../arbitraries/unique_identifier_arb'; import { getActor, runPropTests } from '../../..'; import { AzleResult, Test } from '../../../../test'; -import { Candid } from '../../../arbitraries/candid/candid_arb'; +import { CandidMeta } from '../../../arbitraries/candid/candid_arb'; const TupleTestArb = fc .tuple( @@ -58,8 +58,8 @@ const TupleTestArb = fc runPropTests(TupleTestArb); function generateBody( - paramTuples: Candid[], - returnTuple: Candid + paramTuples: CandidMeta[], + returnTuple: CandidMeta ): string { const paramsAreTuples = paramTuples .map((tuple, index) => { @@ -100,8 +100,8 @@ function generateBody( function generateTest( functionName: string, - paramTuples: Candid[], - returnTuple: Candid + paramTuples: CandidMeta[], + returnTuple: CandidMeta ): Test { const expectedResult = returnTuple.value; diff --git a/property_tests/tests/variant/test/test.ts b/property_tests/tests/variant/test/test.ts index 9d9491ddec..716edf272c 100644 --- a/property_tests/tests/variant/test/test.ts +++ b/property_tests/tests/variant/test/test.ts @@ -7,7 +7,7 @@ import { import { TestSample } from '../../../arbitraries/test_sample_arb'; import { UniqueIdentifierArb } from '../../../arbitraries/unique_identifier_arb'; import { getActor, runPropTests } from '../../../../property_tests'; -import { Candid } from '../../../arbitraries/candid/candid_arb'; +import { CandidMeta } from '../../../arbitraries/candid/candid_arb'; import { Test } from '../../../../test'; const VariantTestArb = fc @@ -68,8 +68,8 @@ runPropTests(VariantTestArb); function generateBody( paramNames: string[], - paramVariants: Candid[], - returnVariant: Candid + paramVariants: CandidMeta[], + returnVariant: CandidMeta ): string { const paramsAreVariants = paramNames .map((paramName) => { @@ -102,8 +102,8 @@ function generateBody( function generateTest( functionName: string, - paramVariants: Candid[], - returnVariant: Candid + paramVariants: CandidMeta[], + returnVariant: CandidMeta ): Test { const expectedResult = paramVariants[0]?.value ?? returnVariant.value; const equals = diff --git a/property_tests/tests/vec/test/test.ts b/property_tests/tests/vec/test/test.ts index 42d0db39cc..9d6ec0826e 100644 --- a/property_tests/tests/vec/test/test.ts +++ b/property_tests/tests/vec/test/test.ts @@ -6,7 +6,7 @@ import { TestSample } from '../../../arbitraries/test_sample_arb'; import { createUniquePrimitiveArb } from '../../../arbitraries/unique_primitive_arb'; import { getActor, runPropTests } from '../../../../property_tests'; import { deepEqual } from 'fast-equals'; -import { Candid } from '../../../arbitraries/candid/candid_arb'; +import { CandidMeta } from '../../../arbitraries/candid/candid_arb'; import { Test } from '../../../../test'; const VecTestArb = fc @@ -61,8 +61,8 @@ function blobsAreEqual(arr1: Uint8Array, arr2: Uint8Array) { function generateBody( paramNames: string[], - paramVecs: Candid[], - returnVec: Candid + paramVecs: CandidMeta[], + returnVec: CandidMeta ): string { // TODO these checks should be much more precise probably, imagine checking the elements inside of the arrays const paramsAreArrays = paramNames @@ -93,8 +93,8 @@ function generateBody( function generateTest( functionName: string, - paramVecs: Candid[], - returnVec: Candid + paramVecs: CandidMeta[], + returnVec: CandidMeta ): Test { const expectedResult = paramVecs[0]?.value ?? returnVec.value; const equals = paramVecs[0]?.equals ?? returnVec.equals;