No internet connection
  1. Home
  2. WASM

Testing CosmWasm contracts without deploying to wasmd

By Orkun Külçe @orkunkl
    2020-07-27 09:57:24.085Z

    Is there a way to know which crates / binaries will not work on CosmWasm without running it on wasmd?

    • 2 replies
    1. Orkun Külçe @orkunkl
        2020-07-27 09:57:42.740Z

        Yes, running integration tests with singlepass.

        This requires a version of Rust nightly installed and then cargo +nightly integration-test --no-default-features --features singlepass
        This should perform all the checks that the chain does as well. Unfortunately we cannot execute the deterministic middleware in cranelift right now (https://github.com/CosmWasm/cosmwasm/issues/311)

        1. In reply toorkunkl:
          Orkun Külçe @orkunkl
            2020-07-27 09:58:25.326Z

            As a rule of thumb, if the crate requires access to any sort of external service (OS, dynamic linking to external libraries, browser, filesystem, etc.) it either won't compile in the first place, or compile and request those capabilities through function imports/exports which are not recognized in the cosmwasm runtime.

            Crates that are fundamentally "pure", such as macros, math, parsers, data structures, information processing, traits, etc., should work smoothly out of the box
            Really, just keep in mind that the contract is running in an intentionally-highly-restricted, custom runtime environment. Crates that don't work on the platform probably aren't supposed to work in the first place.

            That being said, many crates also have a no-std mode which disables some of the features in exchange for not requiring any services. So in some cases the default configuration of the crate won't work, but a couple of Cargo.toml flags will get it to work just fine. This will usually be documented in the specific crate. If you're desparate, you can manually check the Cargo.toml of the desired crate to see if there's undocumented support for this.