mirror of
https://github.com/status-im/status-cli-tests.git
synced 2026-08-31 05:11:14 +00:00
Merge pull request #11 from status-im/feat/add-sharded-community
feat: add the first community in own shard
This commit is contained in:
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
@@ -163,6 +163,12 @@ class StatusNode:
|
||||
params = [{"membership": 3, "name": name, "color": "#ffffff", "description": name}]
|
||||
return self.api.send_rpc_request("wakuext_createCommunity", params)
|
||||
|
||||
def set_community_shard(self, community_id, index=128, private_key=None):
|
||||
params = [{"communityId": community_id, "shard": {"cluster": 16, "index": index}}]
|
||||
if private_key is not None:
|
||||
params[0]["shard"]["privateKey"] = private_key
|
||||
return self.api.send_rpc_request("wakuext_setCommunityShard", params)
|
||||
|
||||
@retry(stop=stop_after_delay(30), wait=wait_fixed(0.1), reraise=True)
|
||||
# wakuext_fetchCommunity times out sometimes so that's why we need this retry mechanism
|
||||
def fetch_community(self, community_key):
|
||||
|
||||
@@ -4,22 +4,37 @@ from time import sleep
|
||||
from src.node.status_node import StatusNode
|
||||
|
||||
num_communities = 10
|
||||
sharded_community_pk = "0x4c0883a69102937d62341493bd663cdbe3d7d0cf8d59ae34d49bdf57b582f8c4"
|
||||
root_folder = "." # Set your root folder path here
|
||||
resources_folder = os.path.join(root_folder, "resources")
|
||||
|
||||
# Ensure the resources folder exists
|
||||
os.makedirs(resources_folder, exist_ok=True)
|
||||
|
||||
|
||||
def create_community(node: StatusNode, i: int, in_shard: bool = False) -> tuple[str, str]:
|
||||
if in_shard:
|
||||
name = f"vac_qa_community_{i}_shard"
|
||||
else:
|
||||
name = f"vac_qa_community_{i}"
|
||||
response = node.create_community(name)
|
||||
community_id = response["result"]["communities"][0]["id"]
|
||||
if in_shard:
|
||||
sleep(5)
|
||||
node.set_community_shard(community_id, 128, sharded_community_pk)
|
||||
return community_id, name
|
||||
|
||||
|
||||
for i in range(num_communities):
|
||||
port = str(6130 + i)
|
||||
node = StatusNode(name=f"node{i}", port=port)
|
||||
node.start(capture_logs=False)
|
||||
sleep(4)
|
||||
|
||||
name = f"vac_qa_community_{i}"
|
||||
response = node.create_community(name)
|
||||
community_id = response["result"]["communities"][0]["id"]
|
||||
# create the first community in shard 128
|
||||
community_id, name = create_community(node, i, i == 0)
|
||||
sleep(5)
|
||||
print(f"Created community: {name} with ID: {community_id}")
|
||||
|
||||
node.stop(remove_local_data=False)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user