refactor: move read_xor_key() to TestNode

pull/30669/head
tdb3 3 months ago
parent d43948c3ef
commit d8399584dd
No known key found for this signature in database

@ -9,7 +9,6 @@ from test_framework.test_node import ErrorMatch
from test_framework.util import (
assert_equal,
assert_greater_than,
read_xor_key,
util_xor,
)
from test_framework.wallet import MiniWallet
@ -39,7 +38,7 @@ class BlocksXORTest(BitcoinTestFramework):
self.log.info("Shut down node and un-XOR block/undo files manually")
self.stop_node(0)
xor_key = read_xor_key(node=node)
xor_key = node.read_xor_key()
for data_file in sorted(block_files + undo_files):
self.log.debug(f"Rewriting file {data_file}...")
with open(data_file, 'rb+') as f:

@ -14,7 +14,6 @@ from test_framework.test_framework import BitcoinTestFramework
from test_framework.messages import MAGIC_BYTES
from test_framework.util import (
assert_equal,
read_xor_key,
util_xor,
)
@ -43,7 +42,7 @@ class ReindexTest(BitcoinTestFramework):
# we're generating them rather than getting them from peers), so to
# test out-of-order handling, swap blocks 1 and 2 on disk.
blk0 = self.nodes[0].blocks_path / "blk00000.dat"
xor_dat = read_xor_key(node=self.nodes[0])
xor_dat = self.nodes[0].read_xor_key()
with open(blk0, 'r+b') as bf:
# Read at least the first few blocks (including genesis)

@ -469,6 +469,11 @@ class TestNode():
def blocks_key_path(self) -> Path:
return self.blocks_path / "xor.dat"
def read_xor_key(self) -> bytes:
with open(self.blocks_key_path, "rb") as xor_f:
NUM_XOR_BYTES = 8 # From InitBlocksdirXorKey::xor_key.size()
return xor_f.read(NUM_XOR_BYTES)
@property
def wallets_path(self) -> Path:
return self.chain_path / "wallets"

@ -515,12 +515,6 @@ def check_node_connections(*, node, num_in, num_out):
assert_equal(info["connections_out"], num_out)
def read_xor_key(*, node):
with open(node.blocks_key_path, "rb") as xor_f:
NUM_XOR_BYTES = 8 # From InitBlocksdirXorKey::xor_key.size()
return xor_f.read(NUM_XOR_BYTES)
# Transaction/Block functions
#############################

Loading…
Cancel
Save