#!/usr/bin/env python3 # Copyright (c) 2021 The Bitcoin Core developers # Distributed under the MIT software license, see the accompanying # file COPYING or http://www.opensource.org/licenses/mit-license.php. """Test addrman functionality""" import os import re import struct from test_framework.messages import ser_uint256, hash256, MAGIC_BYTES from test_framework.test_framework import BitcoinTestFramework from test_framework.test_node import ErrorMatch from test_framework.util import assert_equal def serialize_addrman( *, format=1, lowest_compatible=4, net_magic="regtest", bucket_key=1, len_new=None, len_tried=None, mock_checksum=None, ): new = [] tried = [] INCOMPATIBILITY_BASE = 32 r = MAGIC_BYTES[net_magic] r += struct.pack("B", format) r += struct.pack("B", INCOMPATIBILITY_BASE + lowest_compatible) r += ser_uint256(bucket_key) r += struct.pack("