aboutsummaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorJon Atack <jon@atack.com>2021-03-22 19:19:05 +0100
committerJon Atack <jon@atack.com>2021-05-12 10:50:58 +0200
commit91f6e6e6d1720e1154ad3f70a5098e9028efa84a (patch)
tree62f694aab492d4de41d09ba3b8036978c6de8b01 /src/test
parent2e30e328a7a46e0405664fd0cb31d971171f71d1 (diff)
scripted-diff: add NetPermissionFlags scopes where not already present
-BEGIN VERIFY SCRIPT- s() { git grep -l "$1" -- 'src' ':!src/net_permissions.h' | xargs sed -i -E "s/([^:])$1/\1NetPermissionFlags::$1/"; } s 'PF_NONE' s 'PF_BLOOMFILTER' s 'PF_RELAY' s 'PF_FORCERELAY' s 'PF_DOWNLOAD' s 'PF_NOBAN' s 'PF_MEMPOOL' s 'PF_ADDR' s 'PF_ISIMPLICIT' s 'PF_ALL' -END VERIFY SCRIPT- Co-authored-by: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com>
Diffstat (limited to 'src/test')
-rw-r--r--src/test/netbase_tests.cpp38
1 files changed, 19 insertions, 19 deletions
diff --git a/src/test/netbase_tests.cpp b/src/test/netbase_tests.cpp
index b316a37c6e..ea896d8318 100644
--- a/src/test/netbase_tests.cpp
+++ b/src/test/netbase_tests.cpp
@@ -381,19 +381,19 @@ BOOST_AUTO_TEST_CASE(netpermissions_test)
// If no permission flags, assume backward compatibility
BOOST_CHECK(NetWhitebindPermissions::TryParse("1.2.3.4:32", whitebindPermissions, error));
BOOST_CHECK(error.empty());
- BOOST_CHECK_EQUAL(whitebindPermissions.m_flags, PF_ISIMPLICIT);
- BOOST_CHECK(NetPermissions::HasFlag(whitebindPermissions.m_flags, PF_ISIMPLICIT));
- NetPermissions::ClearFlag(whitebindPermissions.m_flags, PF_ISIMPLICIT);
- BOOST_CHECK(!NetPermissions::HasFlag(whitebindPermissions.m_flags, PF_ISIMPLICIT));
- BOOST_CHECK_EQUAL(whitebindPermissions.m_flags, PF_NONE);
- NetPermissions::AddFlag(whitebindPermissions.m_flags, PF_ISIMPLICIT);
- BOOST_CHECK(NetPermissions::HasFlag(whitebindPermissions.m_flags, PF_ISIMPLICIT));
+ BOOST_CHECK_EQUAL(whitebindPermissions.m_flags, NetPermissionFlags::PF_ISIMPLICIT);
+ BOOST_CHECK(NetPermissions::HasFlag(whitebindPermissions.m_flags, NetPermissionFlags::PF_ISIMPLICIT));
+ NetPermissions::ClearFlag(whitebindPermissions.m_flags, NetPermissionFlags::PF_ISIMPLICIT);
+ BOOST_CHECK(!NetPermissions::HasFlag(whitebindPermissions.m_flags, NetPermissionFlags::PF_ISIMPLICIT));
+ BOOST_CHECK_EQUAL(whitebindPermissions.m_flags, NetPermissionFlags::PF_NONE);
+ NetPermissions::AddFlag(whitebindPermissions.m_flags, NetPermissionFlags::PF_ISIMPLICIT);
+ BOOST_CHECK(NetPermissions::HasFlag(whitebindPermissions.m_flags, NetPermissionFlags::PF_ISIMPLICIT));
// Can set one permission
BOOST_CHECK(NetWhitebindPermissions::TryParse("bloom@1.2.3.4:32", whitebindPermissions, error));
- BOOST_CHECK_EQUAL(whitebindPermissions.m_flags, PF_BLOOMFILTER);
+ BOOST_CHECK_EQUAL(whitebindPermissions.m_flags, NetPermissionFlags::PF_BLOOMFILTER);
BOOST_CHECK(NetWhitebindPermissions::TryParse("@1.2.3.4:32", whitebindPermissions, error));
- BOOST_CHECK_EQUAL(whitebindPermissions.m_flags, PF_NONE);
+ BOOST_CHECK_EQUAL(whitebindPermissions.m_flags, NetPermissionFlags::PF_NONE);
NetWhitebindPermissions noban, noban_download, download_noban, download;
@@ -420,24 +420,24 @@ BOOST_AUTO_TEST_CASE(netpermissions_test)
// Happy path, can parse flags
BOOST_CHECK(NetWhitebindPermissions::TryParse("bloom,forcerelay@1.2.3.4:32", whitebindPermissions, error));
// forcerelay should also activate the relay permission
- BOOST_CHECK_EQUAL(whitebindPermissions.m_flags, PF_BLOOMFILTER | PF_FORCERELAY | PF_RELAY);
+ BOOST_CHECK_EQUAL(whitebindPermissions.m_flags, NetPermissionFlags::PF_BLOOMFILTER | NetPermissionFlags::PF_FORCERELAY | NetPermissionFlags::PF_RELAY);
BOOST_CHECK(NetWhitebindPermissions::TryParse("bloom,relay,noban@1.2.3.4:32", whitebindPermissions, error));
- BOOST_CHECK_EQUAL(whitebindPermissions.m_flags, PF_BLOOMFILTER | PF_RELAY | PF_NOBAN);
+ BOOST_CHECK_EQUAL(whitebindPermissions.m_flags, NetPermissionFlags::PF_BLOOMFILTER | NetPermissionFlags::PF_RELAY | NetPermissionFlags::PF_NOBAN);
BOOST_CHECK(NetWhitebindPermissions::TryParse("bloom,forcerelay,noban@1.2.3.4:32", whitebindPermissions, error));
BOOST_CHECK(NetWhitebindPermissions::TryParse("all@1.2.3.4:32", whitebindPermissions, error));
- BOOST_CHECK_EQUAL(whitebindPermissions.m_flags, PF_ALL);
+ BOOST_CHECK_EQUAL(whitebindPermissions.m_flags, NetPermissionFlags::PF_ALL);
// Allow dups
BOOST_CHECK(NetWhitebindPermissions::TryParse("bloom,relay,noban,noban@1.2.3.4:32", whitebindPermissions, error));
- BOOST_CHECK_EQUAL(whitebindPermissions.m_flags, PF_BLOOMFILTER | PF_RELAY | PF_NOBAN | PF_DOWNLOAD); // "noban" implies "download"
+ BOOST_CHECK_EQUAL(whitebindPermissions.m_flags, NetPermissionFlags::PF_BLOOMFILTER | NetPermissionFlags::PF_RELAY | NetPermissionFlags::PF_NOBAN | NetPermissionFlags::PF_DOWNLOAD); // "noban" implies "download"
// Allow empty
BOOST_CHECK(NetWhitebindPermissions::TryParse("bloom,relay,,noban@1.2.3.4:32", whitebindPermissions, error));
- BOOST_CHECK_EQUAL(whitebindPermissions.m_flags, PF_BLOOMFILTER | PF_RELAY | PF_NOBAN);
+ BOOST_CHECK_EQUAL(whitebindPermissions.m_flags, NetPermissionFlags::PF_BLOOMFILTER | NetPermissionFlags::PF_RELAY | NetPermissionFlags::PF_NOBAN);
BOOST_CHECK(NetWhitebindPermissions::TryParse(",@1.2.3.4:32", whitebindPermissions, error));
- BOOST_CHECK_EQUAL(whitebindPermissions.m_flags, PF_NONE);
+ BOOST_CHECK_EQUAL(whitebindPermissions.m_flags, NetPermissionFlags::PF_NONE);
BOOST_CHECK(NetWhitebindPermissions::TryParse(",,@1.2.3.4:32", whitebindPermissions, error));
- BOOST_CHECK_EQUAL(whitebindPermissions.m_flags, PF_NONE);
+ BOOST_CHECK_EQUAL(whitebindPermissions.m_flags, NetPermissionFlags::PF_NONE);
// Detect invalid flag
BOOST_CHECK(!NetWhitebindPermissions::TryParse("bloom,forcerelay,oopsie@1.2.3.4:32", whitebindPermissions, error));
@@ -449,16 +449,16 @@ BOOST_AUTO_TEST_CASE(netpermissions_test)
// Happy path for whitelist parsing
BOOST_CHECK(NetWhitelistPermissions::TryParse("noban@1.2.3.4", whitelistPermissions, error));
- BOOST_CHECK_EQUAL(whitelistPermissions.m_flags, PF_NOBAN);
+ BOOST_CHECK_EQUAL(whitelistPermissions.m_flags, NetPermissionFlags::PF_NOBAN);
BOOST_CHECK(NetPermissions::HasFlag(whitelistPermissions.m_flags, NetPermissionFlags::PF_NOBAN));
BOOST_CHECK(NetWhitelistPermissions::TryParse("bloom,forcerelay,noban,relay@1.2.3.4/32", whitelistPermissions, error));
- BOOST_CHECK_EQUAL(whitelistPermissions.m_flags, PF_BLOOMFILTER | PF_FORCERELAY | PF_NOBAN | PF_RELAY);
+ BOOST_CHECK_EQUAL(whitelistPermissions.m_flags, NetPermissionFlags::PF_BLOOMFILTER | NetPermissionFlags::PF_FORCERELAY | NetPermissionFlags::PF_NOBAN | NetPermissionFlags::PF_RELAY);
BOOST_CHECK(error.empty());
BOOST_CHECK_EQUAL(whitelistPermissions.m_subnet.ToString(), "1.2.3.4/32");
BOOST_CHECK(NetWhitelistPermissions::TryParse("bloom,forcerelay,noban,relay,mempool@1.2.3.4/32", whitelistPermissions, error));
- const auto strings = NetPermissions::ToStrings(PF_ALL);
+ const auto strings = NetPermissions::ToStrings(NetPermissionFlags::PF_ALL);
BOOST_CHECK_EQUAL(strings.size(), 7U);
BOOST_CHECK(std::find(strings.begin(), strings.end(), "bloomfilter") != strings.end());
BOOST_CHECK(std::find(strings.begin(), strings.end(), "forcerelay") != strings.end());