aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortdb3 <106488469+tdb3@users.noreply.github.com>2024-08-20 20:03:25 -0400
committertdb3 <106488469+tdb3@users.noreply.github.com>2024-08-25 08:42:38 -0400
commitd8399584dd59b3954a0bea393b2de350a732055e (patch)
tree2e629ecdbaa0817fd098c1d77bf712edfc5a71c3
parentd43948c3ef610c383176bf9b389697973bd0ad64 (diff)
refactor: move read_xor_key() to TestNode
-rwxr-xr-xtest/functional/feature_blocksxor.py3
-rwxr-xr-xtest/functional/feature_reindex.py3
-rwxr-xr-xtest/functional/test_framework/test_node.py5
-rw-r--r--test/functional/test_framework/util.py6
4 files changed, 7 insertions, 10 deletions
diff --git a/test/functional/feature_blocksxor.py b/test/functional/feature_blocksxor.py
index 16597e6d01..8ea16db7bb 100755
--- a/test/functional/feature_blocksxor.py
+++ b/test/functional/feature_blocksxor.py
@@ -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:
diff --git a/test/functional/feature_reindex.py b/test/functional/feature_reindex.py
index 2961a2d356..1ebfe82da5 100755
--- a/test/functional/feature_reindex.py
+++ b/test/functional/feature_reindex.py
@@ -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)
diff --git a/test/functional/test_framework/test_node.py b/test/functional/test_framework/test_node.py
index 9e037345f3..ce34ef6f5f 100755
--- a/test/functional/test_framework/test_node.py
+++ b/test/functional/test_framework/test_node.py
@@ -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"
diff --git a/test/functional/test_framework/util.py b/test/functional/test_framework/util.py
index 2372683c04..00fe5b08e4 100644
--- a/test/functional/test_framework/util.py
+++ b/test/functional/test_framework/util.py
@@ -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
#############################