test: threshold set to 2

This commit is contained in:
dqy 2023-10-24 21:00:19 +08:00
parent 4e577e41c7
commit 63933a1d19

View File

@ -96,6 +96,7 @@ class C(BaseModel):
Tuple: Tuple[capsule, int]
ip: str
# receive messages from nodes
@app.post("/receive_messages")
async def receive_messages(message: C):
@ -180,6 +181,7 @@ async def send_messages(
):
global pk, sk
id_list = []
print(node_ips)
# calculate id of nodes
for node_ip in node_ips:
ip_parts = node_ip.split(".")
@ -256,9 +258,6 @@ async def request_message(i_m: Request_Message):
(public_key, threshold),
)
try:
if response.status_code == 200:
data = response.json()
@ -301,7 +300,8 @@ async def recieve_request(i_m: IP_Message):
if source_ip != i_m.dest_ip:
return HTTPException(status_code=400, detail="Wrong ip")
dest_ip = i_m.source_ip
threshold = random.randrange(1, 2)
# threshold = random.randrange(1, 2)
threshold = 2
own_public_key = pk
pk_B = i_m.pk
@ -326,7 +326,6 @@ async def recieve_request(i_m: IP_Message):
def get_own_ip() -> str:
ip = os.environ.get("HOST_IP", "IP not set")
return ip
@ -334,7 +333,7 @@ def get_own_ip() -> str:
# get node list from central server
def get_node_list(count: int, server_addr: str):
url = "http://" + server_addr + "/server/send_nodes_list?count=" + str(count)
response = requests.get(url,timeout=3)
response = requests.get(url, timeout=3)
# Checking the response
if response.status_code == 200:
print("Success get node list")