-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest.py
88 lines (72 loc) · 1.75 KB
/
test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
import requests
import time
URL = "http://127.0.0.1:8001/"
times = 0
# setup
print("Start setup...")
r = requests.post(URL + "setup", json={})
if r.status_code == 200:
times += 1
print(times, r.text)
else:
print("ERROR")
exit(1)
print("Setup ok")
# register
print("Start register test, register two account, maybe 10s")
for _ in range(2):
r = requests.post(URL + "register", json={"pubkey": "00", "psk": "00"})
if r.status_code == 200:
times += 1
print(times, r.text)
else:
print("ERROR REGISTER")
exit(1)
print("Waiting register onchain...")
time.sleep(10)
# deposit
print("Start deposit test, maybe need 15s")
r = requests.post(URL + "deposit", json={"to": "0", "amount": "10000", "psk": "00"})
if r.status_code == 200:
times += 1
print(times, r.text)
else:
print("ERROR DEPOSIT")
exit(1)
print("Waiting deposit onchain...")
time.sleep(15)
# withdraw
print("Start withdraw test, maybe need 15s")
r = requests.post(URL + "withdraw", json={"from": "0", "amount": "10", "psk": "00"})
if r.status_code == 200:
times += 1
print(times, r.text)
else:
print("ERROR DEPOSIT")
exit(1)
print("Waiting withdraw onchain...")
time.sleep(15)
print("Start transfer test, loop run in 0.4s new a transfer (CTRL+c to kill)...")
uses = ["0", "1"]
t_amount = 10000
s_amount = 0
while True:
times += 1
time.sleep(0.4)
t_from = "0"
t_to = "1"
amount = 9
data = {
"from": t_from,
"to": t_to,
"amount": str(amount),
"psk": "00",
}
r = requests.post(URL + "transfer", json=data)
if r.status_code == 200:
t_amount -= amount
s_amount += amount
print(times, r.text)
else:
print("ERROR TRANSFER")
exit(1)