From 99d884004698d0a8ed864a64901d6aeedb99cfe2 Mon Sep 17 00:00:00 2001 From: Steven Roose Date: Tue, 7 May 2019 18:41:46 +0100 Subject: [PATCH] Add pegin double spend test to functional test --- qa/rpc-tests/feature_fedpeg.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/qa/rpc-tests/feature_fedpeg.py b/qa/rpc-tests/feature_fedpeg.py index a6c03540a5..7ca4960b61 100755 --- a/qa/rpc-tests/feature_fedpeg.py +++ b/qa/rpc-tests/feature_fedpeg.py @@ -203,6 +203,14 @@ class FedPegTest(BitcoinTestFramework): # Should succeed via wallet lookup for address match, and when given pegtxid1 = sidechain.claimpegin(raw, proof) + # Make sure a double spend of the pegin doesn't get accepted while another is in mempool. + try: + pegtxid1 = sidechain.claimpegin(raw, proof) + raise Exception("double spending a pegin should not be accepted in mempool!") + except JSONRPCException as e: + print('RPC ERROR:', e.error['message']) + assert("pegin-already-claimed" in e.error["message"]) + # Will invalidate the block that confirms this transaction later self.sync_all() blockhash = sidechain2.generate(1) @@ -240,6 +248,14 @@ class FedPegTest(BitcoinTestFramework): if sidechain.gettransaction(pegtxid1)["confirmations"] != 6: raise Exception("Peg-in should be back to 6 confirms.") + # Make sure a double spend of the pegin doesn't get accepted while another is confirmed. + try: + pegtxid1 = sidechain.claimpegin(raw, proof) + raise Exception("double spending a pegin should not be accepted in mempool!") + except JSONRPCException as e: + print('RPC ERROR:', e.error['message']) + assert("pegin-already-claimed" in e.error["message"]) + # Do multiple claims in mempool n_claims = 6