Simulator Test

This commit is contained in:
mjalalzai 2023-07-20 16:26:25 -04:00
parent ab1d6e5b69
commit ac1d5fd17a
2 changed files with 2 additions and 2 deletions

View File

@ -52,9 +52,9 @@ def simulate_message_passing(committee, latency):
int: The number of levels the message passed through.
"""
# Base case: if the committee is the root (no parent), return 0 (the message reached the root)
time.sleep(latency)
if committee.parent_committee is None:
return 0
time.sleep(latency)
# Simulate the message passing to the parent committee and get its result
parent_result = simulate_message_passing(committee.parent_committee,latency)

View File

@ -16,7 +16,7 @@ def test_message_passing():
result = simulate_message_passing(leaf_committee, latency)
end_time = time.time()
expected_result = num_levels - 1
expected_result = num_levels
assert result == expected_result, f"Test Case 1 failed. Expected: {expected_result}, Got: {result}"
print(f"Test Case 1: Number of Levels Message Passed: {result}, Elapsed Time: {end_time - start_time:.4f} seconds")