aboutsummaryrefslogtreecommitdiff
path: root/test/lint
diff options
context:
space:
mode:
authorAdam Jonas <jonas@chaincode.com>2019-10-29 16:26:01 -0400
committerAdam Jonas <jonas@chaincode.com>2019-10-30 12:03:07 -0400
commitc98bd13e675fbf5641ed64d551b63aaf55a1a8e9 (patch)
treede1e060178eb8efa14291ca328c26b82323b5976 /test/lint
parentedd9d0781b96e71f88bd87b30dd10ad008b964a5 (diff)
replace asserts in RPC code with CHECK_NONFATAL and add linter
Diffstat (limited to 'test/lint')
-rwxr-xr-xtest/lint/lint-assertions.sh11
1 files changed, 11 insertions, 0 deletions
diff --git a/test/lint/lint-assertions.sh b/test/lint/lint-assertions.sh
index 5bbcae79eb..a4c6f0a8d4 100755
--- a/test/lint/lint-assertions.sh
+++ b/test/lint/lint-assertions.sh
@@ -20,4 +20,15 @@ if [[ ${OUTPUT} != "" ]]; then
EXIT_CODE=1
fi
+# Macro CHECK_NONFATAL(condition) should be used instead of assert for RPC code, where it
+# is undesirable to crash the whole program. See: src/util/check.h
+# src/rpc/server.cpp is excluded from this check since it's mostly meta-code.
+OUTPUT=$(git grep -nE 'assert *\(.*\);' -- "src/rpc/" "src/wallet/rpc*" ":(exclude)src/rpc/server.cpp")
+if [[ ${OUTPUT} != "" ]]; then
+ echo "CHECK_NONFATAL(condition) should be used instead of assert for RPC code."
+ echo
+ echo "${OUTPUT}"
+ EXIT_CODE=1
+fi
+
exit ${EXIT_CODE}