Skip to content

Commit

Permalink
Add event assertions in test methods
Browse files Browse the repository at this point in the history
  • Loading branch information
m-Peter committed Apr 3, 2024
1 parent 680e521 commit f45ad59
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions cadence/tests/flow_evm_bridge_tests.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,16 @@ fun bridgeNFTToEVM(signer: Test.TestAccount, contractAddr: Address, contractName
signer
)
Test.expect(bridgeResult, Test.beSucceeded())

var events = Test.eventsOfType(Type<NonFungibleToken.Withdrawn>())
let withdrawnEvent = events[events.length - 1] as! NonFungibleToken.Withdrawn
Test.assertEqual(nftID, withdrawnEvent.id)
Test.assertEqual(signer.address, withdrawnEvent.from!)

events = Test.eventsOfType(Type<NonFungibleToken.Deposited>())
let depositedEvent = events[events.length - 1] as! NonFungibleToken.Deposited
Test.assertEqual(nftID, depositedEvent.id)
Test.assertEqual(bridgeAccount.address, depositedEvent.to!)
}

access(all)
Expand All @@ -497,5 +507,13 @@ fun bridgeNFTFromEVM(signer: Test.TestAccount, contractAddr: Address, contractNa
signer
)
Test.expect(bridgeResult, Test.beSucceeded())

var events = Test.eventsOfType(Type<NonFungibleToken.Withdrawn>())
let withdrawnEvent = events[events.length - 1] as! NonFungibleToken.Withdrawn
Test.assertEqual(bridgeAccount.address, withdrawnEvent.from!)

events = Test.eventsOfType(Type<NonFungibleToken.Deposited>())
let depositedEvent = events[events.length - 1] as! NonFungibleToken.Deposited
Test.assertEqual(signer.address, depositedEvent.to!)
}

0 comments on commit f45ad59

Please sign in to comment.