Resolve confusion of #[test] vs. #[ink::test] #714
Labels
A-ink_lang
[ink_lang] Work item
B-research
Research task that has open questions that need to be resolved.
Escalated from use-ink/cargo-contract#190.
Problem
There is often confusion when to use
#[test]
vs.#[ink::test]
.The implication of
#[ink::test]
is that the test annotated with it is run in a emulated chain environment (we call this "off-chain testing"). This comes with a bit of overhead for spawning this emulation. This emulation is not needed for every test, only for the ones where e.g. chain storage or theenv()
API is involved.For users starting out with ink! it can be hard to know when it's necessary to have an emulated chain, which can result in strange errors if
#[test]
is used but an emulation is necessary.Proposals
#[test]
with#[ink::test]
for every single test and live with the slight performance overhead.My opinion
My opinion is that we will always have this issue as long as we use different attributes for tests which require an emulated chain and ones which don't. I would just replace
#[test]
with#[ink::test]
in all examples and public documentation and trade a slight decrease in performance for an improved UX with less friction.The text was updated successfully, but these errors were encountered: