From f45ad59ffb028d08e47e9c7eb9bc587d41598c2f Mon Sep 17 00:00:00 2001 From: Ardit Marku Date: Wed, 3 Apr 2024 14:19:18 +0300 Subject: [PATCH] Add event assertions in test methods --- cadence/tests/flow_evm_bridge_tests.cdc | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/cadence/tests/flow_evm_bridge_tests.cdc b/cadence/tests/flow_evm_bridge_tests.cdc index 41e495b0..e553bfd4 100644 --- a/cadence/tests/flow_evm_bridge_tests.cdc +++ b/cadence/tests/flow_evm_bridge_tests.cdc @@ -487,6 +487,16 @@ fun bridgeNFTToEVM(signer: Test.TestAccount, contractAddr: Address, contractName signer ) Test.expect(bridgeResult, Test.beSucceeded()) + + var events = Test.eventsOfType(Type()) + let withdrawnEvent = events[events.length - 1] as! NonFungibleToken.Withdrawn + Test.assertEqual(nftID, withdrawnEvent.id) + Test.assertEqual(signer.address, withdrawnEvent.from!) + + events = Test.eventsOfType(Type()) + let depositedEvent = events[events.length - 1] as! NonFungibleToken.Deposited + Test.assertEqual(nftID, depositedEvent.id) + Test.assertEqual(bridgeAccount.address, depositedEvent.to!) } access(all) @@ -497,5 +507,13 @@ fun bridgeNFTFromEVM(signer: Test.TestAccount, contractAddr: Address, contractNa signer ) Test.expect(bridgeResult, Test.beSucceeded()) + + var events = Test.eventsOfType(Type()) + let withdrawnEvent = events[events.length - 1] as! NonFungibleToken.Withdrawn + Test.assertEqual(bridgeAccount.address, withdrawnEvent.from!) + + events = Test.eventsOfType(Type()) + let depositedEvent = events[events.length - 1] as! NonFungibleToken.Deposited + Test.assertEqual(signer.address, depositedEvent.to!) }