demergent-labs / azle

A WebAssembly runtime for TypeScript and JavaScript on ICP
MIT License
204 stars 37 forks source link

Bugs found during property testing #1388

Open lastmjs opened 1 year ago

lastmjs commented 1 year ago

During the initial phases of property testing, we have discovered that not all JavaScript function names can be Rust function names. The developer could create a valid canister method, and the Rust macro would break.

This should be solved if we can get rid of the Rust environment by shipping a Wasm to the developer and using indexes to call into functions. Otherwise we'd have to somehow map JS function names to Rust names.

lastmjs commented 1 year ago

The Vec(nat8) CandidType should be type inferred as a Uint8Array, and all of the other Vec typed things should also be inferred likely.

lastmjs commented 11 months ago

null was not handled correctly in the StableJson replacer and reviver

lastmjs commented 10 months ago

https://github.com/demergent-labs/azle/issues/1462

bdemann commented 10 months ago

https://github.com/demergent-labs/azle/issues/1453

bdemann commented 10 months ago

https://github.com/demergent-labs/azle/issues/1443

lastmjs commented 10 months ago

Did not account for NaN is stableJson

lastmjs commented 10 months ago

Did not account for Infinity and -Infinity in stableJson

dansteren commented 10 months ago

Services must have their properties sorted alphabetically. See https://forum.dfinity.org/t/services-wont-deserialize-properly-if-functions-arent-in-alphabetical-order/20885/14.

It's supposedly fixed by @dfinity/agent v0.20.0, we just need to update to that version.

dansteren commented 10 months ago

The DFX CLI has a bug where it requires variants to have at least one field. The spec says that it's fine (as far as I could tell) but the CLI doesn't allow it.

See property_tests/arbitraries/candid/constructed/variant_arb/definition_arbs.ts.

[!NOTE] No issue has been made for this yet. I could use advice on where to open this issue.

bdemann commented 10 months ago

The thing where empty tuples get returned as {} and not [] yet if you try to pass in an empty tuple {} as a parameter dfx will break. Consistency would be great and allow us to only have one value instead of an agentArgumentValue and an agentResponseValue

lastmjs commented 10 months ago

Vec2 is not a function on _K6w, this has happened a couple of times if I remember correctly, the last time it just happened was from Service:

import { Canister,query,update,Void,bool,int64,Principal,float64,blob,int16,Func,int,int32,Opt,Some,None,text,nat32,Vec,nat8,Tuple,Record,nat16,nat,Variant,int8,nat64,float32 } from 'azle';
        import { deepEqual } from 'fast-equals';
        // TODO solve the underlying principal problem https://github.com/demergent-labs/azle/issues/1443
        import { Principal as DfinityPrincipal } from '@dfinity/principal';

        const w2t8l3C = Void;
const _XQA61 = bool;
const KF4Kt = int64;
const T2ma2g1 = int64;
const _m4Y = Principal;
const _m3s = Principal;
const _av = int;
const _hYZ6k5e = Void;
const bz9GH0 = nat32;
const S6n8at = bool;
const _K6w = Vec(nat8)
lastmjs commented 10 months ago

Tuple tests are failing on main

Running test: tuple _3tSBU2qr

 test: tuple _3tSBU2qr passed

src/index.ts 1011ms
Uninstalling code for canister canister, with canister_id bkyz2-fmaaa-aaaaa-qaaaq-cai
Deploying: canister
All canisters have already been created.
Building canisters...
Executing 'npx azle canister'

Building canister canister
TypeError: Cannot use 'in' operator to search for 'azleName' in undefined
    at toIdl (evalmachine.<anonymous>:98198:20)
    at toIdlArray (evalmachine.<anonymous>:98213:21)
    at Object.getIdl (evalmachine.<anonymous>:98714:76)
    at toIdl (evalmachine.<anonymous>:98207:23)
    at evalmachine.<anonymous>:98211:41
    at Array.map (<anonymous>)
    at toIdlArray (evalmachine.<anonymous>:98211:28)
    at Object.getIdl (evalmachine.<anonymous>:98714:37)
    at toIdl (evalmachine.<anonymous>:98207:23)
    at evalmachine.<anonymous>:98392:20
Error: Failed while trying to deploy canisters.
Caused by: Failed while trying to deploy canisters.
  Failed to build all canisters.
    Failed while trying to build all canisters.
      The build step failed for canister 'bkyz2-fmaaa-aaaaa-qaaaq-cai' (canister) with an embedded error: Failed to build custom canister canister.: Failed to run npx azle canister.: The custom tool failed.
Error: Property failed after 2 tests
dansteren commented 10 months ago
bdemann commented 10 months ago

Problems with IDL.Rec()