From eac9de8e24154d6e862683ea9bfab9cf14aa65c8 Mon Sep 17 00:00:00 2001 From: Benjamin DeMann Date: Tue, 30 Jan 2024 15:10:10 -0700 Subject: [PATCH] quick fix for blob bug --- property_tests/arbitraries/canister_arb.ts | 27 +++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/property_tests/arbitraries/canister_arb.ts b/property_tests/arbitraries/canister_arb.ts index 08d72c1e6b..81acddc25e 100644 --- a/property_tests/arbitraries/canister_arb.ts +++ b/property_tests/arbitraries/canister_arb.ts @@ -6,7 +6,12 @@ import { InitMethod } from './canister_methods/init_method_arb'; import { PostUpgradeMethod } from './canister_methods/post_upgrade_arb'; import { PreUpgradeMethod } from './canister_methods/pre_upgrade_method_arb'; import { CorrespondingJSType } from './candid/corresponding_js_type'; -import { TextClass, FloatClass } from '@dfinity/candid/lib/cjs/idl'; +import { + TextClass, + FloatClass, + FixedNatClass, + VecClass +} from '@dfinity/candid/lib/cjs/idl'; TextClass.prototype.valueToString = (x): string => { return `"${escapeForBash(x)}"`; @@ -24,6 +29,26 @@ FloatClass.prototype.valueToString = (x): string => { return floatString + '.0'; }; +// Remove this when it is no longer necessary +// TODO https://github.com/demergent-labs/azle/issues/1597 +VecClass.prototype.valueToString = function (x): string { + const elements = Array.from(x).map((e): string => { + // @ts-ignore + return this._type.valueToString(e); + }); + return 'vec {' + elements.join('; ') + '}'; +}; + +// Remove this when it is no longer necessary +// TODO https://github.com/demergent-labs/azle/issues/1597 +FixedNatClass.prototype.valueToString = function (x): string { + const natString = x.toString(); + if (this._bits === 8) { + return `${natString}: nat8`; + } + return natString; +}; + export type Canister = { initArgs: string[] | undefined; postUpgradeArgs: string[] | undefined;