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

Method test_conflicting

test/functional/rpc_packages.py:234–267  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

232 assert_equal(testres_single, testres_multiple)
233
234 def test_conflicting(self):
235 node = self.nodes[0]
236 prevtx = self.coins.pop()
237 inputs = [{"txid": prevtx["txid"], "vout": 0}]
238 output1 = [{node.get_deterministic_priv_key().address: 50 - 0.00125}, {"fee" : 0.00125}]
239 output2 = [{ADDRESS_BCRT1_P2WSH_OP_TRUE: 50 - 0.00125}, {"fee" : 0.00125}]
240
241 # tx1 and tx2 share the same inputs
242 rawtx1 = node.createrawtransaction(inputs, output1)
243 rawtx2 = node.createrawtransaction(inputs, output2)
244 signedtx1 = node.signrawtransactionwithkey(hexstring=rawtx1, privkeys=self.privkeys)
245 signedtx2 = node.signrawtransactionwithkey(hexstring=rawtx2, privkeys=self.privkeys)
246 tx1 = tx_from_hex(signedtx1["hex"])
247 tx2 = tx_from_hex(signedtx2["hex"])
248 assert signedtx1["complete"]
249 assert signedtx2["complete"]
250
251 # Ensure tx1 and tx2 are valid by themselves
252 assert node.testmempoolaccept([signedtx1["hex"]])[0]["allowed"]
253 assert node.testmempoolaccept([signedtx2["hex"]])[0]["allowed"]
254
255 self.log.info("Test duplicate transactions in the same package")
256 testres = node.testmempoolaccept([signedtx1["hex"], signedtx1["hex"]])
257 assert_equal(testres, [
258 {"txid": tx1.rehash(), "wtxid": tx1.getwtxid(), "package-error": "conflict-in-package"},
259 {"txid": tx1.rehash(), "wtxid": tx1.getwtxid(), "package-error": "conflict-in-package"}
260 ])
261
262 self.log.info("Test conflicting transactions in the same package")
263 testres = node.testmempoolaccept([signedtx1["hex"], signedtx2["hex"]])
264 assert_equal(testres, [
265 {"txid": tx1.rehash(), "wtxid": tx1.getwtxid(), "package-error": "conflict-in-package"},
266 {"txid": tx2.rehash(), "wtxid": tx2.getwtxid(), "package-error": "conflict-in-package"}
267 ])
268
269 def test_rbf(self):
270 node = self.nodes[0]

Callers 1

run_testMethod · 0.95

Calls 6

tx_from_hexFunction · 0.90
assert_equalFunction · 0.90
infoMethod · 0.80
getwtxidMethod · 0.80
rehashMethod · 0.45

Tested by

no test coverage detected