Changeset View
Changeset View
Standalone View
Standalone View
test/functional/p2p_permissions.py
Show All 21 Lines | def set_test_params(self): | ||||
self.setup_clean_chain = True | self.setup_clean_chain = True | ||||
self.extra_args = [[], []] | self.extra_args = [[], []] | ||||
def run_test(self): | def run_test(self): | ||||
self.checkpermission( | self.checkpermission( | ||||
# default permissions (no specific permissions) | # default permissions (no specific permissions) | ||||
["-whitelist=127.0.0.1"], | ["-whitelist=127.0.0.1"], | ||||
["relay", "noban", "mempool"], | # Make sure the default values in the command line documentation | ||||
# match the ones here | |||||
["relay", "noban", "mempool", "download"], | |||||
True) | True) | ||||
self.checkpermission( | self.checkpermission( | ||||
# relay permission removed (no specific permissions) | # relay permission removed (no specific permissions) | ||||
["-whitelist=127.0.0.1", "-whitelistrelay=0"], | ["-whitelist=127.0.0.1", "-whitelistrelay=0"], | ||||
["noban", "mempool"], | ["noban", "mempool", "download"], | ||||
True) | True) | ||||
self.checkpermission( | self.checkpermission( | ||||
# forcerelay and relay permission added | # forcerelay and relay permission added | ||||
# Legacy parameter interaction which set whitelistrelay to true | # Legacy parameter interaction which set whitelistrelay to true | ||||
# if whitelistforcerelay is true | # if whitelistforcerelay is true | ||||
["-whitelist=127.0.0.1", "-whitelistforcerelay"], | ["-whitelist=127.0.0.1", "-whitelistforcerelay"], | ||||
["forcerelay", "relay", "noban", "mempool"], | ["forcerelay", "relay", "noban", "mempool", "download"], | ||||
True) | True) | ||||
# Let's make sure permissions are merged correctly | # Let's make sure permissions are merged correctly | ||||
# For this, we need to use whitebind instead of bind | # For this, we need to use whitebind instead of bind | ||||
# by modifying the configuration file. | # by modifying the configuration file. | ||||
ip_port = "127.0.0.1:{}".format(p2p_port(1)) | ip_port = "127.0.0.1:{}".format(p2p_port(1)) | ||||
self.replaceinconfig( | self.replaceinconfig( | ||||
1, | 1, | ||||
"bind=127.0.0.1", | "bind=127.0.0.1", | ||||
"whitebind=bloomfilter,forcerelay@" + | "whitebind=bloomfilter,forcerelay@" + | ||||
ip_port) | ip_port) | ||||
self.checkpermission( | self.checkpermission( | ||||
["-whitelist=noban@127.0.0.1"], | ["-whitelist=noban@127.0.0.1"], | ||||
# Check parameter interaction forcerelay should activate relay | # Check parameter interaction forcerelay should activate relay | ||||
["noban", "bloomfilter", "forcerelay", "relay"], | ["noban", "bloomfilter", "forcerelay", "relay", "download"], | ||||
False) | False) | ||||
self.replaceinconfig( | self.replaceinconfig( | ||||
1, | 1, | ||||
"whitebind=bloomfilter,forcerelay@" + | "whitebind=bloomfilter,forcerelay@" + | ||||
ip_port, | ip_port, | ||||
"bind=127.0.0.1") | "bind=127.0.0.1") | ||||
self.checkpermission( | self.checkpermission( | ||||
# legacy whitelistrelay should be ignored | # legacy whitelistrelay should be ignored | ||||
["-whitelist=noban,mempool@127.0.0.1", "-whitelistrelay"], | ["-whitelist=noban,mempool@127.0.0.1", "-whitelistrelay"], | ||||
["noban", "mempool"], | ["noban", "mempool", "download"], | ||||
False) | False) | ||||
self.checkpermission( | self.checkpermission( | ||||
# legacy whitelistforcerelay should be ignored | # legacy whitelistforcerelay should be ignored | ||||
["-whitelist=noban,mempool@127.0.0.1", "-whitelistforcerelay"], | ["-whitelist=noban,mempool@127.0.0.1", "-whitelistforcerelay"], | ||||
["noban", "mempool"], | ["noban", "mempool", "download"], | ||||
False) | False) | ||||
self.checkpermission( | self.checkpermission( | ||||
# missing mempool permission to be considered legacy whitelisted | # missing mempool permission to be considered legacy whitelisted | ||||
["-whitelist=noban@127.0.0.1"], | ["-whitelist=noban@127.0.0.1"], | ||||
["noban"], | ["noban", "download"], | ||||
False) | False) | ||||
self.checkpermission( | self.checkpermission( | ||||
# all permission added | # all permission added | ||||
["-whitelist=all@127.0.0.1"], | ["-whitelist=all@127.0.0.1"], | ||||
["forcerelay", "noban", "mempool", "bloomfilter", "relay"], | ["forcerelay", "noban", "mempool", "bloomfilter", "relay", "download"], | ||||
False) | False) | ||||
self.stop_node(1) | self.stop_node(1) | ||||
self.nodes[1].assert_start_raises_init_error( | self.nodes[1].assert_start_raises_init_error( | ||||
["-whitelist=oopsie@127.0.0.1"], | ["-whitelist=oopsie@127.0.0.1"], | ||||
"Invalid P2P permission", | "Invalid P2P permission", | ||||
match=ErrorMatch.PARTIAL_REGEX) | match=ErrorMatch.PARTIAL_REGEX) | ||||
self.nodes[1].assert_start_raises_init_error( | self.nodes[1].assert_start_raises_init_error( | ||||
Show All 28 Lines |