test_: added test case for Signals via ws endpoint
This commit is contained in:
parent
f859b58c38
commit
f51d4654f6
|
@ -15,7 +15,12 @@ def pytest_addoption(parser):
|
||||||
help="",
|
help="",
|
||||||
default="http://0.0.0.0:3334",
|
default="http://0.0.0.0:3334",
|
||||||
)
|
)
|
||||||
|
parser.addoption(
|
||||||
|
"--ws_url",
|
||||||
|
action="store",
|
||||||
|
help="",
|
||||||
|
default="ws://0.0.0.0:8354",
|
||||||
|
)
|
||||||
parser.addoption(
|
parser.addoption(
|
||||||
"--password",
|
"--password",
|
||||||
action="store",
|
action="store",
|
||||||
|
|
|
@ -7,9 +7,10 @@ services:
|
||||||
build_tags: gowaku_no_rln
|
build_tags: gowaku_no_rln
|
||||||
build_target: statusd
|
build_target: statusd
|
||||||
build_flags: -ldflags="-X github.com/status-im/status-go/params.Version= -X github.com/status-im/status-go/params.GitCommit=11f83780d -X github.com/status-im/status-go/params.IpfsGatewayURL=https://ipfs.status.im/ -X github.com/status-im/status-go/vendor/github.com/ethereum/go-ethereum/metrics.EnabledStr=true"
|
build_flags: -ldflags="-X github.com/status-im/status-go/params.Version= -X github.com/status-im/status-go/params.GitCommit=11f83780d -X github.com/status-im/status-go/params.IpfsGatewayURL=https://ipfs.status.im/ -X github.com/status-im/status-go/vendor/github.com/ethereum/go-ethereum/metrics.EnabledStr=true"
|
||||||
entrypoint: ["statusd", "-c", "/static/configs/config.json", "--seed-phrase=test test test test test test test test test test test junk", "--password=Strong12345"]
|
entrypoint: ["statusd", "-c", "/static/configs/config.json", "--server=0.0.0.0:8354", "--seed-phrase=test test test test test test test test test test test junk", "--password=Strong12345"]
|
||||||
ports:
|
# ports:
|
||||||
- 3333:3333
|
# - 3333:3333
|
||||||
|
# - 8354:8354 # use for local debbuging only
|
||||||
healthcheck:
|
healthcheck:
|
||||||
test: ["CMD-SHELL", "curl -X POST --data '{\"jsonrpc\":\"2.0\",\"method\":\"net_version\",\"params\":[],\"id\":1}' -H 'Content-Type: application/json' http://0.0.0.0:3333 || exit 1"]
|
test: ["CMD-SHELL", "curl -X POST --data '{\"jsonrpc\":\"2.0\",\"method\":\"net_version\",\"params\":[],\"id\":1}' -H 'Content-Type: application/json' http://0.0.0.0:3333 || exit 1"]
|
||||||
interval: 5s
|
interval: 5s
|
||||||
|
@ -25,8 +26,8 @@ services:
|
||||||
build_target: statusd
|
build_target: statusd
|
||||||
build_flags: -ldflags="-X github.com/status-im/status-go/params.Version= -X github.com/status-im/status-go/params.GitCommit=11f83780d -X github.com/status-im/status-go/params.IpfsGatewayURL=https://ipfs.status.im/ -X github.com/status-im/status-go/vendor/github.com/ethereum/go-ethereum/metrics.EnabledStr=true"
|
build_flags: -ldflags="-X github.com/status-im/status-go/params.Version= -X github.com/status-im/status-go/params.GitCommit=11f83780d -X github.com/status-im/status-go/params.IpfsGatewayURL=https://ipfs.status.im/ -X github.com/status-im/status-go/vendor/github.com/ethereum/go-ethereum/metrics.EnabledStr=true"
|
||||||
entrypoint: ["statusd", "-c", "/static/configs/config.json", "--seed-phrase=test test test test test test test test test test test takoe", "--password=Strong12345"]
|
entrypoint: ["statusd", "-c", "/static/configs/config.json", "--seed-phrase=test test test test test test test test test test test takoe", "--password=Strong12345"]
|
||||||
ports:
|
# ports:
|
||||||
- 3334:3333
|
# - 3334:3333 # use for local debbuging only
|
||||||
healthcheck:
|
healthcheck:
|
||||||
test: ["CMD-SHELL", "curl -X POST --data '{\"jsonrpc\":\"2.0\",\"method\":\"net_version\",\"params\":[],\"id\":1}' -H 'Content-Type: application/json' http://0.0.0.0:3333 || exit 1"]
|
test: ["CMD-SHELL", "curl -X POST --data '{\"jsonrpc\":\"2.0\",\"method\":\"net_version\",\"params\":[],\"id\":1}' -H 'Content-Type: application/json' http://0.0.0.0:3333 || exit 1"]
|
||||||
interval: 5s
|
interval: 5s
|
||||||
|
@ -38,8 +39,8 @@ services:
|
||||||
depends_on:
|
depends_on:
|
||||||
status-go:
|
status-go:
|
||||||
condition: service_healthy
|
condition: service_healthy
|
||||||
# status-go-no-funds:
|
status-go-no-funds:
|
||||||
# condition: service_healthy
|
condition: service_healthy
|
||||||
deploy-communities-contracts:
|
deploy-communities-contracts:
|
||||||
condition: service_completed_successfully
|
condition: service_completed_successfully
|
||||||
build:
|
build:
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
[pytest]
|
[pytest]
|
||||||
addopts = -s -v --tb=short --junitxml=results.xml
|
addopts = -s -v --tb=short --junitxml=results.xml
|
||||||
|
|
||||||
|
log_cli=true
|
||||||
|
log_level=INFO
|
||||||
|
|
||||||
markers =
|
markers =
|
||||||
rpc
|
rpc
|
||||||
wallet
|
wallet
|
||||||
|
|
|
@ -3,3 +3,4 @@ jsonschema~=3.2.0
|
||||||
pytest==6.2.4
|
pytest==6.2.4
|
||||||
requests==2.31.0
|
requests==2.31.0
|
||||||
genson~=1.2.2
|
genson~=1.2.2
|
||||||
|
websocket-client~=1.4.2
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
import json
|
import json
|
||||||
|
import websocket
|
||||||
|
import threading
|
||||||
|
import logging
|
||||||
import jsonschema
|
import jsonschema
|
||||||
import requests
|
import requests
|
||||||
from conftest import option, user_1, user_2
|
from conftest import option, user_1, user_2
|
||||||
|
@ -44,7 +47,9 @@ class RpcTestCase:
|
||||||
|
|
||||||
def verify_json_schema(self, response, method):
|
def verify_json_schema(self, response, method):
|
||||||
with open(f"{option.base_dir}/schemas/{method}", "r") as schema:
|
with open(f"{option.base_dir}/schemas/{method}", "r") as schema:
|
||||||
jsonschema.validate(instance=response.json(), schema=json.load(schema))
|
jsonschema.validate(instance=response.json(),
|
||||||
|
schema=json.load(schema))
|
||||||
|
|
||||||
|
|
||||||
class TransactionTestCase(RpcTestCase):
|
class TransactionTestCase(RpcTestCase):
|
||||||
|
|
||||||
|
@ -89,7 +94,43 @@ class TransactionTestCase(RpcTestCase):
|
||||||
|
|
||||||
response = self.wallet_create_multi_transaction()
|
response = self.wallet_create_multi_transaction()
|
||||||
try:
|
try:
|
||||||
self.tx_hash = response.json()["result"]["hashes"][str(self.network_id)][0]
|
self.tx_hash = response.json(
|
||||||
|
)["result"]["hashes"][str(self.network_id)][0]
|
||||||
except (KeyError, json.JSONDecodeError):
|
except (KeyError, json.JSONDecodeError):
|
||||||
raise Exception(response.content)
|
raise Exception(response.content)
|
||||||
|
|
||||||
|
|
||||||
|
class SignalTestCase(RpcTestCase):
|
||||||
|
|
||||||
|
received_signals = []
|
||||||
|
|
||||||
|
def _on_message(self, ws, signal):
|
||||||
|
self.received_signals.append(signal)
|
||||||
|
|
||||||
|
def _on_error(self, ws, error):
|
||||||
|
logging.info(f"Error: {error}")
|
||||||
|
|
||||||
|
def _on_close(self, ws, close_status_code, close_msg):
|
||||||
|
logging.info(f"Connection closed: {close_status_code}, {close_msg}")
|
||||||
|
|
||||||
|
def _on_open(self, ws):
|
||||||
|
logging.info("Connection opened")
|
||||||
|
|
||||||
|
def _connect(self):
|
||||||
|
self.url = f"{option.ws_url}/signals"
|
||||||
|
|
||||||
|
ws = websocket.WebSocketApp(self.url,
|
||||||
|
on_message=self._on_message,
|
||||||
|
on_error=self._on_error,
|
||||||
|
on_close=self._on_close)
|
||||||
|
|
||||||
|
ws.on_open = self._on_open
|
||||||
|
|
||||||
|
ws.run_forever()
|
||||||
|
|
||||||
|
def setup_method(self):
|
||||||
|
super().setup_method()
|
||||||
|
|
||||||
|
websocket_thread = threading.Thread(target=self._connect)
|
||||||
|
websocket_thread.daemon = True
|
||||||
|
websocket_thread.start()
|
||||||
|
|
Loading…
Reference in New Issue