Comments (3)
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 ofcw_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.
Makes sense, thank you for the clarification
from cw-contracts.
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)
- Remove mask HOT 3
- Migrate contracts to 0.12 HOT 1
- Add integration test setup to simple-option
- Move all contracts into ./contracts directory HOT 4
- Upgrade to 0.14
- Develop small project to demo submessages
- Release 0.10.0 HOT 3
- link in simple-option example is broken
- Use CanonicalAddr instead of Addr and String
- Update version of `rust-optimizer` in the `README.md`
- Error:While storing the bytecode on the chain unable to get the code id.
- Add clippy CI step
- Create CosmosMsg::Custom unit test for mask contract HOT 1
- Update build instructions to cosmwasm/rust-optimizer
- Create query for escrow
- List all names owned by a given address
- Deprecate Mask Contract HOT 1
- Auto-build contracts on releases HOT 5
- Add "ListNames" to nameservice HOT 1
- Upgrade to CosmWasm 0.11 HOT 11
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cw-contracts.