14#include <boost/test/unit_test.hpp>
17using namespace std::literals;
27 for (
unsigned int idx = 0; idx < tests.
size(); idx++) {
29 std::string strTest = test.
write();
32 BOOST_ERROR(
"Bad test: " << strTest);
35 std::vector<unsigned char> sourcedata =
ParseHex(test[0].get_str());
36 std::string base58string = test[1].
get_str();
47 std::vector<unsigned char> result;
49 for (
unsigned int idx = 0; idx < tests.
size(); idx++) {
51 std::string strTest = test.
write();
54 BOOST_ERROR(
"Bad test: " << strTest);
57 std::vector<unsigned char> expected =
ParseHex(test[0].get_str());
58 std::string base58string = test[1].
get_str();
59 BOOST_CHECK_MESSAGE(
DecodeBase58(base58string, result, 256), strTest);
60 BOOST_CHECK_MESSAGE(result.size() == expected.size() && std::equal(result.begin(), result.end(), expected.begin()), strTest);
75 std::vector<unsigned char> expected =
ParseHex(
"971a55");
76 BOOST_CHECK_EQUAL_COLLECTIONS(result.begin(), result.end(), expected.begin(), expected.end());
86 for (
int n = 0; n < 1000; ++n) {
91 std::vector<unsigned char> decoded;
std::string EncodeBase58(Span< const unsigned char > input)
Why base-58 instead of standard base-64 encoding?
std::string EncodeBase58Check(Span< const unsigned char > input)
Encode a byte span into a base58-encoded string, including checksum.
static bool DecodeBase58Check(const char *psz, std::vector< unsigned char > &vchRet, int max_ret_len)
static bool DecodeBase58(const char *psz, std::vector< unsigned char > &vch, int max_ret_len)
UniValue read_json(const std::string &jsondata)
BOOST_AUTO_TEST_CASE(base58_EncodeBase58)
std::vector< unsigned char > randbytes(size_t len)
Generate random bytes.
const std::string & get_str() const
std::string write(unsigned int prettyIndent=0, unsigned int indentLevel=0) const
BOOST_AUTO_TEST_SUITE_END()
static unsigned const char base58_encode_decode[]
#define BOOST_FIXTURE_TEST_SUITE(a, b)
#define BOOST_CHECK(expr)
FastRandomContext g_insecure_rand_ctx
This global and the helpers that use it are not thread-safe.
static uint64_t InsecureRandRange(uint64_t range)
static uint64_t InsecureRandBits(int bits)
static bool InsecureRandBool()
std::vector< unsigned char > ParseHex(const char *psz)
V Cat(V v1, V &&v2)
Concatenate two vectors, moving elements.