Skip to content

Commit 74fb1b5

Browse files
committed
Update shh integration tests
1 parent 139ffa0 commit 74fb1b5

File tree

17 files changed

+726
-105
lines changed

17 files changed

+726
-105
lines changed

docs/web3.shh.rst

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,13 @@ SHH API
77
The ``web3.shh`` object exposes methods to interact with the RPC APIs under the
88
``shh_`` namespace.
99

10+
Web3.py exposes select Whisper methods under the ``web3.geth`` and ``web3.parity``
11+
namespaces to interact with the Whisper RPC API based on which endpoints are
12+
supported by each respective client.
13+
14+
1015
.. warning:: The Whisper protocol is in flux, with incompatible versions supported
11-
by different major clients. So it is not currently included by default in the web3
12-
instance.
16+
by different major clients.
1317

1418

1519
Properties

tests/core/shh-module/conftest.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +0,0 @@
1-
import pytest
2-
3-
from web3.shh import (
4-
Shh,
5-
)
6-
7-
8-
@pytest.fixture(autouse=True)
9-
def include_shh_module(web3):
10-
Shh.attach(web3, "shh")

tests/integration/go_ethereum/common.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from web3._utils.module_testing import ( # noqa: F401
44
EthModuleTest,
55
GoEthereumPersonalModuleTest,
6+
GoEthereumShhModuleTest,
67
NetModuleTest,
78
VersionModuleTest,
89
Web3ModuleTest,
@@ -62,7 +63,7 @@ def test_eth_estimateGas_with_block(self,
6263
def test_eth_submitHashrate(self, web3):
6364
if 'v1.8.22' in web3.clientVersion:
6465
# https://github.com/ethereum/go-ethereum/commit/51db5975cc5fb88db6a0dba1826b534fd4df29d7
65-
pytest.xfail('eth_submitHashrate depracated in v1.8.22 for ethash_submitHashRate')
66+
pytest.xfail('eth_submitHashrate deprecated in 1.8.22 for ethash_submitHashRate')
6667
super().test_eth_submitHashrate(web3)
6768

6869
def test_eth_chainId(self, web3):
@@ -77,3 +78,20 @@ class GoEthereumVersionModuleTest(VersionModuleTest):
7778

7879
class GoEthereumNetModuleTest(NetModuleTest):
7980
pass
81+
82+
83+
class CommonGoEthereumShhModuleTest(GoEthereumShhModuleTest):
84+
def test_shh_sync_filter(self, web3):
85+
if 'v1.7.2' in web3.clientVersion:
86+
pytest.xfail('Whisper version 6 not supported in geth 1.7.2')
87+
super().test_shh_sync_filter(web3)
88+
89+
def test_shh_async_filter(self, web3):
90+
if 'v1.7.2' in web3.clientVersion:
91+
pytest.xfail('Whisper version 6 not supported in geth 1.7.2')
92+
super().test_shh_async_filter(web3)
93+
94+
def test_shh_post(self, web3):
95+
if 'v1.7.2' in web3.clientVersion:
96+
pytest.xfail('Whisper version 6 not supported in geth 1.7.2')
97+
super().test_shh_post(web3)

tests/integration/go_ethereum/test_goethereum_http.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from web3 import Web3
77

88
from .common import (
9+
CommonGoEthereumShhModuleTest,
910
GoEthereumEthModuleTest,
1011
GoEthereumNetModuleTest,
1112
GoEthereumPersonalModuleTest,
@@ -32,11 +33,12 @@ def geth_command_arguments(geth_binary, datadir, rpc_port):
3233
return (
3334
geth_binary,
3435
'--datadir', str(datadir),
36+
'--shh',
3537
'--nodiscover',
3638
'--fakepow',
3739
'--rpc',
3840
'--rpcport', rpc_port,
39-
'--rpcapi', 'db,eth,net,web3,personal,web3',
41+
'--rpcapi', 'db,eth,net,web3,personal,shh,web3',
4042
'--ipcdisable',
4143
)
4244

@@ -66,3 +68,7 @@ class TestGoEthereumNetModuleTest(GoEthereumNetModuleTest):
6668

6769
class TestGoEthereumPersonalModuleTest(GoEthereumPersonalModuleTest):
6870
pass
71+
72+
73+
class TestGoEthereumShhModuleTest(CommonGoEthereumShhModuleTest):
74+
pass

tests/integration/go_ethereum/test_goethereum_ipc.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from web3 import Web3
99

1010
from .common import (
11+
CommonGoEthereumShhModuleTest,
1112
GoEthereumEthModuleTest,
1213
GoEthereumNetModuleTest,
1314
GoEthereumPersonalModuleTest,
@@ -26,6 +27,7 @@ def geth_command_arguments(geth_binary, datadir, geth_ipc_path):
2627
geth_binary,
2728
'--datadir', str(datadir),
2829
'--ipcpath', geth_ipc_path,
30+
'--shh',
2931
'--nodiscover',
3032
'--fakepow',
3133
'--port', geth_port,
@@ -67,3 +69,7 @@ class TestGoEthereumNetModuleTest(GoEthereumNetModuleTest):
6769

6870
class TestGoEthereumPersonalModuleTest(GoEthereumPersonalModuleTest):
6971
pass
72+
73+
74+
class TestGoEthereumShhModuleTest(CommonGoEthereumShhModuleTest):
75+
pass

tests/integration/go_ethereum/test_goethereum_ws.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from web3 import Web3
1111

1212
from .common import (
13+
CommonGoEthereumShhModuleTest,
1314
GoEthereumEthModuleTest,
1415
GoEthereumNetModuleTest,
1516
GoEthereumPersonalModuleTest,
@@ -36,8 +37,9 @@ def geth_command_arguments(geth_binary, datadir, ws_port):
3637
'--nodiscover',
3738
'--fakepow',
3839
'--ws',
40+
'--shh',
3941
'--wsport', ws_port,
40-
'--wsapi', 'db,eth,net,web3,personal,web3',
42+
'--wsapi', 'db,eth,net,shh,web3,personal,web3',
4143
'--wsorigins', '*',
4244
'--ipcdisable',
4345
)
@@ -72,3 +74,9 @@ class TestGoEthereumPersonalModuleTest(GoEthereumPersonalModuleTest):
7274

7375
class TestMiscWebsocketTest(MiscWebsocketTest):
7476
pass
77+
78+
79+
class TestGoEthereumShhModuleTest(CommonGoEthereumShhModuleTest):
80+
def test_shh_async_filter(self, web3):
81+
pytest.xfail("async filter bug in geth ws version")
82+
super().test_shh_async_filter(web3)

tests/integration/parity/common.py

Lines changed: 11 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
from web3._utils.module_testing.eth_module import (
1414
UNKNOWN_ADDRESS,
1515
)
16+
from web3._utils.module_testing.shh_module import (
17+
ParityShhModuleTest,
18+
)
1619

1720
# some tests appear flaky with Parity v1.10.x
1821
MAX_FLAKY_RUNS = 3
@@ -167,36 +170,14 @@ def test_eth_getLogs_without_logs(self, web3, block_with_txn_with_log):
167170

168171

169172
class ParityTraceModuleTest(TraceModuleTest):
170-
def test_list_storage_keys_no_support(self, web3, emitter_contract_address):
171-
super().test_list_storage_keys_no_support(web3, emitter_contract_address)
172-
173-
def test_trace_replay_transaction(self, web3, parity_fixture_data):
174-
super().test_trace_replay_transaction(web3, parity_fixture_data)
175-
176-
def test_trace_replay_block_with_transactions(self,
177-
web3,
178-
block_with_txn,
179-
parity_fixture_data):
180-
pytest.xfail('This method does not exist in older parity versions')
181-
super().test_trace_replay_block_with_transactions(web3,
182-
block_with_txn,
183-
parity_fixture_data)
184-
185-
def test_trace_replay_block_without_transactions(self, web3, empty_block):
186-
pytest.xfail('This method does not exist in older parity versions')
187-
super().test_trace_replay_block_without_transactions(web3, empty_block)
188-
189-
def test_trace_block(self, web3, block_with_txn):
190-
super().test_trace_block(web3, block_with_txn)
191-
192-
def test_trace_transaction(self, web3, parity_fixture_data):
193-
super().test_trace_transaction(web3, parity_fixture_data)
173+
pass
194174

195-
def test_trace_call(self, web3, math_contract, math_contract_address):
196-
super().test_trace_call(web3, math_contract, math_contract_address)
197175

198-
def test_eth_call_with_0_result(self, web3, math_contract, math_contract_address):
199-
super().test_eth_call_with_0_result(web3, math_contract, math_contract_address)
176+
class CommonParityShhModuleTest(ParityShhModuleTest):
177+
def test_shh_sync_filter(self, web3):
178+
pytest.xfail("Skip until parity filter bug is resolved")
179+
super().test_shh_sync_filter(web3)
200180

201-
def test_trace_filter(self, web3, txn_filter_params, parity_fixture_data):
202-
super().test_trace_filter(web3, txn_filter_params, parity_fixture_data)
181+
def test_shh_async_filter(self, web3):
182+
pytest.xfail("Skip until parity filter bug is resolved")
183+
super().test_shh_async_filter(web3)

tests/integration/parity/test_parity_http.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
)
1515

1616
from .common import (
17+
CommonParityShhModuleTest,
1718
ParityEthModuleTest,
1819
ParityPersonalModuleTest,
1920
ParityTraceModuleTest,
@@ -50,6 +51,7 @@ def parity_command_arguments(
5051
'--jsonrpc-apis', 'all',
5152
'--no-ipc',
5253
'--no-ws',
54+
'--whisper',
5355
)
5456

5557

@@ -98,3 +100,7 @@ class TestParityPersonalModuleTest(ParityPersonalModuleTest):
98100

99101
class TestParityTraceModuleTest(ParityTraceModuleTest):
100102
pass
103+
104+
105+
class TestParityShhModuleTest(CommonParityShhModuleTest):
106+
pass

tests/integration/parity/test_parity_ipc.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
)
1313

1414
from .common import (
15+
CommonParityShhModuleTest,
1516
ParityEthModuleTest,
1617
ParityPersonalModuleTest,
1718
ParityTraceModuleTest,
@@ -48,6 +49,7 @@ def parity_command_arguments(
4849
'--ipc-apis', 'all',
4950
'--no-jsonrpc',
5051
'--no-ws',
52+
'--whisper',
5153
)
5254

5355

@@ -96,3 +98,7 @@ class TestParityPersonalModuleTest(ParityPersonalModuleTest):
9698

9799
class TestParityTraceModuleTest(ParityTraceModuleTest):
98100
pass
101+
102+
103+
class TestParityShhModuleTest(CommonParityShhModuleTest):
104+
pass

tests/integration/parity/test_parity_ws.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
)
1616

1717
from .common import (
18+
CommonParityShhModuleTest,
1819
ParityEthModuleTest,
1920
ParityPersonalModuleTest,
2021
ParityTraceModuleTest,
@@ -52,6 +53,7 @@ def parity_command_arguments(
5253
'--ws-apis', 'all',
5354
'--no-ipc',
5455
'--no-jsonrpc',
56+
'--whisper',
5557
)
5658

5759

@@ -105,3 +107,7 @@ class TestParityTraceModuleTest(ParityTraceModuleTest):
105107

106108
class TestMiscWebsocketTest(MiscWebsocketTest):
107109
pass
110+
111+
112+
class TestParityShhModuleTest(CommonParityShhModuleTest):
113+
pass

0 commit comments

Comments
 (0)