mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-12 15:09:59 +01:00
This commit effectively moves the definition of these constants out of the chainparamsbase to their own file. Using the ChainType enums provides better type safety compared to passing around strings. The commit is part of an ongoing effort to decouple the libbitcoinkernel library from the ArgsManager and other functionality that should not be part of the kernel library.
40 lines
1.1 KiB
C++
40 lines
1.1 KiB
C++
// Copyright (c) 2020-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.
|
|
|
|
#include <chainparams.h>
|
|
#include <key_io.h>
|
|
#include <test/fuzz/fuzz.h>
|
|
#include <util/chaintype.h>
|
|
|
|
#include <cassert>
|
|
#include <cstdint>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
void initialize_key_io()
|
|
{
|
|
ECC_Start();
|
|
SelectParams(ChainType::MAIN);
|
|
}
|
|
|
|
FUZZ_TARGET_INIT(key_io, initialize_key_io)
|
|
{
|
|
const std::string random_string(buffer.begin(), buffer.end());
|
|
|
|
const CKey key = DecodeSecret(random_string);
|
|
if (key.IsValid()) {
|
|
assert(key == DecodeSecret(EncodeSecret(key)));
|
|
}
|
|
|
|
const CExtKey ext_key = DecodeExtKey(random_string);
|
|
if (ext_key.key.size() == 32) {
|
|
assert(ext_key == DecodeExtKey(EncodeExtKey(ext_key)));
|
|
}
|
|
|
|
const CExtPubKey ext_pub_key = DecodeExtPubKey(random_string);
|
|
if (ext_pub_key.pubkey.size() == CPubKey::COMPRESSED_SIZE) {
|
|
assert(ext_pub_key == DecodeExtPubKey(EncodeExtPubKey(ext_pub_key)));
|
|
}
|
|
}
|