|
16 | 16 | stop_node, |
17 | 17 | ) |
18 | 18 |
|
19 | | -# Sync mempool, make a block, sync blocks |
20 | | -def sync_all(sidechain, sidechain2, makeblock=True): |
21 | | - block = "" |
22 | | - timeout = 20 |
23 | | - while len(sidechain.getrawmempool()) != len(sidechain2.getrawmempool()): |
24 | | - time.sleep(1) |
25 | | - timeout -= 1 |
26 | | - if timeout == 0: |
27 | | - raise Exception("Peg-in has failed to propagate.") |
28 | | - if makeblock: |
29 | | - block = sidechain2.generate(1) |
30 | | - while sidechain.getblockcount() != sidechain2.getblockcount(): |
31 | | - time.sleep(1) |
32 | | - timeout -= 1 |
33 | | - if timeout == 0: |
34 | | - raise Exception("Blocks are not propagating.") |
35 | | - return block |
36 | | - |
37 | 19 | def get_new_unconfidential_address(node): |
38 | 20 | addr = node.getnewaddress() |
39 | 21 | val_addr = node.validateaddress(addr) |
@@ -158,7 +140,7 @@ def run_test(self): |
158 | 140 | parent.generate(1) |
159 | 141 | time.sleep(2) |
160 | 142 | proof = parent.gettxoutproof([txid1]) |
161 | | - |
| 143 | + |
162 | 144 | raw = parent.getrawtransaction(txid1) |
163 | 145 | print('raw', parent.getrawtransaction(txid1, True)) |
164 | 146 |
|
@@ -202,8 +184,9 @@ def run_test(self): |
202 | 184 | pegtxid1 = sidechain.claimpegin(raw, proof) |
203 | 185 |
|
204 | 186 | # Will invalidate the block that confirms this transaction later |
205 | | - sync_all(parent, parent2) |
206 | | - blockhash = sync_all(sidechain, sidechain2) |
| 187 | + self.sync_all() |
| 188 | + blockhash = sidechain2.generate(1) |
| 189 | + self.sync_all() |
207 | 190 | sidechain.generate(5) |
208 | 191 |
|
209 | 192 | tx1 = sidechain.gettransaction(pegtxid1) |
@@ -252,9 +235,7 @@ def run_test(self): |
252 | 235 | raw = parent.getrawtransaction(txid) |
253 | 236 | pegtxs += [sidechain.claimpegin(raw, proof)] |
254 | 237 |
|
255 | | - sync_all(parent, parent2) |
256 | | - sync_all(sidechain, sidechain2) |
257 | | - |
| 238 | + self.sync_all() |
258 | 239 | sidechain2.generate(1) |
259 | 240 | for pegtxid in pegtxs: |
260 | 241 | tx = sidechain.gettransaction(pegtxid) |
@@ -324,7 +305,7 @@ def run_test(self): |
324 | 305 | # Don't make a block, race condition when pegin-invalid block |
325 | 306 | # is awaiting further validation, nodes reject subsequent blocks |
326 | 307 | # even ones they create |
327 | | - sync_all(sidechain, sidechain2, makeblock=False) |
| 308 | + self.sync_all() |
328 | 309 | print("Now send funds out in two stages, partial, and full") |
329 | 310 | some_btc_addr = get_new_unconfidential_address(parent) |
330 | 311 | bal_1 = sidechain.getwalletinfo()["balance"]["bitcoin"] |
|
0 commit comments