Skip to content

Commit

Permalink
add EVMBlocklist test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
sisyphusSmiling committed Sep 19, 2024
1 parent f1693ef commit 3558434
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 1 deletion.
28 changes: 27 additions & 1 deletion cadence/tests/flow_evm_bridge_tests.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -961,11 +961,37 @@ access(all)
fun testOnboardERC721ByEVMAddressSucceeds() {
snapshot = getCurrentBlockHeight()

// Validate EVMBlocklist works by blocking the EVM address
let blockResult = executeTransaction(
"../transactions/bridge/admin/blocklist/block_evm_address.cdc",
[erc721AddressHex],
bridgeAccount
)
Test.expect(blockResult, Test.beSucceeded())

// onboarding should fail as the EVM address is blocked
var onboardingResult = executeTransaction(
"../transactions/bridge/onboarding/onboard_by_evm_address.cdc",
[erc721AddressHex],
alice
)
Test.expect(onboardingResult, Test.beFailed())

// Unblock the EVM address
let unblockResult = executeTransaction(
"../transactions/bridge/admin/blocklist/remove_evm_address_from_blocklist.cdc",
[erc721AddressHex],
bridgeAccount
)
Test.expect(unblockResult, Test.beSucceeded())

// And now onboarding should succeed
var requiresOnboarding = evmAddressRequiresOnboarding(erc721AddressHex)
?? panic("Problem getting onboarding requirement")
Test.assertEqual(true, requiresOnboarding)

var onboardingResult = executeTransaction(
onboardingResult = executeTransaction(
"../transactions/bridge/onboarding/onboard_by_evm_address.cdc",
[erc721AddressHex],
alice
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import "EVM"

import "FlowEVMBridgeConfig"

/// Removes the given EVM contract address from the EVMBlocklist if it exists.
///
/// @param evmContractHex: The EVM contract address to remove from the blocklist
///
transaction(evmContractHex: String) {

let evmBlocklist: auth(FlowEVMBridgeConfig.Blocklist) &FlowEVMBridgeConfig.EVMBlocklist
let evmAddress: EVM.EVMAddress

prepare(signer: auth(BorrowValue) &Account) {
self.evmBlocklist = signer.storage.borrow<auth(FlowEVMBridgeConfig.Blocklist) &FlowEVMBridgeConfig.EVMBlocklist>(
from: FlowEVMBridgeConfig.adminStoragePath
) ?? panic("Could not borrow FlowEVMBridgeConfig Admin reference")
self.evmAddress = EVM.addressFromString(evmContractHex)
}

execute {
self.evmBlocklist.block(self.evmAddress)
}

post {
FlowEVMBridgeConfig.isEVMAddressBlocked(self.evmAddress): "Fee was not set correctly"
}
}

0 comments on commit 3558434

Please sign in to comment.