diff options
author | Sebastian Falbesoner <sebastian.falbesoner@gmail.com> | 2024-08-14 16:43:46 +0200 |
---|---|---|
committer | Sebastian Falbesoner <sebastian.falbesoner@gmail.com> | 2024-08-14 16:43:46 +0200 |
commit | 6b3676be3e5b6e407876031791172f441b359295 (patch) | |
tree | 0ecf270eb792de110d451764ccd3d94fea815d57 /test/functional/test_framework/util.py | |
parent | 1a41e63575986887ae34993b4433ec711ae0ffbc (diff) |
test: refactor: move `read_xor_key`/`util_xor` helpers to util module
Diffstat (limited to 'test/functional/test_framework/util.py')
-rw-r--r-- | test/functional/test_framework/util.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/test/functional/test_framework/util.py b/test/functional/test_framework/util.py index de756691e0..c3bc861cf6 100644 --- a/test/functional/test_framework/util.py +++ b/test/functional/test_framework/util.py @@ -311,6 +311,13 @@ def sha256sum_file(filename): return h.digest() +def util_xor(data, key, *, offset): + data = bytearray(data) + for i in range(len(data)): + data[i] ^= key[(i + offset) % len(key)] + return bytes(data) + + # RPC/P2P connection constants and functions ############################################ @@ -508,6 +515,12 @@ 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_path / "xor.dat", "rb") as xor_f: + NUM_XOR_BYTES = 8 # From InitBlocksdirXorKey::xor_key.size() + return xor_f.read(NUM_XOR_BYTES) + + # Transaction/Block functions ############################# |