Skip to content

Write bash script to switch a contract's E2E tests from sandboxed to non-sandboxed (and vice-versa) #2588

@cmichi

Description

@cmichi

Our E2E tests support running either in a sandbox (#[ink_e2e::test(backend(runtime_only))]) or against a node process spawned in the background (just #[ink_e2e::test]). You can read more here.

For our CI we want to test that all contracts in integration-tests/ succeed with either sandboxed or non-sandboxed. That's why we need a script that does this switching for us. Then we can run cargo test --all-features on the integration-tests/ contract's, execute the script, and execute another cargo test run. For this issue, you can just focus on the script though.

If you full-text search the integration-tests/ folder for #[ink_e2e::test you'll get an idea of how the macro is used.

The requirement for this issue is:

  • Write a bash script switch-e2e-backend which takes a --manifest-path to a contract.
  • Ensure that a contract's E2E tests are switched to the opposite of what a test currently uses. So if it's sandboxed, the test should be switched to non-sandboxed and vice-versa.
  • If sandboxed tests are used, the contract's Cargo.toml must contain ink_e2e = {…, features = ["sandbox"] }.
  • If the contract does no longer contain sandboxed E2E tests, the sandbox feature must be removed from the Cargo.toml.

Some test cases:

- #[ink_e2e::test(backend(runtime_only(sandbox = ink_e2e::DefaultSandbox)))]
+ #[ink_e2e::test]
-#[ink_e2e::test(environment = crate::EnvironmentWithManyTopics)]
+#[ink_e2e::test(environment = crate::EnvironmentWithManyTopics, backend(runtime_only)]
-#[ink_e2e::test(replace_test_attr = "#[quickcheck]", backend(runtime_only))]
+#[ink_e2e::test(replace_test_attr = "#[quickcheck]"]

Besides the arguments above, there are more arguments the ink_e2e::test macro can contain. I think it's best to just focus on the backend(…) argument.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-CIContinuous integration work itemgood first issueGood for newcomers

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions