def test_dataclasses_json_dict() -> None: for net in NETWORKS.values(): net2 = Network.from_json(net.to_json()) assert net2 == net net2 = Network.from_dict(net.to_dict()) assert net2 == net datadir = path.join(path.dirname(__file__), "generated_files") filename = path.join(datadir, "mainnet.json") with open(filename, "w") as file_: json.dump(NETWORKS["mainnet"].to_dict(), file_, indent=4)
def test_dataclasses_json_dict() -> None: for network_name, net in NETWORKS.items(): assert net == Network.from_dict(net.to_dict()) datadir = path.join(path.dirname(__file__), "_generated_files") filename = path.join(datadir, network_name + ".json") with open(filename, "w", encoding="ascii") as file_: json.dump(net.to_dict(), file_, indent=4)
def test_bad_network() -> None: with pytest.raises(BTClibValueError, match="invalid genesis_block length: "): Network( curve=CURVES["secp256k1"], magic_bytes="d9b4bef9", genesis_block="000000000019d6689c08", # too short wif=b"\x80", p2pkh=b"\x00", p2sh=b"\x05", hrp="bc", bip32_prv="0488ade4", bip32_pub="0488b21e", slip132_p2wpkh_prv="04b2430c", slip132_p2wpkh_pub="04b24746", slip132_p2wpkh_p2sh_prv="049d7878", slip132_p2wpkh_p2sh_pub="049d7cb2", slip132_p2wsh_prv="02aa7a99", slip132_p2wsh_pub="02aa7ed3", slip132_p2wsh_p2sh_prv="0295b005", slip132_p2wsh_p2sh_pub="0295b43f", )