Add NFT Bridging Cadence tests#24
Conversation
…n on deployERC721
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
| [contractAddr, contractName, nftID], | ||
| signer | ||
| ) | ||
| Test.expect(bridgeResult, Test.beSucceeded()) |
There was a problem hiding this comment.
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.
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
| 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.
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.
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.
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.
Co-authored-by: Joshua Hannan <joshua.hannan@flowfoundation.org>
Related: #16
Stacked against: #20
Description
Adds test cases. Following on from #22 after git issues.
For contributor use:
masterbranchFiles changedin the Github PR explorer