-
Notifications
You must be signed in to change notification settings - Fork 138
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
Cadence testing framework improvements #2696
Cadence testing framework improvements #2696
Conversation
Codecov Report
@@ Coverage Diff @@
## master #2696 +/- ##
=======================================
Coverage 79.10% 79.10%
=======================================
Files 333 333
Lines 78192 78194 +2
=======================================
+ Hits 61851 61855 +4
+ Misses 14048 14046 -2
Partials 2293 2293
Flags with carried forward coverage won't be shown. Click here to find out more.
|
In general, these additions are great ideas! The FLOW token helpers I'm not so sure about ( Though they are obviously convenient, the Cadence repo is probably not the best place to add them. We're trying to keep Cadence chain-agnostic / independent of Flow. Unfortunately there have been some places where we were not strict (e.g. naming of built-in events), but it would be nice to at least avoid adding new code tying Cadence to Flow, i.e. here the assumption that there is a FLOW token. Maybe these helper functions could be added upstream, e.g. in |
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.
LGTM
7249cb0
to
600ed65
Compare
@turbolent Thanks for the feedback 🙏 You've got a good point. I wanted to add the helper functions as part of the import Test
import BlockchainHelpers
pub let blockchain = Test.newEmulatorBlockchain()
pub let account = blockchain.createAccount()
// Retrieve current block height
let height = getCurrentBlockHeight(blockchain: blockchain)
// Reset (rollback) the blockchain to a given block height
blockchain.reset(height)
// Retrieve the Flow token balance of a test account
let balance = getFlowBalance(for: account, blockchain: blockchain)
// Mint a given amount of Flow tokens to a specified test account
mintFlow(to: account, amount: 1500.0, blockchain: blockchain)
// Burn a given amount of Flow tokens from a specified test account
burnFlow(from: account, amount: 500.0, blockchain: blockchain) We have to pass around the |
af7f759
to
01d7af5
Compare
This matcher function asserts that the result of an executed operation, such as scripts and transactions, resulted in an error that contains a given sub-string.
01d7af5
to
ff06b1d
Compare
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!
Closes #2076
Companion PR: onflow/cadence-tools#181
Description
Adding the following improvements:
ScriptResult
/TransactionResult
Sample usage:
master
branchFiles changed
in the Github PR explorer