diff --git a/integration/tests/basic/evm/test_precompiled_contracts.py b/integration/tests/basic/evm/test_precompiled_contracts.py index dfc7100a19..d308ccf5cb 100644 --- a/integration/tests/basic/evm/test_precompiled_contracts.py +++ b/integration/tests/basic/evm/test_precompiled_contracts.py @@ -134,11 +134,8 @@ def test_call_via_send_trx( amount = random.choice([0, 10]) balance_before = self.web3_client.get_balance(address) - instruction_tx = self.web3_client.make_raw_tx(sender_account, amount=amount, estimate_gas=True) - instruction_tx["data"] = input_data - instruction_tx["chainId"] = self.web3_client.eth.chain_id - instruction_tx["to"] = address - instruction_tx["from"] = sender_account.address + instruction_tx = self.web3_client.make_raw_tx(sender_account, address, data=input_data, + amount=amount, estimate_gas=True) if request.node.callspec.id not in [ "modexp-nagydani-5-square0", "modexp-nagydani-5-square1", diff --git a/integration/tests/basic/test_nonce.py b/integration/tests/basic/test_nonce.py index 80dbb58368..3a53008e23 100644 --- a/integration/tests/basic/test_nonce.py +++ b/integration/tests/basic/test_nonce.py @@ -36,12 +36,15 @@ def test_get_receipt_sequence(self): def test_reverse_sequence(self): sender_account = self.accounts[0] + recipient_account = self.accounts[1] nonce = self.web3_client.get_nonce(sender_account.address) nonce_list = [i for i in range(nonce + self.TRANSFER_CNT - 1, nonce - 1, -1)] tx_hash_list = [] for nonce in nonce_list: - transaction = self.web3_client.make_raw_tx(sender_account, nonce=nonce, estimate_gas=True) + transaction = self.web3_client.make_raw_tx( + sender_account, recipient_account, nonce=nonce, estimate_gas=True + ) signed_tx = self.web3_client.eth.account.sign_transaction(transaction, sender_account.key) tx = self.web3_client.eth.send_raw_transaction(signed_tx.rawTransaction) tx_hash_list.append(tx.hex()) @@ -50,12 +53,16 @@ def test_reverse_sequence(self): def test_random_sequence(self): sender_account = self.accounts[0] + recipient_account = self.accounts[1] nonce = self.web3_client.get_nonce(sender_account.address) nonce_list = [i for i in range(nonce, nonce + self.TRANSFER_CNT)] random.shuffle(nonce_list) tx_hash_list = [] for nonce in nonce_list: - transaction = self.web3_client.make_raw_tx(sender_account, nonce=nonce, estimate_gas=True) + transaction = self.web3_client.make_raw_tx( + sender_account, recipient_account, nonce=nonce, estimate_gas=True + ) + print(transaction) signed_tx = self.web3_client.eth.account.sign_transaction(transaction, sender_account.key) tx = self.web3_client.eth.send_raw_transaction(signed_tx.rawTransaction) tx_hash_list.append(tx.hex()) @@ -65,10 +72,11 @@ def test_random_sequence(self): def test_send_transaction_with_low_nonce_after_several_high(self, json_rpc_client): """Check that transaction with a higher nonce is waiting for its turn in the mempool""" sender_account = self.accounts[0] + recipient_account = self.accounts[1] nonce = self.web3_client.eth.get_transaction_count(sender_account.address) trx = {} for n in [nonce + 3, nonce + 1, nonce]: - transaction = self.web3_client.make_raw_tx(sender_account, nonce=n, estimate_gas=True) + transaction = self.web3_client.make_raw_tx(sender_account, recipient_account, nonce=n, estimate_gas=True) signed_tx = self.web3_client.eth.account.sign_transaction(transaction, sender_account.key) response_trx = json_rpc_client.send_rpc("eth_sendRawTransaction", [signed_tx.rawTransaction.hex()]) trx[n] = response_trx @@ -76,7 +84,7 @@ def test_send_transaction_with_low_nonce_after_several_high(self, json_rpc_clien receipt_trx1 = json_rpc_client.send_rpc(method="eth_getTransactionReceipt", params=[trx[n + 3]["result"]]) assert receipt_trx1["result"] is None, "Transaction shouldn't be accepted" - transaction = self.web3_client.make_raw_tx(sender_account, nonce=n + 2, estimate_gas=True) + transaction = self.web3_client.make_raw_tx(sender_account, recipient_account, nonce=n + 2, estimate_gas=True) signed_tx = self.web3_client.eth.account.sign_transaction(transaction, sender_account.key) json_rpc_client.send_rpc("eth_sendRawTransaction", [signed_tx.rawTransaction.hex()]) @@ -86,8 +94,9 @@ def test_send_transaction_with_low_nonce_after_several_high(self, json_rpc_clien def test_send_transaction_with_low_nonce_after_high(self, json_rpc_client): """Check that transaction with a higher nonce is waiting for its turn in the mempool""" sender_account = self.accounts[0] + recipient_account = self.accounts[1] nonce = self.web3_client.eth.get_transaction_count(sender_account.address) + 1 - transaction = self.web3_client.make_raw_tx(sender_account, nonce=nonce, estimate_gas=True) + transaction = self.web3_client.make_raw_tx(sender_account, recipient_account, nonce=nonce, estimate_gas=True) signed_tx = self.web3_client.eth.account.sign_transaction(transaction, sender_account.key) response_trx1 = json_rpc_client.send_rpc("eth_sendRawTransaction", [signed_tx.rawTransaction.hex()]) @@ -95,22 +104,27 @@ def test_send_transaction_with_low_nonce_after_high(self, json_rpc_client): receipt_trx1 = json_rpc_client.send_rpc(method="eth_getTransactionReceipt", params=[response_trx1["result"]]) assert receipt_trx1["result"] is None, "Transaction shouldn't be accepted" - transaction = self.web3_client.make_raw_tx(sender_account, nonce=nonce - 1, estimate_gas=True) + transaction = self.web3_client.make_raw_tx( + sender_account, recipient_account, nonce=nonce - 1, estimate_gas=True + ) signed_tx = self.web3_client.eth.account.sign_transaction(transaction, sender_account.key) response_trx2 = json_rpc_client.send_rpc("eth_sendRawTransaction", [signed_tx.rawTransaction.hex()]) for result in (response_trx2["result"], response_trx1["result"]): self.web3_client.wait_for_transaction_receipt(result) assert rpc_checks.is_hex(result) - @pytest.mark.only_stands # This doesn't work on devnet because sticky session is not enabled + @pytest.mark.only_stands # This doesn't work on devnet because sticky session is not enabled def test_send_transaction_with_the_same_nonce_and_lower_gas(self, json_rpc_client, new_account): """Check that transaction with a low gas and the same nonce can't be sent""" sender_account = self.accounts[3] + recipient_account = self.accounts[4] nonce = self.web3_client.eth.get_transaction_count(sender_account.address) + 1 gas = self.web3_client.gas_price() - tx1 = self.web3_client.make_raw_tx(sender_account, nonce=nonce, gas_price=gas, estimate_gas=True) + tx1 = self.web3_client.make_raw_tx( + sender_account, recipient_account, nonce=nonce, gas_price=gas, estimate_gas=True + ) signed_tx1 = self.web3_client.eth.account.sign_transaction(tx1, sender_account.key) - tx2 = self.web3_client.make_raw_tx(sender_account, nonce=nonce, gas_price=gas - 1000, estimate_gas=True) + tx2 = self.web3_client.make_raw_tx(sender_account, recipient_account, nonce=nonce, gas_price=gas - 1000, estimate_gas=True) signed_tx2 = self.web3_client.eth.account.sign_transaction(tx2, sender_account.key) resp1 = json_rpc_client.send_rpc("eth_sendRawTransaction", [signed_tx1.rawTransaction.hex()]) response = json_rpc_client.send_rpc("eth_sendRawTransaction", [signed_tx2.rawTransaction.hex()]) @@ -122,12 +136,18 @@ def test_send_transaction_with_the_same_nonce_and_lower_gas(self, json_rpc_clien def test_send_transaction_with_the_same_nonce_and_higher_gas(self, json_rpc_client): """Check that transaction with higher gas and the same nonce can be sent""" sender_account = self.accounts[2] + recipient_account = self.accounts[3] nonce = self.web3_client.eth.get_transaction_count(sender_account.address) + 1 gas = self.web3_client.gas_price() - transaction = self.web3_client.make_raw_tx(sender_account, nonce=nonce, gas_price=gas, estimate_gas=True) + transaction = self.web3_client.make_raw_tx( + sender_account, recipient_account, nonce=nonce, gas_price=gas, estimate_gas=True + ) signed_tx = self.web3_client.eth.account.sign_transaction(transaction, sender_account.key) json_rpc_client.send_rpc("eth_sendRawTransaction", [signed_tx.rawTransaction.hex()]) - transaction = self.web3_client.make_raw_tx(sender_account, nonce=nonce, gas_price=gas * 10, estimate_gas=True) + transaction = self.web3_client.make_raw_tx( + sender_account, recipient_account, nonce=nonce, gas_price=gas * 10, estimate_gas=True + ) + signed_tx = self.web3_client.eth.account.sign_transaction(transaction, sender_account.key) response = json_rpc_client.send_rpc("eth_sendRawTransaction", [signed_tx.rawTransaction.hex()]) assert "error" not in response @@ -136,7 +156,8 @@ def test_send_transaction_with_the_same_nonce_and_higher_gas(self, json_rpc_clie def test_send_the_same_transactions_if_accepted(self, json_rpc_client): """Transaction cannot be sent again if it was accepted""" sender_account = self.accounts[0] - transaction = self.web3_client.make_raw_tx(sender_account, estimate_gas=True) + recipient_account = self.accounts[1] + transaction = self.web3_client.make_raw_tx(sender_account, recipient_account, estimate_gas=True) signed_tx = self.web3_client.eth.account.sign_transaction(transaction, sender_account.key) params = [signed_tx.rawTransaction.hex()] response = json_rpc_client.send_rpc("eth_sendRawTransaction", params) @@ -151,7 +172,8 @@ def test_send_the_same_transactions_if_accepted(self, json_rpc_client): def test_send_the_same_transactions_if_not_accepted(self, json_rpc_client): """Transaction can be sent again if it was not accepted""" sender_account = self.accounts[0] - transaction = self.web3_client.make_raw_tx(sender_account, estimate_gas=True) + recipient_account = self.accounts[1] + transaction = self.web3_client.make_raw_tx(sender_account, recipient_account, estimate_gas=True) signed_tx = self.web3_client.eth.account.sign_transaction(transaction, sender_account.key) params = [signed_tx.rawTransaction.hex()] json_rpc_client.send_rpc("eth_sendRawTransaction", params) @@ -163,8 +185,11 @@ def test_send_the_same_transactions_if_not_accepted(self, json_rpc_client): def test_send_transaction_with_old_nonce(self, json_rpc_client, new_account): """Check that transaction with old nonce can't be sent""" sender_account = new_account + recipient_account = self.accounts[1] nonce = self.web3_client.eth.get_transaction_count(sender_account.address) - transaction = self.web3_client.make_raw_tx(sender_account, amount=1, nonce=nonce, estimate_gas=True) + transaction = self.web3_client.make_raw_tx( + sender_account, recipient_account, amount=1, nonce=nonce, estimate_gas=True + ) signed_tx = self.web3_client.eth.account.sign_transaction(transaction, sender_account.key) response = json_rpc_client.send_rpc("eth_sendRawTransaction", [signed_tx.rawTransaction.hex()]) assert "result" in response and response["result"], f"Response doesn't have result field: {response}" @@ -172,7 +197,7 @@ def test_send_transaction_with_old_nonce(self, json_rpc_client, new_account): block_num = receipt["blockNumber"] wait_finalized_block(json_rpc_client, block_num) - transaction = self.web3_client.make_raw_tx(sender_account, amount=2, nonce=nonce, estimate_gas=True) + transaction = self.web3_client.make_raw_tx(sender_account, recipient_account, amount=2, nonce=nonce, estimate_gas=True) signed_tx = self.web3_client.eth.account.sign_transaction(transaction, sender_account.key) response = json_rpc_client.send_rpc("eth_sendRawTransaction", [signed_tx.rawTransaction.hex()]) assert ErrorMessage.NONCE_TOO_LOW.value in response["error"]["message"]