Skip to content

Commit d839958

Browse files
committed
refactor: move read_xor_key() to TestNode
1 parent d43948c commit d839958

File tree

4 files changed

+7
-10
lines changed

4 files changed

+7
-10
lines changed

Diff for: test/functional/feature_blocksxor.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
from test_framework.util import (
1010
assert_equal,
1111
assert_greater_than,
12-
read_xor_key,
1312
util_xor,
1413
)
1514
from test_framework.wallet import MiniWallet
@@ -39,7 +38,7 @@ def run_test(self):
3938

4039
self.log.info("Shut down node and un-XOR block/undo files manually")
4140
self.stop_node(0)
42-
xor_key = read_xor_key(node=node)
41+
xor_key = node.read_xor_key()
4342
for data_file in sorted(block_files + undo_files):
4443
self.log.debug(f"Rewriting file {data_file}...")
4544
with open(data_file, 'rb+') as f:

Diff for: test/functional/feature_reindex.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
from test_framework.messages import MAGIC_BYTES
1515
from test_framework.util import (
1616
assert_equal,
17-
read_xor_key,
1817
util_xor,
1918
)
2019

@@ -43,7 +42,7 @@ def out_of_order(self):
4342
# we're generating them rather than getting them from peers), so to
4443
# test out-of-order handling, swap blocks 1 and 2 on disk.
4544
blk0 = self.nodes[0].blocks_path / "blk00000.dat"
46-
xor_dat = read_xor_key(node=self.nodes[0])
45+
xor_dat = self.nodes[0].read_xor_key()
4746

4847
with open(blk0, 'r+b') as bf:
4948
# Read at least the first few blocks (including genesis)

Diff for: test/functional/test_framework/test_node.py

+5
Original file line numberDiff line numberDiff line change
@@ -469,6 +469,11 @@ def blocks_path(self) -> Path:
469469
def blocks_key_path(self) -> Path:
470470
return self.blocks_path / "xor.dat"
471471

472+
def read_xor_key(self) -> bytes:
473+
with open(self.blocks_key_path, "rb") as xor_f:
474+
NUM_XOR_BYTES = 8 # From InitBlocksdirXorKey::xor_key.size()
475+
return xor_f.read(NUM_XOR_BYTES)
476+
472477
@property
473478
def wallets_path(self) -> Path:
474479
return self.chain_path / "wallets"

Diff for: test/functional/test_framework/util.py

-6
Original file line numberDiff line numberDiff line change
@@ -515,12 +515,6 @@ def check_node_connections(*, node, num_in, num_out):
515515
assert_equal(info["connections_out"], num_out)
516516

517517

518-
def read_xor_key(*, node):
519-
with open(node.blocks_key_path, "rb") as xor_f:
520-
NUM_XOR_BYTES = 8 # From InitBlocksdirXorKey::xor_key.size()
521-
return xor_f.read(NUM_XOR_BYTES)
522-
523-
524518
# Transaction/Block functions
525519
#############################
526520

0 commit comments

Comments
 (0)