Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Order of additional_contracts argument impacts compilation #1499

Closed
HCastano opened this issue Nov 15, 2022 · 1 comment
Closed

Order of additional_contracts argument impacts compilation #1499

HCastano opened this issue Nov 15, 2022 · 1 comment
Labels
A-ink_e2e [ink_e2e] Work item C-bug Something isn't working

Comments

@HCastano
Copy link
Contributor

If a contract is included in an E2E test using the additional_contract argument then
this argument needs to come before any other invocations of ink_e2e::test, even if the
additional contracts aren't used, otherwise compilation fails.

For example, the below example fails to compile with the following error:

❯ cargo +nightly test --manifest-path ./examples/flipper/Cargo.toml

error[E0433]: failed to resolve: use of undeclared crate or module `accumulator`
  --> lib.rs:77:31
   |
77 |             let constructor = accumulator::constructors::new(0);
   |                               ^^^^^^^^^^^ use of undeclared crate or module `accumulator`

For more information about this error, try `rustc --explain E0433`.
error: could not compile `flipper` due to previous error

We should be able to include tests in any order, and we should expect that only tests
which use additional contracts require this argument.

This can be reproduced with ink@7789caf, cargo-contract@3e24722, and
substrate-contracts-node@0.21.0 using the following tests with Flipper:

#[cfg(test)]
mod e2e_tests {
    type E2EResult<T> = std::result::Result<T, Box<dyn std::error::Error>>;

    #[ink_e2e::test]
    // N.B, We need to include this, even though the `accumulator` contract isn't used in
    // this test, otherwise compilation of `e2e_second_instantiation` fails.
    //
    // #[ink_e2e::test(additional_contracts = "../delegator/accumulator/Cargo.toml")]
    async fn e2e_first_instantiation(
        mut client: ink_e2e::Client<C, E>,
    ) -> E2EResult<()> {
        let constructor = flipper::constructors::default();
        client
            .instantiate(&mut ink_e2e::alice(), constructor, 0, None)
            .await
            .expect("Instantiate `flipper` failed");

        Ok(())
    }

    #[ink_e2e::test(additional_contracts = "../delegator/accumulator/Cargo.toml")]
    async fn e2e_second_instantiation(
        mut client: ink_e2e::Client<C, E>,
    ) -> E2EResult<()> {
        let constructor = accumulator::constructors::new(0);
        client
            .instantiate(&mut ink_e2e::bob(), constructor, 0, None)
            .await
            .expect("Instantiate `adder` failed");

        Ok(())
    }
}
@HCastano HCastano added A-ink_e2e [ink_e2e] Work item C-bug Something isn't working labels Nov 15, 2022
@SkymanOne
Copy link
Contributor

additional_contracts has been removed in #2098

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-ink_e2e [ink_e2e] Work item C-bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants