Skip to content

Commit 7eb5033

Browse files
MarcoFalkePastaPastaPasta
authored andcommitted
Merge bitcoin#22510: test: add test for RPC error 'Transaction already in block chain'
2ebf2fe test: check for RPC error 'Transaction already in block chain' (-27) (Sebastian Falbesoner) Pull request description: This PR adds missing test coverage for the RPC error "Transaction already in block chain" (error code `RPC_VERIFY_ALREADY_IN_CHAIN` = `RPC_TRANSACTION_ALREADY_IN_CHAIN` = -27), which is thrown in the function `BroadcastTransaction` (src/node/transaction.cpp). ACKs for top commit: kristapsk: ACK 2ebf2fe (ran linter, looked at changes and ran modified test and checked code in `src/node/transaction.cpp`) darosior: ACK 2ebf2fe Tree-SHA512: 8bfbd3ff3da0cb3b8745f69b8ca2377f85fa99f0270750840b60e6ae43b5645c5c59b236993e8b2ad0444ec4171484e4f1ee23fa7e81b79d4222bcb623666fa5
1 parent 06e4671 commit 7eb5033

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

test/functional/rpc_rawtransaction.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -422,5 +422,15 @@ def run_test(self):
422422
assert_equal(testres['allowed'], True)
423423
self.nodes[2].sendrawtransaction(hexstring=rawTxSigned['hex'], maxfeerate='0.20000000')
424424

425+
self.log.info('sendrawtransaction/testmempoolaccept with tx that is already in the chain')
426+
self.nodes[2].generate(1)
427+
self.sync_blocks()
428+
for node in self.nodes:
429+
testres = node.testmempoolaccept([rawTxSigned['hex']])[0]
430+
assert_equal(testres['allowed'], False)
431+
assert_equal(testres['reject-reason'], 'txn-already-known')
432+
assert_raises_rpc_error(-27, 'Transaction already in block chain', node.sendrawtransaction, rawTxSigned['hex'])
433+
434+
425435
if __name__ == '__main__':
426436
RawTransactionsTest().main()

0 commit comments

Comments
 (0)