MCPcopy Create free account
hub / github.com/ElementsProject/elements / run_test

Method run_test

test/functional/feature_fedpeg.py:187–746  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

185 assert_equal(sidechain.gettransaction(pegout_txid)["confirmations"], 1)
186
187 def run_test(self):
188 self.import_deterministic_coinbase_privkeys() # Create wallets for all nodes
189
190 parent = self.nodes[0]
191 #parent2 = self.nodes[1]
192 sidechain = self.nodes[2]
193 sidechain2 = self.nodes[3]
194
195 # If we're testing post-transition, force a fedpegscript transition and
196 # getting rid of old fedpegscript by making at least another epoch pass by
197 WSH_OP_TRUE = self.nodes[0].decodescript("51")["segwit"]["hex"]
198 # We just randomize the keys a bit to get another valid fedpegscript
199 tweaked = sidechain.tweakfedpegscript("f00dbabe")
200 assert sidechain.getaddressinfo(tweaked['p2wsh'])['iswitness']
201 assert not sidechain.getaddressinfo(tweaked['p2shwsh'])['iswitness']
202 new_fedpegscript = tweaked["script"]
203 if self.options.post_transition:
204 print("Running test post-transition")
205 for _ in range(30):
206 block_hex = sidechain.getnewblockhex(0, {"signblockscript":WSH_OP_TRUE, "max_block_witness":10, "fedpegscript":new_fedpegscript, "extension_space":[]})
207 sidechain.submitblock(block_hex)
208 assert_equal(sidechain.getsidechaininfo()["current_fedpegscripts"], [new_fedpegscript]*2)
209
210 if self.options.pre_transition:
211 print("Running test pre-transition, dynafed activated from first block")
212
213 for node in self.nodes:
214 node.importprivkey(privkey=node.get_deterministic_priv_key().key, label="mining")
215 util.node_fastmerkle = sidechain
216
217 self.generate(parent, 101, sync_fun=self.no_op)
218 self.generate(sidechain, 101, sync_fun=self.no_op)
219 self.log.info("sidechain info: {}".format(sidechain.getsidechaininfo()))
220
221 addrs = sidechain.getpeginaddress()
222 addr = addrs["mainchain_address"]
223 assert_equal(sidechain.decodescript(addrs["claim_script"])["type"], "witness_v0_keyhash")
224 current_fedpegscript = sidechain.getsidechaininfo()["current_fedpegscripts"][0]
225 tweaked = sidechain.tweakfedpegscript(addrs["claim_script"], current_fedpegscript)
226 if sidechain.getaddressinfo(addr)['iswitness']:
227 assert_equal(tweaked['p2wsh'], addr)
228 else:
229 assert_equal(tweaked['p2shwsh'], addr)
230 txid1 = parent.sendtoaddress(addr, 24)
231 vout = find_vout_for_address(parent, txid1, addr)
232 # 10+2 confirms required to get into mempool and confirm
233 assert_equal(sidechain.getsidechaininfo()["pegin_confirmation_depth"], 10)
234 self.generate(parent, 1, sync_fun=self.no_op)
235 time.sleep(2)
236 proof = parent.gettxoutproof([txid1])
237
238 raw = parent.gettransaction(txid1)["hex"]
239
240 # Create a wallet in order to test that multi-wallet support works correctly for claimpegin
241 # (Regression test for https://github.com/ElementsProject/elements/issues/812 .)
242 sidechain.createwallet("throwaway")
243 # Set up our sidechain RPCs to use the first wallet (with empty name). We do this by
244 # overriding the RPC object in a hacky way, to avoid breaking a different hack on TestNode

Callers

nothing calls this directly

Calls 15

test_pegoutMethod · 0.95
assert_equalFunction · 0.90
find_vout_for_addressFunction · 0.90
tx_from_hexFunction · 0.90
assert_raises_rpc_errorFunction · 0.90
from_hexFunction · 0.90
CBlockClass · 0.90
add_witness_commitmentFunction · 0.90
assert_greater_thanFunction · 0.90
CTxInWitnessClass · 0.90
CTxOutNonceClass · 0.90
CTxInClass · 0.90

Tested by

no test coverage detected