Skip to content

Commit

Permalink
Add mempool test
Browse files Browse the repository at this point in the history
  • Loading branch information
shohamc1 committed Sep 12, 2023
1 parent d7eb9a2 commit b6d14b0
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions test/functional/feature_evm_transferdomain.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# Copyright (c) DeFi Blockchain Developers
# Distributed under the MIT software license, see the accompanying
# file LICENSE or http://www.opensource.org/licenses/mit-license.php.
import web3.utils

from test_framework.test_framework import DefiTestFramework
from test_framework.util import assert_equal, assert_raises_rpc_error, int_to_eth_u256
Expand Down Expand Up @@ -761,6 +762,45 @@ def invalid_transfer_sc(self):
],
)

def invalid_transfer_sc_mempool(self):
abi, bytecode, _ = EVMContract.from_file("Reverter.sol", "Reverter").compile()
compiled = self.nodes[0].w3.eth.contract(abi=abi, bytecode=bytecode)
nonce = self.nodes[0].w3.eth.get_transaction_count(self.evm_key_pair.address)

tx = compiled.constructor().build_transaction(
{
"chainId": self.nodes[0].w3.eth.chain_id,
"nonce": nonce,
"maxFeePerGas": 10_000_000_000,
"maxPriorityFeePerGas": 1_500_000_000,
"gas": 1_000_000,
}
)
self.nodes[0].w3.eth.account.sign_transaction(tx, self.evm_key_pair.privkey)
contract_address = web3.utils.get_create_address(
self.evm_key_pair.address, nonce
)

assert_raises_rpc_error(
-32600,
"EVM destination is a smart contract",
self.nodes[0].transferdomain,
[
{
"src": {
"address": self.address,
"amount": "1@DFI",
"domain": 2,
},
"dst": {
"address": contract_address,
"amount": "1@DFI",
"domain": 3,
},
}
],
)

def invalid_transfer_no_auth(self):
assert_raises_rpc_error(
-5,
Expand Down Expand Up @@ -1009,6 +1049,7 @@ def run_test(self):

# Transfer to smart contract
self.invalid_transfer_sc()
self.invalid_transfer_sc_mempool()

# Invalid authorisation
self.invalid_transfer_no_auth()
Expand Down

0 comments on commit b6d14b0

Please sign in to comment.