Skip to content

Commit

Permalink
refactor: cleanups post unsubtree'ing univalue
Browse files Browse the repository at this point in the history
Mostly changes to remove src/univalue exceptions from the various linters,
and the required code changes to make them happy. As well as minor doc
changes.
  • Loading branch information
fanquake committed Jun 15, 2022
1 parent e2aa704 commit d873ff9
Show file tree
Hide file tree
Showing 22 changed files with 32 additions and 56 deletions.
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@ src/obj
share/setup.nsi
share/qt/Info.plist

src/univalue/gen

src/qt/*.moc
src/qt/moc_*.cpp
src/qt/forms/ui_*.h
Expand Down
1 change: 0 additions & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,6 @@ LCOV_FILTER_PATTERN = \
-p "src/leveldb/" \
-p "src/crc32c/" \
-p "src/bench/" \
-p "src/univalue" \
-p "src/crypto/ctaes" \
-p "src/minisketch" \
-p "src/secp256k1" \
Expand Down
1 change: 0 additions & 1 deletion ci/lint/06_script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ export COMMIT_RANGE
test/lint/git-subtree-check.sh src/crypto/ctaes
test/lint/git-subtree-check.sh src/secp256k1
test/lint/git-subtree-check.sh src/minisketch
test/lint/git-subtree-check.sh src/univalue
test/lint/git-subtree-check.sh src/leveldb
test/lint/git-subtree-check.sh src/crc32c
test/lint/check-doc.py
Expand Down
1 change: 0 additions & 1 deletion contrib/devtools/copyright_header.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
"src/leveldb/",
"src/minisketch",
"src/secp256k1/",
"src/univalue/",
"src/crc32c/",
]

Expand Down
4 changes: 0 additions & 4 deletions doc/developer-notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -1158,10 +1158,6 @@ Current subtrees include:
- src/crypto/ctaes
- Upstream at https://github.com/bitcoin-core/ctaes ; maintained by Core contributors.

- src/univalue
- Subtree at https://github.com/bitcoin-core/univalue-subtree ; maintained by Core contributors.
- Deviates from upstream https://github.com/jgarzik/univalue.

- src/minisketch
- Upstream at https://github.com/sipa/minisketch ; maintained by Core contributors.

Expand Down
6 changes: 3 additions & 3 deletions src/univalue/include/univalue.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or https://opensource.org/licenses/mit-license.php.

#ifndef __UNIVALUE_H__
#define __UNIVALUE_H__
#ifndef BITCOIN_UNIVALUE_INCLUDE_UNIVALUE_H
#define BITCOIN_UNIVALUE_INCLUDE_UNIVALUE_H

#include <charconv>
#include <cstdint>
Expand Down Expand Up @@ -194,4 +194,4 @@ extern const UniValue NullUniValue;

const UniValue& find_value( const UniValue& obj, const std::string& name);

#endif // __UNIVALUE_H__
#endif // BITCOIN_UNIVALUE_INCLUDE_UNIVALUE_H
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Automatically generated file. Do not modify.
#ifndef BITCOIN_UNIVALUE_UNIVALUE_ESCAPES_H
#define BITCOIN_UNIVALUE_UNIVALUE_ESCAPES_H
#ifndef BITCOIN_UNIVALUE_INCLUDE_UNIVALUE_ESCAPES_H
#define BITCOIN_UNIVALUE_INCLUDE_UNIVALUE_ESCAPES_H
static const char *escapes[256] = {
"\\u0000",
"\\u0001",
Expand Down Expand Up @@ -259,4 +258,4 @@ static const char *escapes[256] = {
nullptr,
nullptr,
};
#endif // BITCOIN_UNIVALUE_UNIVALUE_ESCAPES_H
#endif // BITCOIN_UNIVALUE_INCLUDE_UNIVALUE_ESCAPES_H
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// Copyright 2016 Wladimir J. van der Laan
// Distributed under the MIT software license, see the accompanying
// file COPYING or https://opensource.org/licenses/mit-license.php.
#ifndef UNIVALUE_UTFFILTER_H
#define UNIVALUE_UTFFILTER_H
#ifndef BITCOIN_UNIVALUE_INCLUDE_UNIVALUE_UTFFILTER_H
#define BITCOIN_UNIVALUE_INCLUDE_UNIVALUE_UTFFILTER_H

#include <string>

Expand Down Expand Up @@ -116,4 +116,4 @@ class JSONUTF8StringFilter
}
};

#endif
#endif // BITCOIN_UNIVALUE_INCLUDE_UNIVALUE_UTFFILTER_H
2 changes: 1 addition & 1 deletion src/univalue/lib/univalue_read.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// file COPYING or https://opensource.org/licenses/mit-license.php.

#include <univalue.h>
#include "univalue_utffilter.h"
#include <univalue_utffilter.h>

#include <cstdio>
#include <cstdint>
Expand Down
2 changes: 1 addition & 1 deletion src/univalue/lib/univalue_write.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// file COPYING or https://opensource.org/licenses/mit-license.php.

#include <univalue.h>
#include "univalue_escapes.h"
#include <univalue_escapes.h>

#include <memory>
#include <string>
Expand Down
6 changes: 2 additions & 4 deletions src/univalue/sources.mk
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,8 @@ UNIVALUE_INCLUDE_DIR_INT = %reldir%/include

UNIVALUE_DIST_HEADERS_INT =
UNIVALUE_DIST_HEADERS_INT += %reldir%/include/univalue.h

UNIVALUE_LIB_HEADERS_INT =
UNIVALUE_LIB_HEADERS_INT += %reldir%/lib/univalue_utffilter.h
UNIVALUE_LIB_HEADERS_INT += %reldir%/lib/univalue_escapes.h
UNIVALUE_DIST_HEADERS_INT += %reldir%/include/univalue_utffilter.h
UNIVALUE_DIST_HEADERS_INT += %reldir%/include/univalue_escapes.h

UNIVALUE_LIB_SOURCES_INT =
UNIVALUE_LIB_SOURCES_INT += %reldir%/lib/univalue.cpp
Expand Down
34 changes: 13 additions & 21 deletions src/univalue/test/unitester.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,7 @@
#error JSON_TEST_SRC must point to test source directory
#endif

#ifndef ARRAY_SIZE
#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
#endif

std::string srcdir(JSON_TEST_SRC);
static bool test_failed = false;

#define d_assert(expr) { if (!(expr)) { test_failed = true; fprintf(stderr, "%s failed\n", filename.c_str()); } }
#define f_assert(expr) { if (!(expr)) { test_failed = true; fprintf(stderr, "%s failed\n", __func__); } }

static std::string rtrim(std::string s)
{
Expand All @@ -41,9 +33,9 @@ static void runtest(std::string filename, const std::string& jdata)
bool testResult = val.read(jdata);

if (wantPass) {
d_assert(testResult == true);
assert(testResult == true);
} else {
d_assert(testResult == false);
assert(testResult == false);
}

if (wantRoundTrip) {
Expand Down Expand Up @@ -141,30 +133,30 @@ void unescape_unicode_test()
bool testResult;
// Escaped ASCII (quote)
testResult = val.read("[\"\\u0022\"]");
f_assert(testResult);
f_assert(val[0].get_str() == "\"");
assert(testResult);
assert(val[0].get_str() == "\"");
// Escaped Basic Plane character, two-byte UTF-8
testResult = val.read("[\"\\u0191\"]");
f_assert(testResult);
f_assert(val[0].get_str() == "\xc6\x91");
assert(testResult);
assert(val[0].get_str() == "\xc6\x91");
// Escaped Basic Plane character, three-byte UTF-8
testResult = val.read("[\"\\u2191\"]");
f_assert(testResult);
f_assert(val[0].get_str() == "\xe2\x86\x91");
assert(testResult);
assert(val[0].get_str() == "\xe2\x86\x91");
// Escaped Supplementary Plane character U+1d161
testResult = val.read("[\"\\ud834\\udd61\"]");
f_assert(testResult);
f_assert(val[0].get_str() == "\xf0\x9d\x85\xa1");
assert(testResult);
assert(val[0].get_str() == "\xf0\x9d\x85\xa1");
}

int main (int argc, char *argv[])
{
for (unsigned int fidx = 0; fidx < ARRAY_SIZE(filenames); fidx++) {
runtest_file(filenames[fidx]);
for (const auto& f: filenames) {
runtest_file(f);
}

unescape_unicode_test();

return test_failed ? 1 : 0;
return 0;
}

1 change: 0 additions & 1 deletion test/lint/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ To do a full check with `-r`, make sure that you have fetched the upstream repos
maintained:
* for `src/secp256k1`: https://github.com/bitcoin-core/secp256k1.git (branch master)
* for `src/leveldb`: https://github.com/bitcoin-core/leveldb-subtree.git (branch bitcoin-fork)
* for `src/univalue`: https://github.com/bitcoin-core/univalue-subtree.git (branch master)
* for `src/crypto/ctaes`: https://github.com/bitcoin-core/ctaes.git (branch master)
* for `src/crc32c`: https://github.com/bitcoin-core/crc32c-subtree.git (branch bitcoin-fork)
* for `src/minisketch`: https://github.com/sipa/minisketch.git (branch master)
Expand Down
2 changes: 1 addition & 1 deletion test/lint/lint-files.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
ALLOWED_FILENAME_REGEXP = "^[a-zA-Z0-9/_.@][a-zA-Z0-9/_.@-]*$"
ALLOWED_SOURCE_FILENAME_REGEXP = "^[a-z0-9_./-]+$"
ALLOWED_SOURCE_FILENAME_EXCEPTION_REGEXP = (
"^src/(secp256k1/|minisketch/|univalue/|test/fuzz/FuzzedDataProvider.h)"
"^src/(secp256k1/|minisketch/|test/fuzz/FuzzedDataProvider.h)"
)
ALLOWED_PERMISSION_NON_EXECUTABLES = 0o644
ALLOWED_PERMISSION_EXECUTABLES = 0o755
Expand Down
2 changes: 1 addition & 1 deletion test/lint/lint-format-strings.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def main():

matching_files_filtered = []
for matching_file in matching_files:
if not re.search('^src/(leveldb|secp256k1|minisketch|tinyformat|univalue|test/fuzz/strprintf.cpp)', matching_file):
if not re.search('^src/(leveldb|secp256k1|minisketch|tinyformat|test/fuzz/strprintf.cpp)', matching_file):
matching_files_filtered.append(matching_file)
matching_files_filtered.sort()

Expand Down
1 change: 0 additions & 1 deletion test/lint/lint-include-guards.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
'src/crc32c',
'src/secp256k1',
'src/minisketch',
'src/univalue',
'src/tinyformat.h',
'src/bench/nanobench.h',
'src/test/fuzz/FuzzedDataProvider.h']
Expand Down
2 changes: 1 addition & 1 deletion test/lint/lint-includes.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"src/crc32c/",
"src/secp256k1/",
"src/minisketch/",
"src/univalue/"]
]

EXPECTED_BOOST_INCLUDES = ["boost/algorithm/string/replace.hpp",
"boost/date_time/posix_time/posix_time.hpp",
Expand Down
1 change: 0 additions & 1 deletion test/lint/lint-locale-dependence.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@
"src/secp256k1/",
"src/minisketch/",
"src/tinyformat.h",
"src/univalue/"
]

LOCALE_DEPENDENT_FUNCTIONS = [
Expand Down
2 changes: 1 addition & 1 deletion test/lint/lint-shell-locale.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def main():
exit_code = 0
shell_files = get_shell_files_list()
for file_path in shell_files:
if re.search('src/(secp256k1|minisketch|univalue)/', file_path):
if re.search('src/(secp256k1|minisketch)/', file_path):
continue

with open(file_path, 'r', encoding='utf-8') as file_obj:
Expand Down
2 changes: 1 addition & 1 deletion test/lint/lint-shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def main():
]
files = get_files(files_cmd)
# remove everything that doesn't match this regex
reg = re.compile(r'src/[leveldb,secp256k1,minisketch,univalue]')
reg = re.compile(r'src/[leveldb,secp256k1,minisketch]')
files[:] = [file for file in files if not reg.match(file)]

# build the `shellcheck` command
Expand Down
2 changes: 1 addition & 1 deletion test/lint/lint-spelling.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from subprocess import check_output, STDOUT, CalledProcessError

IGNORE_WORDS_FILE = 'test/lint/spelling.ignore-words.txt'
FILES_ARGS = ['git', 'ls-files', '--', ":(exclude)build-aux/m4/", ":(exclude)contrib/seeds/*.txt", ":(exclude)depends/", ":(exclude)doc/release-notes/", ":(exclude)src/leveldb/", ":(exclude)src/crc32c/", ":(exclude)src/qt/locale/", ":(exclude)src/qt/*.qrc", ":(exclude)src/secp256k1/", ":(exclude)src/minisketch/", ":(exclude)src/univalue/", ":(exclude)contrib/builder-keys/keys.txt", ":(exclude)contrib/guix/patches"]
FILES_ARGS = ['git', 'ls-files', '--', ":(exclude)build-aux/m4/", ":(exclude)contrib/seeds/*.txt", ":(exclude)depends/", ":(exclude)doc/release-notes/", ":(exclude)src/leveldb/", ":(exclude)src/crc32c/", ":(exclude)src/qt/locale/", ":(exclude)src/qt/*.qrc", ":(exclude)src/secp256k1/", ":(exclude)src/minisketch/", ":(exclude)contrib/builder-keys/keys.txt", ":(exclude)contrib/guix/patches"]


def check_codespell_install():
Expand Down
1 change: 0 additions & 1 deletion test/lint/lint-whitespace.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
"src/crc32c/",
"src/secp256k1/",
"src/minisketch/",
"src/univalue/",
"doc/release-notes/",
"src/qt/locale"]

Expand Down

0 comments on commit d873ff9

Please sign in to comment.