Giter Club home page Giter Club logo

Comments (3)

webmaster128 avatar webmaster128 commented on July 3, 2024 1

Very good question.

Those tests are very different things:

  • unit tests: test the Rust logic directly, no compilation to Wasm, no VM involved, compiled using the cargo unit testing infrastructure for library internal interfaces.
  • **integration tests: uses cosmwasm_vm to test a compiled Wasm, can only access symbols that are public exports of cw_erc20. More or less a standalone binary.

The only code those two types of tests share is the contract itself (i.e. things exported by src/lib.rs). While it would theoretically be possible to share test code between the two different test modules, I don't see an obvious place to put that code. Creating test utils that are exported by the contract would be part of the contract that is uploaded to chain since every public interface cannot be stripped off.

Most of those function would not be useful in the contract itself since they panic on error instead of propagating it up, which makes them handy to use in tests.

Even if it would be possible to DRY this a little more, I don't see any obvious potential without adding much more complexity and indirection, which would it make harder for newcomers to understand what is going on.

from cw-contracts.

anilcse avatar anilcse commented on July 3, 2024 1

Makes sense, thank you for the clarification

from cw-contracts.

webmaster128 avatar webmaster128 commented on July 3, 2024

You're welcome, closing for now.

Creating test utils that are exported by the contract would be part of the contract that is uploaded to chain since every public interface cannot be stripped off.

I need to add that I'm not sure about this statement. I did not verify it. Wasm compilation could potentially remove everything that is not references by Wasm imports/exports. Anyways, I still don't think test helpers belong in the contract code.

from cw-contracts.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.