mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-03-05 14:06:27 -05:00
test: Test dumping dbs with overflow pages
This commit is contained in:
parent
fd7b16e391
commit
c1984f1282
1 changed files with 38 additions and 0 deletions
|
@ -14,6 +14,7 @@ from collections import OrderedDict
|
||||||
from test_framework.test_framework import BitcoinTestFramework
|
from test_framework.test_framework import BitcoinTestFramework
|
||||||
from test_framework.util import (
|
from test_framework.util import (
|
||||||
assert_equal,
|
assert_equal,
|
||||||
|
assert_greater_than,
|
||||||
sha256sum_file,
|
sha256sum_file,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -473,6 +474,42 @@ class ToolWalletTest(BitcoinTestFramework):
|
||||||
other_dump = self.read_dump(self.nodes[0].datadir_path / "rt-other_endian.dump")
|
other_dump = self.read_dump(self.nodes[0].datadir_path / "rt-other_endian.dump")
|
||||||
self.assert_dump(expected_dump, other_dump)
|
self.assert_dump(expected_dump, other_dump)
|
||||||
|
|
||||||
|
def test_dump_very_large_records(self):
|
||||||
|
self.log.info("Test that wallets with large records are successfully dumped")
|
||||||
|
|
||||||
|
self.start_node(0)
|
||||||
|
self.nodes[0].createwallet("bigrecords")
|
||||||
|
wallet = self.nodes[0].get_wallet_rpc("bigrecords")
|
||||||
|
|
||||||
|
# Both BDB and sqlite have maximum page sizes of 65536 bytes, with defaults of 4096
|
||||||
|
# When a record exceeds some size threshold, both BDB and SQLite will store the data
|
||||||
|
# in one or more overflow pages. We want to make sure that our tooling can dump such
|
||||||
|
# records, even when they span multiple pages. To make a large record, we just need
|
||||||
|
# to make a very big transaction.
|
||||||
|
self.generate(self.nodes[0], 101)
|
||||||
|
def_wallet = self.nodes[0].get_wallet_rpc(self.default_wallet_name)
|
||||||
|
outputs = {}
|
||||||
|
for i in range(500):
|
||||||
|
outputs[wallet.getnewaddress(address_type="p2sh-segwit")] = 0.01
|
||||||
|
def_wallet.sendmany(amounts=outputs)
|
||||||
|
self.generate(self.nodes[0], 1)
|
||||||
|
send_res = wallet.sendall([def_wallet.getnewaddress()])
|
||||||
|
self.generate(self.nodes[0], 1)
|
||||||
|
assert_equal(send_res["complete"], True)
|
||||||
|
tx = wallet.gettransaction(txid=send_res["txid"], verbose=True)
|
||||||
|
assert_greater_than(tx["decoded"]["size"], 70000)
|
||||||
|
|
||||||
|
self.stop_node(0)
|
||||||
|
|
||||||
|
wallet_dump = self.nodes[0].datadir_path / "bigrecords.dump"
|
||||||
|
self.assert_tool_output("The dumpfile may contain private keys. To ensure the safety of your Bitcoin, do not share the dumpfile.\n", "-wallet=bigrecords", f"-dumpfile={wallet_dump}", "dump")
|
||||||
|
dump = self.read_dump(wallet_dump)
|
||||||
|
for k,v in dump.items():
|
||||||
|
if tx["hex"] in v:
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
assert False, "Big transaction was not found in wallet dump"
|
||||||
|
|
||||||
def run_test(self):
|
def run_test(self):
|
||||||
self.wallet_path = self.nodes[0].wallets_path / self.default_wallet_name / self.wallet_data_filename
|
self.wallet_path = self.nodes[0].wallets_path / self.default_wallet_name / self.wallet_data_filename
|
||||||
self.test_invalid_tool_commands_and_args()
|
self.test_invalid_tool_commands_and_args()
|
||||||
|
@ -487,6 +524,7 @@ class ToolWalletTest(BitcoinTestFramework):
|
||||||
self.test_dump_endianness()
|
self.test_dump_endianness()
|
||||||
self.test_dump_createfromdump()
|
self.test_dump_createfromdump()
|
||||||
self.test_chainless_conflicts()
|
self.test_chainless_conflicts()
|
||||||
|
self.test_dump_very_large_records()
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
ToolWalletTest().main()
|
ToolWalletTest().main()
|
||||||
|
|
Loading…
Add table
Reference in a new issue