-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtestReorg.sh
executable file
·61 lines (60 loc) · 2.12 KB
/
testReorg.sh
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
#!/bin/bash
echo "Start with clean environment"
./downAll.sh
./rmAllWithWallets.sh
echo "Start bitoind instances for Alice, Bob and Carl"
./upAll.sh
sleep 5s
echo "Create wallets for every node."
./cwAll.sh
echo "Connections"
./connect.sh alice bob
./connect.sh alice carl
./connect.sh bob carl
echo "Alice generates 200 blocks."
./gbalice.sh 200
echo "Bob generates 200 blocks."
./gbbob.sh 200
echo "Create new address for each node"
./naAll.sh
echo "Press key when zmq-listening program is up and connected."
read -N 1
echo "Alice Send to Bob, 1 tx in all mempools since we are connected"
./alicest.sh bob
echo "Wait tx to propagate to other nodes"
sleep 10s
echo "Disconnect all nodes to simulate chain reorg."
./disconnect.sh alice bob
./disconnect.sh alice carl
./disconnect.sh bob carl
echo "Alice generates 10 tx when disconnected"
for n in {1..10}; do ./alicest.sh bob; done
echo "Alice generate 1 block containing 11 transactions"
./gbalice.sh
echo "Alice generate another transaction for Bob."
./alicest.sh bob
echo "Alice generate another block containing 1 transaction"
./gbalice.sh
echo "At this point Alice has generated two blocks and its mempool is empty."
echo "Bob and Carl are oblivious of this since they are disconnected."
echo "Bob mines a block containing 1 transaction (the one sent by alice while connected)"
./gbbob.sh
echo "Bob create 2 transactions to Alice."
for n in {1..2}; do ./bobst.sh alice; done
echo "Bob mines a block containing last 2 txs."
./gbbob.sh
echo "Bob create 3 transactions to Alice."
for n in {1..3}; do ./bobst.sh alice; done
echo "Bob mines a block containing last 3 txs."
./gbbob.sh
echo "At this point both alice and bob mempool is empty, but Bob has mined 3 blocks and Alice only 2."
echo "We connect nodes again to see the chain reorg."
./connect.sh alice bob
./connect.sh alice carl
./connect.sh bob carl
echo "Wait for reorg in nodes."
sleep 1s
echo "Alice overrides its two blocks and all transactions oblivious to other nodes (11) are now in it's mempool."
./calice.sh getmempoolinfo
echo "Bob has its mempool empty since Alice does not resend transactions from overrided blocks."
./cbob.sh getmempoolinfo