-
Notifications
You must be signed in to change notification settings - Fork 7
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
Add NFT Bridging Cadence tests #24
Conversation
…n on deployERC721
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## add-serialization #24 +/- ##
======================================================
+ Coverage 58.92% 74.79% +15.86%
======================================================
Files 5 13 +8
Lines 297 599 +302
======================================================
+ Hits 175 448 +273
- Misses 122 151 +29 ☔ View full report in Codecov by Sentry. |
[contractAddr, contractName, nftID], | ||
signer | ||
) | ||
Test.expect(bridgeResult, Test.beSucceeded()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add a few more lines after this one and for the next test to verify this worked? Could be as simple as using the get ids to make sure the id still exists here in the account on the evm side, and similar for the next test. Also an event emitted check would be good.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are actually helper functions, used in test cases. The actual tests do contain assertions for checking the IDs etc.
I have added some assertions about checking emitted events: f45ad59
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!
import "EVM" | ||
|
||
/// This contract is intended for testing purposes for the sake of capturing a deployed contract address while native | ||
/// `evm.TransactionExecuted` event types are not available in Cadence testing framework. The deploying account should |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Soon enough there will be no need for such workarounds 🙏 . I already have a WIP PR in onflow/cadence-tools#330
|
||
var events = Test.eventsOfType(Type<NonFungibleToken.Withdrawn>()) | ||
let withdrawnEvent = events[events.length - 1] as! NonFungibleToken.Withdrawn | ||
Test.assertEqual(bridgeAccount.address, withdrawnEvent.from!) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would like to add some assertions to check the withdrawnEvent.id
& depositedEvent.id
event fields, but I am not sure how to convert from the erc721ID
argument to a Cadence NFT ID. Any ideas @sisyphusSmiling ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the best way to do this would be to look for the subsequent IFlowEVMNFTBridge.BridgedNFTFromEVM
event and match the evmID
value to erc721
. This event will also contain the id
value corresponding to the bridged nft.id
value which can then be checked in the Withdrawn
and Deposited
events. This is a bit roundabout, but necessary given the fact evmID
is not guaranteed to match nft.id
due to different types - UInt256
and UInt64
respectively.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice 👏
Co-authored-by: Joshua Hannan <[email protected]>
Related: #16
Stacked against: #20
Description
Adds test cases. Following on from #22 after git issues.
For contributor use:
master
branchFiles changed
in the Github PR explorer