mirror of
https://github.com/vacp2p/status-benchmarks.git
synced 2026-01-08 23:17:56 -05:00
Add codex related utilities
This commit is contained in:
@@ -19,7 +19,7 @@ logger = logging.getLogger(__name__)
|
||||
NodesInformation = dict[str, StatusBackend]
|
||||
|
||||
|
||||
async def initialize_nodes_application(pod_names: list[str], wakuV2LightClient=False) -> NodesInformation:
|
||||
async def initialize_nodes_application(pod_names: list[str], wakuV2LightClient=False, codex_config_enabled=False, message_archive_interval=60, import_initial_delay=5) -> NodesInformation:
|
||||
# We don't need a lock here because we cannot have two pods with the same name, and no other operations are done.
|
||||
nodes_status: NodesInformation = {}
|
||||
|
||||
@@ -28,10 +28,11 @@ async def initialize_nodes_application(pod_names: list[str], wakuV2LightClient=F
|
||||
status_backend = StatusBackend(
|
||||
url=f"http://{pod_name}:3333",
|
||||
await_signals=["messages.new", "message.delivered", "node.ready", "node.started", "node.login",
|
||||
"node.stopped"]
|
||||
"node.stopped", "community.downloadingHistoryArchivesFinished"]
|
||||
)
|
||||
await status_backend.start_status_backend()
|
||||
await status_backend.create_account_and_login(wakuV2LightClient=wakuV2LightClient)
|
||||
await status_backend.create_account_and_login(wakuV2LightClient=wakuV2LightClient, codex_config_enabled=codex_config_enabled, message_archive_interval=message_archive_interval, import_initial_delay=import_initial_delay)
|
||||
await status_backend.wakuext_service.set_archive_distribution_preference("codex")
|
||||
await status_backend.wallet_service.start_wallet()
|
||||
await status_backend.wakuext_service.start_messenger()
|
||||
nodes_status[pod_name.split(".")[0]] = status_backend
|
||||
|
||||
@@ -130,10 +130,14 @@ class StatusBackend:
|
||||
"customizationColor": "red",
|
||||
# Logs config
|
||||
"logEnabled": True,
|
||||
"logToStderr": True,
|
||||
"logLevel": "DEBUG",
|
||||
# Waku config
|
||||
"wakuV2LightClient": kwargs.get("wakuV2LightClient", False),
|
||||
"wakuV2Fleet": "dst.dev",
|
||||
"codexConfigEnabled": kwargs.get("codex_config_enabled", False),
|
||||
"importInitialDelay": kwargs.get("import_initial_delay", None),
|
||||
"messageArchiveInterval": kwargs.get("message_archive_interval", None),
|
||||
}
|
||||
self._set_networks(data)
|
||||
return data
|
||||
|
||||
@@ -18,12 +18,18 @@ class WakuextAsyncService(AsyncService):
|
||||
assert json_response["error"]["message"] == "messenger already started"
|
||||
return
|
||||
|
||||
async def create_community(self, name: str, color="#ffffff", membership: int = 3) -> dict:
|
||||
async def create_community(self, name: str, color="#ffffff", membership: int = 3, history_archive_support_enabled=False) -> dict:
|
||||
# TODO check what is membership = 3
|
||||
params = [{"membership": membership, "name": name, "color": color, "description": name}]
|
||||
params = [{"membership": membership, "name": name, "color": color, "description": name,
|
||||
"historyArchiveSupportEnabled": history_archive_support_enabled}]
|
||||
json_response = await self.rpc_request("createCommunity", params)
|
||||
return json_response
|
||||
|
||||
async def create_community_chat(self, community_id: str, c: dict):
|
||||
params = [community_id, c]
|
||||
json_response = await self.rpc_request("createCommunityChat", params)
|
||||
return json_response
|
||||
|
||||
async def fetch_community(self, community_key: str) -> dict:
|
||||
params = [{"communityKey": community_key, "waitForResponse": True, "tryDatabase": True}]
|
||||
json_response = await self.rpc_request("fetchCommunity", params)
|
||||
@@ -84,3 +90,31 @@ class WakuextAsyncService(AsyncService):
|
||||
params = [{"id": contact_id, "nickname": "fake_nickname", "displayName": displayName, "ensName": ""}]
|
||||
json_response = await self.rpc_request("addContact", params)
|
||||
return json_response
|
||||
|
||||
async def get_peer_id(self):
|
||||
json_response = await self.rpc_request("peerID", [])
|
||||
return json_response
|
||||
|
||||
async def set_archive_distribution_preference(self, preference: str):
|
||||
params = [{"preference": preference}]
|
||||
response = await self.rpc_request("setArchiveDistributionPreference", params)
|
||||
return response
|
||||
|
||||
async def get_message_archival(self):
|
||||
json_response = await self.rpc_request("getMessageArchiveInterval", [])
|
||||
return json_response
|
||||
|
||||
async def has_community_archive(self, community_id: str):
|
||||
params = [community_id]
|
||||
json_response = await self.rpc_request("hasCommunityArchive", params)
|
||||
return json_response
|
||||
|
||||
async def debug(self):
|
||||
params = []
|
||||
json_response = await self.rpc_request("debug", params)
|
||||
return json_response
|
||||
|
||||
async def connect(self, peerId: str, addrs: list = []):
|
||||
params = [peerId, addrs]
|
||||
response = await self.rpc_request("connect", params)
|
||||
return response
|
||||
|
||||
Reference in New Issue
Block a user