Refactor to avoid conflicts in new p2p permissions

This commit is contained in:
Luke Dashjr 2020-06-07 22:52:06 +00:00
parent fdcfa5ac36
commit ff459b5b55
3 changed files with 25 additions and 10 deletions

View File

@ -16,6 +16,7 @@ struct bilingual_str;
extern const std::vector<std::string> NET_PERMISSIONS_DOC;
enum class NetPermissionFlags : uint32_t {
// NOTE: When adding here, be sure to update net_permissions.cpp's NetPermissions::ToStrings too
None = 0,
// Can query bloomfilter even if -peerbloomfilters is false
BloomFilter = (1U << 1),

View File

@ -463,15 +463,20 @@ BOOST_AUTO_TEST_CASE(netpermissions_test)
BOOST_CHECK(NetWhitelistPermissions::TryParse("bloom,forcerelay,noban,relay,mempool@1.2.3.4/32", whitelistPermissions, error));
const auto strings = NetPermissions::ToStrings(NetPermissionFlags::All);
BOOST_CHECK_EQUAL(strings.size(), 8U);
BOOST_CHECK(std::find(strings.begin(), strings.end(), "blockfilters") != strings.end());
BOOST_CHECK(std::find(strings.begin(), strings.end(), "bloomfilter") != strings.end());
BOOST_CHECK(std::find(strings.begin(), strings.end(), "forcerelay") != strings.end());
BOOST_CHECK(std::find(strings.begin(), strings.end(), "relay") != strings.end());
BOOST_CHECK(std::find(strings.begin(), strings.end(), "noban") != strings.end());
BOOST_CHECK(std::find(strings.begin(), strings.end(), "mempool") != strings.end());
BOOST_CHECK(std::find(strings.begin(), strings.end(), "download") != strings.end());
BOOST_CHECK(std::find(strings.begin(), strings.end(), "addr") != strings.end());
const std::vector<std::string> expected_strings{
"blockfilters",
"bloomfilter",
"forcerelay",
"relay",
"noban",
"mempool",
"download",
"addr",
};
BOOST_CHECK_EQUAL(strings.size(), expected_strings.size());
for (const auto& expected : expected_strings) {
BOOST_CHECK(std::find(strings.begin(), strings.end(), expected) != strings.end());
}
}
BOOST_AUTO_TEST_CASE(netbase_dont_resolve_strings_with_embedded_nul_characters)

View File

@ -81,7 +81,16 @@ class P2PPermissionsTests(BitcoinTestFramework):
self.checkpermission(
# all permission added
["-whitelist=all@127.0.0.1"],
["blockfilters", "forcerelay", "noban", "mempool", "bloomfilter", "relay", "download", "addr"])
[
"blockfilters",
"forcerelay",
"noban",
"mempool",
"bloomfilter",
"relay",
"download",
"addr",
])
self.stop_node(1)
self.nodes[1].assert_start_raises_init_error(["-whitelist=oopsie@127.0.0.1"], "Invalid P2P permission", match=ErrorMatch.PARTIAL_REGEX)