Skip to content

Commit d937729

Browse files
committed
create StressTest
1 parent 7ca03d1 commit d937729

File tree

2 files changed

+31
-9
lines changed

2 files changed

+31
-9
lines changed

src/stresstest.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
from client import client
2+
from threading import Thread
3+
from main import main
4+
from time import sleep
5+
from utils import readjson
6+
7+
def stress():
8+
main()
9+
10+
for i in range(15):
11+
Thread(target=client, args=("stress", str(i), i%2)).start()
12+
# print(f"Client {i} started\n")
13+
# client("stress", str(i), i%2)
14+
# print(f"\nClient {i} finished\n")
15+
sleep(0.2)
16+
17+
18+
sleep(5)
19+
20+
assert(readjson("election") == {
21+
"Candidato 1": 7,
22+
"Candidato 2": 8
23+
})
24+
25+
assert(len(readjson("public_keys")) == 15)
26+
assert(len(readjson("private_keys"))== 15)
27+
28+
print("\nTeste de estresse passou com sucesso.")
29+
30+
if __name__ == '__main__':
31+
stress()

src/variousclients.py

Lines changed: 0 additions & 9 deletions
This file was deleted.

0 commit comments

Comments
 (0)