Skip to content

Commit

Permalink
fix failing Cadence tests & remove debug tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sisyphusSmiling committed Nov 7, 2024
1 parent bbecea4 commit d203cc9
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 127 deletions.
64 changes: 0 additions & 64 deletions cadence/tests/evm_revertible_random_tests.cdc

This file was deleted.

16 changes: 0 additions & 16 deletions cadence/tests/scripts/evm_revertible_random.cdc

This file was deleted.

10 changes: 2 additions & 8 deletions cadence/tests/test_helpers.cdc

Large diffs are not rendered by default.

22 changes: 12 additions & 10 deletions cadence/tests/wrap_and_mint_tests.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ fun setup() {
let coaEvts = Test.eventsOfType(Type<EVM.CadenceOwnedAccountCreated>())
let coaEvt = coaEvts[0] as! EVM.CadenceOwnedAccountCreated
coaAddress = coaEvt.address
log("COA address: ".concat(coaAddress))

// Deploy WFLOW
let wflowDeployRes = executeTransaction(
Expand Down Expand Up @@ -52,7 +51,7 @@ fun setup() {
constructorArgs
))
// Append the encoded constructor args to the compiled bytecode
let finalBytecode = getERC721Bytecode().concat(argsBytecode)
let finalBytecode = String.join([getERC721Bytecode(), argsBytecode], separator: "")
let erc721DeployRes = executeTransaction(
"./transactions/deploy.cdc",
[finalBytecode, UInt64(15_000_000), 0.0],
Expand All @@ -64,25 +63,28 @@ fun setup() {
txnExecEvts = Test.eventsOfType(Type<EVM.TransactionExecuted>())
let erc721Evt = txnExecEvts[3] as! EVM.TransactionExecuted
erc721Address = erc721Evt.contractAddress

log("WFLOW address: ".concat(wflowAddress))
log("ERC721 address: ".concat(erc721Address))
}

access(all)
fun testWrapAndMintSucceeds() {
let user = Test.createAccount()
mintFlow(to: user, amount: 10.0)

wrapAndMintUntilSuccess(signer: user, wflow: wflowAddress, erc721: erc721Address)
// Executes the wrap_and_mint.cdc transaction
// - Creates a COA
// - Funds the COA with FLOW to cover mint cost
// - Wraps FLOW as WFLOW
// - Approves ERC721 contract to mint
// - Mints ERC721 <- may fail so we retry here until success (can't mock CadenceArch calls in Cadence tests atm)
wrapAndMintUntilSuccess(iter: 5, signer: user, wflow: wflowAddress, erc721: erc721Address)
}

access(all)
fun wrapAndMintUntilSuccess(signer: Test.TestAccount, wflow: String, erc721: String) {
fun wrapAndMintUntilSuccess(iter: Int, signer: Test.TestAccount, wflow: String, erc721: String) {
var i = 0
var success = false
while i < 50 {
let res: Test.TransactionResult = executeTransaction(
while i < iter {
let res = executeTransaction(
"../transactions/bundled/wrap_and_mint.cdc",
[wflow, erc721],
signer
Expand All @@ -95,5 +97,5 @@ fun wrapAndMintUntilSuccess(signer: Test.TestAccount, wflow: String, erc721: Str
moveBlock()
}
}
Test.assertEqual(true, success)
Test.assert(success)
}
29 changes: 0 additions & 29 deletions solidity/src/test/TestCadenceRandomConsumer.sol

This file was deleted.

0 comments on commit d203cc9

Please sign in to comment.