#[test]Expand description
Defines a drink!-based test.
§Requirements
- Your crate must have
drinkin its dependencies (and it shouldn’t be renamed). - You mustn’t import
drink::testin the scope, where the macro is used. In other words, you should always use the macro only with a qualified path#[drink::test]. - Your crate cannot be part of a cargo workspace.
§Impact
This macro will take care of building all needed contracts for the test. The building process will be executed during compile time.
Contracts to be built:
- current cargo package if contains a
ink-as-dependencyfeature - all dependencies declared in the
Cargo.tomlfile with theink-as-dependencyfeature enabled (works with non-local packages as well).
§Compilation features
-
The root contract package (if any) is assumed to be built without any features.
-
All contract dependencies will be built with a union of all features enabled on that package (through potentially different configurations or dependency paths), excluding
ink-as-dependencyandstdfeatures.
§Creating a session object
The macro will also create a new mutable session object and pass it to the decorated function by value. You can
configure which sandbox should be used (by specifying a path to a type implementing
ink_sandbox::Sandbox trait. Thus, your testcase function should accept a single argument:
mut session: Session<_>.
By default, the macro will use drink::minimal::MinimalSandbox.
§Example
#[drink::test]
fn testcase(mut session: Session<MinimalSandbox>) {
session
.deploy_bundle(&get_bundle(), "new", NO_ARGS, NO_SALT, NO_ENDOWMENT)
.unwrap();
}