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

Update Cadence tests to latest API features #161

Merged
merged 3 commits into from
Nov 9, 2023

Conversation

m-Peter
Copy link
Contributor

@m-Peter m-Peter commented Oct 18, 2023

Preliminary work to update the Cadence tests to the upcoming API features.
Most notable features include the ability to specify deployment addresses in flow.json config file, thus allowing developers to import the contracts under test, in their tests files. This allows the use of nested types defined in these contracts. E.g.:

let typ = Type<CapabilityDelegator.DelegatorUpdated>()
let events = Test.eventsOfType(typ)
Test.assertEqual(4, events.length)

let event = events[3]! as! CapabilityDelegator.DelegatorUpdated
Test.assert(event.isPublic == false)
Test.assert(event.active == false)

let capabilityType = Type<Capability<&ExampleNFT.Collection{NonFungibleToken.Provider}>>()
Test.assertEqual(capabilityType, event.capabilityType)

The above snippet allows performing assertions on events payload.

@m-Peter
Copy link
Contributor Author

m-Peter commented Oct 18, 2023

cc @sisyphusSmiling @austinkline A sneak peek for the features of the next flow-cli release 🙏 (I used a local build to run these tests).

@sisyphusSmiling
Copy link
Collaborator

This is awesome @m-Peter! Thanks so much for starting the test updates, very helpful to see the new testing features in context

@codecov-commenter
Copy link

codecov-commenter commented Oct 31, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (8a6faba) 83.95% compared to head (51700ef) 83.95%.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #161   +/-   ##
=======================================
  Coverage   83.95%   83.95%           
=======================================
  Files           4        4           
  Lines         349      349           
=======================================
  Hits          293      293           
  Misses         56       56           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@m-Peter m-Peter marked this pull request as ready for review October 31, 2023 10:17
@m-Peter
Copy link
Contributor Author

m-Peter commented Nov 8, 2023

@sisyphusSmiling Can you take a look at this please? 🙏

@sisyphusSmiling sisyphusSmiling requested a review from a team November 8, 2023 16:09
@sisyphusSmiling
Copy link
Collaborator

sisyphusSmiling commented Nov 8, 2023

Sorry for the delay @m-Peter, will take a look today. Side note to myself to add a CODEOWNERS file to the repo so PRs get auto-assigned

Copy link
Collaborator

@sisyphusSmiling sisyphusSmiling left a comment

Choose a reason for hiding this comment

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

Fantastic work (as always) on the testing API changes! Thank you for updating the tests here, it's very helpful to see the new API in action. Tests look much cleaner!

Just a couple small comments on test script naming, but not a blocker for merging at all, especially since they're test scripts.

test/CapabilityDelegator_tests.cdc Show resolved Hide resolved
transactions/test/add_type_to_factory.cdc Outdated Show resolved Hide resolved
scripts/test/add_type_to_factory.cdc Outdated Show resolved Hide resolved
@sisyphusSmiling sisyphusSmiling merged commit 84bb6f3 into onflow:main Nov 9, 2023
1 check passed
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.

3 participants