From 74ff8467d107b609d699729399b83a1219add78a Mon Sep 17 00:00:00 2001 From: Ava Chow Date: Tue, 5 Nov 2024 12:53:41 -0500 Subject: [PATCH] tests: Handle BDB dynamic pagesize BDB may choose to use a pagesize other than 4096. As such, the parser should use the pagesize given by the BDB file. --- test/functional/test_framework/bdb.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/test/functional/test_framework/bdb.py b/test/functional/test_framework/bdb.py index 41886c09fd402..8a1a7c149bc58 100644 --- a/test/functional/test_framework/bdb.py +++ b/test/functional/test_framework/bdb.py @@ -6,7 +6,6 @@ Utilities for working directly with the wallet's BDB database file This is specific to the configuration of BDB used in this project: - - pagesize: 4096 bytes - Outer database contains single subdatabase named 'main' - btree - btree leaf pages @@ -27,7 +26,7 @@ import struct # Important constants -PAGESIZE = 4096 +MIN_PAGESIZE = 512 OUTER_META_PAGE = 0 INNER_META_PAGE = 2 @@ -132,10 +131,14 @@ def dump_bdb_kv(filename): # Read in the BDB file and start deserializing it pages = [] with open(filename, 'rb') as f: - data = f.read(PAGESIZE) + # Read the outer meta page for the page size. It will always be at least 512 bytes. + metadata = dump_meta_page(f.read(MIN_PAGESIZE)) + f.seek(0) + + data = f.read(metadata["pagesize"]) while len(data) > 0: pages.append(data) - data = f.read(PAGESIZE) + data = f.read(metadata["pagesize"]) # Sanity check the meta pages dump_meta_page(pages[OUTER_META_PAGE])