mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-03-26 17:52:13 +01:00
Merge bitcoin/bitcoin#30195: test: Added test coverage to listsinceblock rpc
881724d443d11f984a721ef1edd5777c24d1ed29 test: Added test coverage to listsinceblock rpc (kevkevinpal)
Pull request description:
This change is meant to add test coverage to this rpc error https://github.com/bitcoin/bitcoin/blob/master/src/wallet/rpc/transactions.cpp#L666C53-L666C79
This is done by renaming the first block in the blocks folder
---
Doing a quick grep for the error code in our functional tests leads to zero results
`grep -nri "Can't read block from disk" ./test/functional/`
ACKs for top commit:
achow101:
ACK 881724d443d11f984a721ef1edd5777c24d1ed29
tdb3:
re ACK for 881724d443d11f984a721ef1edd5777c24d1ed29
rkrux:
tACK [881724](881724d443
)
Tree-SHA512: c5dff20cf014d0181f49d6b161f1364e1c6b79e8661047f77f07e21e59f4d1f2fd6f745538c8fc5bd6d4244650a840dd64d184634366f7c21fa67141a60af44a
This commit is contained in:
commit
f011022d53
@ -40,6 +40,7 @@ class ListSinceBlockTest(BitcoinTestFramework):
|
||||
self.test_no_blockhash()
|
||||
self.test_invalid_blockhash()
|
||||
self.test_reorg()
|
||||
self.test_cant_read_block()
|
||||
self.test_double_spend()
|
||||
self.test_double_send()
|
||||
self.double_spends_filtered()
|
||||
@ -167,6 +168,31 @@ class ListSinceBlockTest(BitcoinTestFramework):
|
||||
found = next(tx for tx in transactions if tx['txid'] == senttx)
|
||||
assert_equal(found['blockheight'], self.nodes[0].getblockheader(nodes2_first_blockhash)['height'])
|
||||
|
||||
def test_cant_read_block(self):
|
||||
self.log.info('Test the RPC error "Can\'t read block from disk"')
|
||||
|
||||
# Split network into two
|
||||
self.split_network()
|
||||
|
||||
# generate on both sides
|
||||
nodes1_last_blockhash = self.generate(self.nodes[1], 6, sync_fun=lambda: self.sync_all(self.nodes[:2]))[-1]
|
||||
self.generate(self.nodes[2], 7, sync_fun=lambda: self.sync_all(self.nodes[2:]))[0]
|
||||
|
||||
self.join_network()
|
||||
|
||||
# Renaming the block file to induce unsuccessful block read
|
||||
blk_dat = (self.nodes[0].blocks_path / "blk00000.dat")
|
||||
blk_dat_moved = blk_dat.rename(self.nodes[0].blocks_path / "blk00000.dat.moved")
|
||||
assert not blk_dat.exists()
|
||||
|
||||
# listsinceblock(nodes1_last_blockhash) should now fail as blocks are not accessible
|
||||
assert_raises_rpc_error(-32603, "Can't read block from disk",
|
||||
self.nodes[0].listsinceblock, nodes1_last_blockhash)
|
||||
|
||||
# Restoring block file
|
||||
blk_dat_moved.rename(self.nodes[0].blocks_path / "blk00000.dat")
|
||||
assert blk_dat.exists()
|
||||
|
||||
def test_double_spend(self):
|
||||
'''
|
||||
This tests the case where the same UTXO is spent twice on two separate
|
||||
|
Loading…
x
Reference in New Issue
Block a user