test_: Code Migration from status-cli-tests cleanup
This commit is contained in:
parent
9fa435a46f
commit
2c385681c5
|
@ -46,4 +46,6 @@ LATENCY_CMD = "sudo tc qdisc add dev eth0 root netem delay 1s 100ms distribution
|
|||
PACKET_LOSS_CMD = "sudo tc qdisc add dev eth0 root netem loss 50%"
|
||||
LOW_BANDWIDTH_CMD = "sudo tc qdisc add dev eth0 root tbf rate 1kbit burst 1kbit"
|
||||
REMOVE_TC_CMD = "sudo tc qdisc del dev eth0 root"
|
||||
NUM_CONTACT_REQUESTS = int(os.getenv("NUM_CONTACT_REQUESTS", "5"))
|
||||
NUM_CONTACT_REQUESTS = int(os.getenv("NUM_CONTACT_REQUESTS", "5"))
|
||||
NUM_MESSAGES = int(os.getenv("NUM_MESSAGES", "25"))
|
||||
DELAY_BETWEEN_MESSAGES = int(os.getenv("NUM_MESSAGES", "1"))
|
|
@ -41,16 +41,6 @@ class StatusNode:
|
|||
self.last_response = None
|
||||
self.api = StatusNodeRPC(self.port, self.name)
|
||||
|
||||
def setup_method(self):
|
||||
self.rpc_client = RpcClient(option.rpc_url_statusd)
|
||||
await_signals = ["history.request.started", "history.request.completed"]
|
||||
self.signal_client = SignalClient(option.ws_url_statusd, await_signals)
|
||||
|
||||
# Start WebSocket connection in a separate thread
|
||||
websocket_thread = threading.Thread(target=self.signal_client._connect)
|
||||
websocket_thread.daemon = True
|
||||
websocket_thread.start()
|
||||
|
||||
def initialize_node(self, name, port, data_dir, account_data):
|
||||
self.name = name
|
||||
self.port = port
|
||||
|
@ -93,7 +83,7 @@ class StatusNode:
|
|||
|
||||
def start_signal_client(self):
|
||||
ws_url = f"ws://localhost:{self.port}"
|
||||
await_signals = ["history.request.started", "history.request.completed"]
|
||||
await_signals = ["history.request.started", "history.request.completed","messages.new"]
|
||||
self.signal_client = SignalClient(ws_url, await_signals)
|
||||
|
||||
websocket_thread = threading.Thread(target=self.signal_client._connect)
|
||||
|
@ -159,6 +149,10 @@ class StatusNode:
|
|||
params = [{"id": pubkey, "message": message}]
|
||||
return self.api.send_rpc_request("wakuext_sendContactRequest", params)
|
||||
|
||||
def send_message(self, pubkey, message):
|
||||
params = [{"id": pubkey, "message": message}]
|
||||
return self.api.send_rpc_request("wakuext_sendOneToOneMessage", params)
|
||||
|
||||
def pause_process(self):
|
||||
if self.pid:
|
||||
logger.info(f"Pausing node with pid: {self.pid}")
|
||||
|
|
|
@ -2,6 +2,8 @@ from contextlib import contextmanager
|
|||
import inspect
|
||||
import subprocess
|
||||
import pytest
|
||||
from tenacity import retry
|
||||
|
||||
from src.libs.common import delay
|
||||
from src.libs.custom_logger import get_custom_logger
|
||||
from src.node.status_node import StatusNode
|
||||
|
@ -101,3 +103,12 @@ class StepsCommon:
|
|||
break
|
||||
|
||||
return timestamp, message_id, response
|
||||
|
||||
# @retry(stop=stop_after_delay(40), wait=wait_fixed(0.5), reraise=True)
|
||||
def accept_contact_request(self, sending_node=None, receiving_node_pk=None):
|
||||
if not sending_node:
|
||||
sending_node = self.second_node
|
||||
if not receiving_node_pk:
|
||||
receiving_node_pk = self.first_node_pubkey
|
||||
sending_node.send_contact_request(receiving_node_pk, "hi")
|
||||
# assert sending_node.wait_for_signal(["accepted your contact request"], timeout=10)
|
||||
|
|
|
@ -10,7 +10,7 @@ from validators.contact_request_validator import ContactRequestValidator
|
|||
|
||||
class TestContactRequest(StepsCommon):
|
||||
def test_contact_request_baseline(self):
|
||||
timeout_secs = 180
|
||||
timeout_secs = 10
|
||||
num_contact_requests = NUM_CONTACT_REQUESTS
|
||||
project_root = get_project_root()
|
||||
nodes = []
|
||||
|
@ -78,7 +78,7 @@ class TestContactRequest(StepsCommon):
|
|||
+ "\n".join(formatted_missing_requests)
|
||||
)
|
||||
|
||||
def send_and_wait_for_message(self, nodes, display_name, index, timeout=45):
|
||||
def send_and_wait_for_message(self, nodes, display_name, index, timeout=10):
|
||||
first_node, second_node = nodes
|
||||
first_node_pubkey = first_node.get_pubkey(display_name)
|
||||
contact_request_message = f"contact_request_{index}"
|
||||
|
|
Loading…
Reference in New Issue