Skip to content

Commit 4eddc55

Browse files
authored
Merge pull request #3099 from darwintree/parametize-eweb3
tests: parametize eweb3 using old and new rpc port
2 parents 62931b3 + ec843e2 commit 4eddc55

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed

integration_tests/test_framework/test_framework.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,12 +350,17 @@ def setup_w3(self):
350350
log = self.log
351351
self._cw3 = CWeb3(CWeb3.HTTPProvider(f'http://{self.nodes[0].ip}:{self.nodes[0].rpcport}/'))
352352
self._ew3 = Web3(Web3.HTTPProvider(f'http://{self.nodes[0].ip}:{self.nodes[0].ethrpcportv2}/'))
353+
self._legacy_ew3 = Web3(Web3.HTTPProvider(f'http://{self.nodes[0].ip}:{self.nodes[0].ethrpcport}/'))
354+
353355
self.cw3.wallet.add_accounts(self.core_accounts)
354356
self.cw3.cfx.default_account = self.core_accounts[0].address
355357

356358
self.ew3.middleware_onion.add(SignAndSendRawMiddlewareBuilder.build(self.evm_secrets)) # type: ignore
357359
self.eth.default_account = self.evm_accounts[0].address
358360

361+
self._legacy_ew3.middleware_onion.add(SignAndSendRawMiddlewareBuilder.build(self.evm_secrets)) # type: ignore
362+
self._legacy_ew3.eth.default_account = self.evm_accounts[0].address
363+
359364
class TestNodeMiddleware(ConfluxWeb3Middleware):
360365
def request_processor(self, method: RPCEndpoint, params: Any) -> Any:
361366
if method == RPC.cfx_sendRawTransaction or method == RPC.cfx_sendTransaction or method == "eth_sendRawTransaction" or method == "eth_sendTransaction":
@@ -377,6 +382,7 @@ def response_processor(self, method: RPCEndpoint, response: Any):
377382

378383
self.cw3.middleware_onion.add(TestNodeMiddleware)
379384
self.ew3.middleware_onion.add(TestNodeMiddleware)
385+
self._legacy_ew3.middleware_onion.add(TestNodeMiddleware)
380386

381387
def add_nodes(self, num_nodes, genesis_nodes=None, rpchost=None, binary=None, auto_recovery=False,
382388
recovery_timeout=30, is_consortium=True):

integration_tests/tests/rpc/espace/conftest.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ def set_test_params(self):
1717
self.conf_parameters["next_hardfork_transition_height"] = 1
1818
self.conf_parameters["next_hardfork_transition_number"] = 1
1919
self.conf_parameters["public_evm_rpc_async_apis"] = "\"all\"" # open all async apis
20+
self.conf_parameters["public_evm_rpc_apis"] = (
21+
'"eth,ethdebug"'
22+
)
2023
# self.conf_parameters["evm_chain_id"] = str(10)
2124
self.conf_parameters["evm_transaction_block_ratio"] = str(1)
2225
self.conf_parameters["executive_trace"] = "true"
@@ -28,6 +31,13 @@ def setup_network(self):
2831
return DefaultFramework
2932

3033

34+
@pytest.fixture(scope="module", params=["ew3_port_v1", "ew3_port_v2"])
35+
def ew3(network: ConfluxTestFramework, request):
36+
if request.param == "ew3_port_v2":
37+
return network.ew3
38+
else:
39+
return network._legacy_ew3
40+
3141
@pytest.fixture(scope="module")
3242
def erc20_contract(ew3, evm_accounts):
3343
account = evm_accounts[0]

integration_tests/tests/rpc/espace/test_rpc_error.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,11 +93,12 @@ def test_same_nonce_higher_gas_price_required(ew3, evm_accounts):
9393
"nonce": nonce,
9494
"chainId": 10,
9595
})
96-
96+
97+
tx_hash = ew3.eth.send_raw_transaction(signed["raw_transaction"])
9798
with pytest.raises(Exception, match="{'code': -32603, 'message': 'already known'}"):
98-
ew3.eth.send_raw_transaction(signed["raw_transaction"])
9999
time.sleep(1)
100100
ew3.eth.send_raw_transaction(signed["raw_transaction"])
101+
ew3.eth.wait_for_transaction_receipt(tx_hash)
101102

102103
def test_gas_too_low(ew3, evm_accounts):
103104
account = evm_accounts[0]

0 commit comments

Comments
 (0)