MCPcopy Create free account
hub / github.com/ElementsProject/elements / run_test

Method run_test

test/functional/p2p_permissions.py:33–93  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

31 self.setup_clean_chain = True
32
33 def run_test(self):
34 self.check_tx_relay()
35
36 self.checkpermission(
37 # default permissions (no specific permissions)
38 ["-whitelist=127.0.0.1"],
39 # Make sure the default values in the command line documentation match the ones here
40 ["relay", "noban", "mempool", "download"])
41
42 self.checkpermission(
43 # no permission (even with forcerelay)
44 ["-whitelist=@127.0.0.1", "-whitelistforcerelay=1"],
45 [])
46
47 self.checkpermission(
48 # relay permission removed (no specific permissions)
49 ["-whitelist=127.0.0.1", "-whitelistrelay=0"],
50 ["noban", "mempool", "download"])
51
52 self.checkpermission(
53 # forcerelay and relay permission added
54 # Legacy parameter interaction which set whitelistrelay to true
55 # if whitelistforcerelay is true
56 ["-whitelist=127.0.0.1", "-whitelistforcerelay"],
57 ["forcerelay", "relay", "noban", "mempool", "download"])
58
59 # Let's make sure permissions are merged correctly
60 # For this, we need to use whitebind instead of bind
61 # by modifying the configuration file.
62 ip_port = "127.0.0.1:{}".format(p2p_port(1))
63 self.replaceinconfig(1, "bind=127.0.0.1", "whitebind=bloomfilter,forcerelay@" + ip_port)
64 self.checkpermission(
65 ["-whitelist=noban@127.0.0.1"],
66 # Check parameter interaction forcerelay should activate relay
67 ["noban", "bloomfilter", "forcerelay", "relay", "download"])
68 self.replaceinconfig(1, "whitebind=bloomfilter,forcerelay@" + ip_port, "bind=127.0.0.1")
69
70 self.checkpermission(
71 # legacy whitelistrelay should be ignored
72 ["-whitelist=noban,mempool@127.0.0.1", "-whitelistrelay"],
73 ["noban", "mempool", "download"])
74
75 self.checkpermission(
76 # legacy whitelistforcerelay should be ignored
77 ["-whitelist=noban,mempool@127.0.0.1", "-whitelistforcerelay"],
78 ["noban", "mempool", "download"])
79
80 self.checkpermission(
81 # missing mempool permission to be considered legacy whitelisted
82 ["-whitelist=noban@127.0.0.1"],
83 ["noban", "download"])
84
85 self.checkpermission(
86 # all permission added
87 ["-whitelist=all@127.0.0.1"],
88 ["forcerelay", "noban", "mempool", "bloomfilter", "relay", "download", "addr"])
89
90 self.stop_node(1)

Callers

nothing calls this directly

Calls 7

check_tx_relayMethod · 0.95
checkpermissionMethod · 0.95
replaceinconfigMethod · 0.95
p2p_portFunction · 0.90
formatMethod · 0.80
stop_nodeMethod · 0.45

Tested by

no test coverage detected