[tor-dev] Chutney code refactoring

teor teor at riseup.net
Fri May 15 01:20:54 UTC 2020


Hi Caitlin,

> On 15 May 2020, at 09:59, Nick Mathewson <nickm at freehaven.net> wrote:
> 
> On Thu, May 14, 2020 at 7:04 PM c <c at chroniko.jp> wrote:
>> 
>>> On Sat, 18 Apr 2020 11:02:03 +0000
>>> c <c at chroniko.jp> wrote:
>>> 
>>> I came across Node.specialize() which does not seem to be called
>>> elsewhere, and I cannot guess at its purpose.
>> 
>> I ran vulture (a static analyzer for dead code), trimmed the output to
>> omit things I know were being used (some functions/attributes are used
>> solely in Python 2), and found these unused names:
>> 
>> lib/chutney/Templating.py:280: unused function 'getUpdateTime' (60% confidence)
>> lib/chutney/TorNet.py:439: unused function 'specialize' (60% confidence)
>> lib/chutney/TorNet.py:658: unused function '_getFreeVars' (60% confidence)
>> lib/chutney/TorNet.py:1232: unused function 'isBootstrapped' (60% confidence)
>> lib/chutney/TorNet.py:1799: unused function 'isInExpectedDirInfoDocs' (60% confidence)
>> lib/chutney/TorNet.py:2151: unused function 'configure' (60% confidence)
>> lib/chutney/TorNet.py:2191: unused function 'restart' (60% confidence)
>> lib/chutney/TorNet.py:2286: unused function 'wait_for_bootstrap' (60% confidence)
>> lib/chutney/Traffic.py:335: unused attribute 'am_closing' (60% confidence)
>> lib/chutney/Traffic.py:345: unused attribute 'am_closing' (60% confidence)
>> lib/chutney/Traffic.py:400: unused attribute 'pending_close' (60% confidence)
>> lib/chutney/Traffic.py:406: unused attribute 'dot_repetitions' (60% confidence)
>> 
>> Aside from isBootstrapped() which we discussed previously and are
>> likely going to use, is there any code that stands out as unnecessary
>> or dead?
> 
> Hm. Of these:
> 
> isInExpectedDirInfoDocs looks like it might once have done something useful.
> 
> configure and restart and wait_for_bootstrap are all in use; they are
> invoked by name, from the command line, at the end of runConfigFile,
> where it says `return getattr(network, verb)()`.
> 
> I think the rest are likely to be unused.

You could try deleting functions, and then running tor's
"make test-network-all". If that test still passes, then the code is probably
unused (in practice).

Chutney's CI does a few more tests for different tor versions, but I'm pretty
sure they all use the same code.

T

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: Message signed with OpenPGP
URL: <http://lists.torproject.org/pipermail/tor-dev/attachments/20200515/fc52467c/attachment.sig>


More information about the tor-dev mailing list