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

Migrate tests for example contracts #347

Merged
merged 44 commits into from
Oct 18, 2023
Merged

Migrate tests for example contracts #347

merged 44 commits into from
Oct 18, 2023

Conversation

Bargsteen
Copy link
Contributor

@Bargsteen Bargsteen commented Oct 6, 2023

Purpose

Migrate the tests of most of our example contracts from the old testing infrastructure to the new integration testing library.
Closes #337 and #338.

Changes

  • Migrate tests and remove use of abstractions on example contracts
    • account-signature-checks (none)
    • auction
    • cis2-multi
    • cis2-multi-royalties
    • cis2-nft
    • cis2-wccd
    • cis3-nft-sponsored-txs
    • counter-notify
    • credential-registry
      • Migrate the tests that use entrypoints (will keep the quickcheck tests that use the state methods directly)
    • eSealing
    • fib
    • icecream
    • memo (none)
    • nametoken
    • offchain-transfers (won't do, needs larger contract changes)
      • In particular, we need to add some more view entrypoints to be able to test it completely. In the interest of time, we'll skip that for now.
    • piggybank
    • proxy
    • recorder
    • signature-verifier
    • smart-contract-upgrade
    • transfer-policy-check
    • two-step-transfer (won't do, uses quickcheck)
    • voting
  • Derive some PartialEq / Eq for some cis2 types
  • Add type aliases the Extern* types, e.g. type StateApi = ExternStateApi
  • Include events from interrupts in ContractInvokeSuccess::events
  • Update rust-sdk dependency with a fix to policy serialization (bug found when migrating transfer-policy-check
  • Use cargo concordium test --out ./concordium-out/module.wasm.v1in the CI instead ofcargo test`
  • Update templates
    • default
    • cis2-nft
    • credential-registry
  • Update documentation and deprecate old testing infrastructure: Deprecate test_infrastructure and supporting traits #349

Checklist

  • My code follows the style of this project.
  • The code compiles without warnings.
  • I have performed a self-review of the changes.
  • I have documented my code, in particular the intent of the
    hard-to-understand areas.
  • (If necessary) I have updated the CHANGELOG.

Also sets a default type for the StateBuilder to be (Extern)`StateApi`
so that users don't have to specify a parameter unless they also use the testing-infrastructure.
- Migrates the tests from the deprecated testing infrastructure to
  `concordium-smart-contract-testing`.
- Remove the abstractions/generics in the init and receive methods that
  were only needed to support the old testing infrastructure
- Make a few minor changes to the examples to enable testing, for
  example adding a contract to be called in the counter-notify example.
@Bargsteen Bargsteen marked this pull request as draft October 6, 2023 14:27
@Bargsteen Bargsteen changed the title Kb/migrate tests Migrate tests for example contracts Oct 10, 2023
The contracts no longer have the crypto-primitives feature as it is not needed.
@Bargsteen Bargsteen marked this pull request as ready for review October 10, 2023 08:10
Copy link
Member

@DOBEN DOBEN left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very good to see how much this improves the contract's readability once we remove these generics (not needed anymore because the old unit testing will be deprecated soon). Nice work.

concordium-std/src/types.rs Outdated Show resolved Hide resolved
.github/workflows/linter.yml Show resolved Hide resolved
examples/auction/tests/tests.rs Outdated Show resolved Hide resolved
examples/cis2-multi-royalties/tests/tests.rs Outdated Show resolved Hide resolved
examples/cis2-multi-royalties/tests/tests.rs Outdated Show resolved Hide resolved
examples/cis3-nft-sponsored-txs/tests/tests.rs Outdated Show resolved Hide resolved
examples/nametoken/tests/tests.rs Outdated Show resolved Hide resolved
examples/nametoken/tests/tests.rs Show resolved Hide resolved
examples/transfer-policy-check/tests/tests.rs Outdated Show resolved Hide resolved
Co-authored-by: Doris Benda <DOBEN@users.noreply.github.com>
concordium-cis2/src/lib.rs Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Rewrite tests of all example contracts to use the testing library
4 participants