From 3c0c6c48b8db6fc420345204c32b9e865bce0ee5 Mon Sep 17 00:00:00 2001 From: SlowRiot Date: Fri, 20 Aug 2021 00:41:08 +0100 Subject: [PATCH 1/5] correct python3 comparison operator --- contrib/testgen/base58.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/testgen/base58.py b/contrib/testgen/base58.py index 08203b8e0b..11bacd7124 100644 --- a/contrib/testgen/base58.py +++ b/contrib/testgen/base58.py @@ -107,7 +107,7 @@ def get_bcaddress_version(strAddress): if __name__ == '__main__': # Test case (from http://gitorious.org/BGL/python-base58.git) - assert get_bcaddress_version('15VjRaDX9zpbA8LVnbrCAFzrVzN7ixHNsC') is 0 + assert get_bcaddress_version('15VjRaDX9zpbA8LVnbrCAFzrVzN7ixHNsC') == 0 _ohai = 'o hai'.encode('ascii') _tmp = b58encode(_ohai) assert _tmp == 'DYB3oMS' From e027dc78c657fad6d321ff18997b1eb7e1165507 Mon Sep 17 00:00:00 2001 From: SlowRiot Date: Fri, 20 Aug 2021 01:11:19 +0100 Subject: [PATCH 2/5] enable building tests by default, external signer default to match bitcoin core, and turn off warning silencing for implicit fallthrough --- configure.ac | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index 9fc705f2ab..86b7b56944 100755 --- a/configure.ac +++ b/configure.ac @@ -167,7 +167,7 @@ AC_ARG_ENABLE([natpmp-default], AC_ARG_ENABLE(tests, AS_HELP_STRING([--disable-tests],[do not compile tests (default is to compile)]), [use_tests=$enableval], - [use_tests=no]) + [use_tests=yes]) AC_ARG_ENABLE(gui-tests, AS_HELP_STRING([--disable-gui-tests],[do not compile GUI tests (default is to compile if GUI and tests enabled)]), @@ -343,7 +343,7 @@ AC_ARG_ENABLE([werror], AC_ARG_ENABLE([external-signer], [AS_HELP_STRING([--enable-external-signer],[compile external signer support (default is no, requires Boost::Process)])], [use_external_signer=$enableval], - [use_external_signer=no]) + [use_external_signer=yes]) AC_LANG_PUSH([C++]) @@ -480,7 +480,6 @@ if test "x$CXXFLAGS_overridden" = "xno"; then AX_CHECK_COMPILE_FLAG([-Wunused-parameter],[NOWARN_CXXFLAGS="$NOWARN_CXXFLAGS -Wno-unused-parameter"],,[[$CXXFLAG_WERROR]]) AX_CHECK_COMPILE_FLAG([-Wself-assign],[NOWARN_CXXFLAGS="$NOWARN_CXXFLAGS -Wno-self-assign"],,[[$CXXFLAG_WERROR]]) AX_CHECK_COMPILE_FLAG([-Wunused-local-typedef],[NOWARN_CXXFLAGS="$NOWARN_CXXFLAGS -Wno-unused-local-typedef"],,[[$CXXFLAG_WERROR]]) - AX_CHECK_COMPILE_FLAG([-Wimplicit-fallthrough],[NOWARN_CXXFLAGS="$NOWARN_CXXFLAGS -Wno-implicit-fallthrough"],,[[$CXXFLAG_WERROR]]) AX_CHECK_COMPILE_FLAG([-Wdeprecated-copy],[NOWARN_CXXFLAGS="$NOWARN_CXXFLAGS -Wno-deprecated-copy"],,[[$CXXFLAG_WERROR]]) fi From 0f6925278287bf0670901c3b18a170afc492cac4 Mon Sep 17 00:00:00 2001 From: SlowRiot Date: Fri, 20 Aug 2021 01:26:11 +0100 Subject: [PATCH 3/5] reinstate valid base58 test data and test methodology from bitcoin core --- src/test/base58_tests.cpp | 4 ++-- src/test/data/base58_encode_decode.json | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/test/base58_tests.cpp b/src/test/base58_tests.cpp index 13b1bad4e7..5a738902e3 100644 --- a/src/test/base58_tests.cpp +++ b/src/test/base58_tests.cpp @@ -18,7 +18,7 @@ using namespace std::literals; -extern UniValue read_json(const std::string& jsondata); +UniValue read_json(const std::string& jsondata); BOOST_FIXTURE_TEST_SUITE(base58_tests, BasicTestingSetup) @@ -88,7 +88,7 @@ BOOST_AUTO_TEST_CASE(base58_random_encode_decode) for (int n = 0; n < 1000; ++n) { unsigned int len = 1 + InsecureRandBits(8); unsigned int zeroes = InsecureRandBool() ? InsecureRandRange(len + 1) : 0; - auto data = Cat(std::vector(zeroes, '\010'), g_insecure_rand_ctx.randbytes(len - zeroes)); + auto data = Cat(std::vector(zeroes, '\000'), g_insecure_rand_ctx.randbytes(len - zeroes)); auto encoded = EncodeBase58Check(data); std::vector decoded; auto ok_too_small = DecodeBase58Check(encoded, decoded, InsecureRandRange(len)); diff --git a/src/test/data/base58_encode_decode.json b/src/test/data/base58_encode_decode.json index 4d91fd67dc..1a4bd7f458 100644 --- a/src/test/data/base58_encode_decode.json +++ b/src/test/data/base58_encode_decode.json @@ -4,13 +4,13 @@ ["626262", "a3gV"], ["636363", "aPEr"], ["73696d706c792061206c6f6e6720737472696e67", "2cFupjhnEsSn59qHXstmK2ffpLv2"], -["0aeb15231dfceb60925886b67d065299925915aeb172c06647", "1NS17iag9jJgTHD1VXjvLCEnZuQ3rJDE9L"], +["00eb15231dfceb60925886b67d065299925915aeb172c06647", "1NS17iag9jJgTHD1VXjvLCEnZuQ3rJDE9L"], ["516b6fcd0f", "ABnLTmg"], ["bf4f89001e670274dd", "3SEo3LWLoPntC"], ["572e4794", "3EFU7m"], ["ecac89cad93923c02321", "EJDM8drfXA6uyA"], ["10c8511e", "Rt5zm"], -["0a0a0a0a0a0a0a0a0a0a", "1111111111"], -["0a0111d38e5fc9071ffcd20b4a763cc9ae4f252bb4e48fd66a835e252ada93ff480d6dd43dc62a641155a5", "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"], -["0a0102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeafb0b1b2b3b4b5b6b7b8b9babbbcbdbebfc0c1c2c3c4c5c6c7c8c9cacbcccdcecfd0d1d2d3d4d5d6d7d8d9dadbdcdddedfe0e1e2e3e4e5e6e7e8e9eaebecedeeeff0f1f2f3f4f5f6f7f8f9fafbfcfdfeff", "1cWB5HCBdLjAuqGGReWE3R3CguuwSjw6RHn39s2yuDRTS5NsBgNiFpWgAnEx6VQi8csexkgYw3mdYrMHr8x9i7aEwP8kZ7vccXWqKDvGv3u1GxFKPuAkn8JCPPGDMf3vMMnbzm6Nh9zh1gcNsMvH3ZNLmP5fSG6DGbbi2tuwMWPthr4boWwCxf7ewSgNQeacyozhKDDQQ1qL5fQFUW52QKUZDZ5fw3KXNQJMcNTcaB723LchjeKun7MuGW5qyCBZYzA1KjofN1gYBV3NqyhQJ3Ns746GNuf9N2pQPmHz4xpnSrrfCvy6TVVz5d4PdrjeshsWQwpZsZGzvbdAdN8MKV5QsBDY"] +["00000000000000000000", "1111111111"], +["000111d38e5fc9071ffcd20b4a763cc9ae4f252bb4e48fd66a835e252ada93ff480d6dd43dc62a641155a5", "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"], +["000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeafb0b1b2b3b4b5b6b7b8b9babbbcbdbebfc0c1c2c3c4c5c6c7c8c9cacbcccdcecfd0d1d2d3d4d5d6d7d8d9dadbdcdddedfe0e1e2e3e4e5e6e7e8e9eaebecedeeeff0f1f2f3f4f5f6f7f8f9fafbfcfdfeff", "1cWB5HCBdLjAuqGGReWE3R3CguuwSjw6RHn39s2yuDRTS5NsBgNiFpWgAnEx6VQi8csexkgYw3mdYrMHr8x9i7aEwP8kZ7vccXWqKDvGv3u1GxFKPuAkn8JCPPGDMf3vMMnbzm6Nh9zh1gcNsMvH3ZNLmP5fSG6DGbbi2tuwMWPthr4boWwCxf7ewSgNQeacyozhKDDQQ1qL5fQFUW52QKUZDZ5fw3KXNQJMcNTcaB723LchjeKun7MuGW5qyCBZYzA1KjofN1gYBV3NqyhQJ3Ns746GNuf9N2pQPmHz4xpnSrrfCvy6TVVz5d4PdrjeshsWQwpZsZGzvbdAdN8MKV5QsBDY"] ] From 60bc8a1b8c518a030d2ae70d1ed6b774584d55d9 Mon Sep 17 00:00:00 2001 From: SlowRiot Date: Fri, 20 Aug 2021 01:26:16 +0100 Subject: [PATCH 4/5] fix base58 implementation --- src/base58.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/base58.cpp b/src/base58.cpp index cadbef6fdf..2a7fbe5e2c 100644 --- a/src/base58.cpp +++ b/src/base58.cpp @@ -80,7 +80,7 @@ static const int8_t mapBase58[256] = { std::vector::iterator it = b256.begin() + (size - length); // Copy result into output vector. vch.reserve(zeroes + (b256.end() - it)); - vch.assign(zeroes, 0x0a); + vch.assign(zeroes, 0x00); while (it != b256.end()) vch.push_back(*(it++)); return true; @@ -91,7 +91,7 @@ std::string EncodeBase58(Span input) // Skip & count leading zeroes. int zeroes = 0; int length = 0; - while (input.size() > 0 && input[0] == 10) { + while (input.size() > 0 && input[0] == 0) { input = input.subspan(1); zeroes++; } From 9781fd3588fefb0c355ac141cd7e30aa1c61331f Mon Sep 17 00:00:00 2001 From: SlowRiot Date: Tue, 24 Aug 2021 18:12:20 +0100 Subject: [PATCH 5/5] don't disable implicit-fallthrough warning (this is now dealt with in another PR) --- configure.ac | 1 + 1 file changed, 1 insertion(+) diff --git a/configure.ac b/configure.ac index 86b7b56944..d8de32985f 100755 --- a/configure.ac +++ b/configure.ac @@ -480,6 +480,7 @@ if test "x$CXXFLAGS_overridden" = "xno"; then AX_CHECK_COMPILE_FLAG([-Wunused-parameter],[NOWARN_CXXFLAGS="$NOWARN_CXXFLAGS -Wno-unused-parameter"],,[[$CXXFLAG_WERROR]]) AX_CHECK_COMPILE_FLAG([-Wself-assign],[NOWARN_CXXFLAGS="$NOWARN_CXXFLAGS -Wno-self-assign"],,[[$CXXFLAG_WERROR]]) AX_CHECK_COMPILE_FLAG([-Wunused-local-typedef],[NOWARN_CXXFLAGS="$NOWARN_CXXFLAGS -Wno-unused-local-typedef"],,[[$CXXFLAG_WERROR]]) + AX_CHECK_COMPILE_FLAG([-Wimplicit-fallthrough],[NOWARN_CXXFLAGS="$NOWARN_CXXFLAGS -Wno-implicit-fallthrough"],,[[$CXXFLAG_WERROR]]) AX_CHECK_COMPILE_FLAG([-Wdeprecated-copy],[NOWARN_CXXFLAGS="$NOWARN_CXXFLAGS -Wno-deprecated-copy"],,[[$CXXFLAG_WERROR]]) fi