Skip to content

Commit cfa7388

Browse files
committed
demo p2p attack using scenario
1 parent dd59217 commit cfa7388

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

Diff for: src/warnet/scenarios/attack.py

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/usr/bin/env python3
2+
import time
3+
4+
# The base class exists inside the commander container
5+
from commander import Commander
6+
7+
from test_framework.messages import msg_addr
8+
from test_framework.p2p import P2PInterface
9+
10+
11+
def cli_help():
12+
return "Run P2P GETDATA test"
13+
14+
15+
class Attack(Commander):
16+
def set_test_params(self):
17+
self.num_nodes = 1
18+
19+
def run_test(self):
20+
print("Adding the p2p connection")
21+
22+
p = self.nodes[0].add_p2p_connection(
23+
P2PInterface(), dstaddr=self.nodes[0].rpchost, dstport=18444
24+
)
25+
26+
for _ in range(1000):
27+
print(f"Sending addr message to {self.nodes[0].rpchost}")
28+
p.send_and_ping(msg_addr())
29+
time.sleep(0.01)
30+
31+
32+
if __name__ == "__main__":
33+
Attack().main()

0 commit comments

Comments
 (0)