Writing tests should be straightforward and with little side-effects as possible.
I don't see how this is needed and can not be achieved with self.num_nodes (and self.extra_args et al.)
Writing tests should be straightforward and with little side-effects as possible.
I don't see how this is needed and can not be achieved with self.num_nodes (and self.extra_args et al.)
This reverts commit 98a1846b00d9c3076d6dcd96244fae6f923e26a0.
I'm not sure this is worth reverting, but okay
utACK faa831102a0ce11b673b72081eed159ad0c17159 (really confused by Travis here)
Can you add a comment to add_nodes() explaining why it should only be called once.
Is there a reason other than it being the design we want it to? I added a comment to mention that it should be called once after the parameters for all nodes have been set up.
Is there a reason other than it being the design we want it to?
That's really it. Some of the test framework infrastructure relies on the num_nodes not changing. We could change that, but I think declaring the number of nodes at the start of the test is a good thing to do anyway.
294 | @@ -292,8 +295,19 @@ def add_nodes(self, num_nodes, extra_args=None, *, rpchost=None, binary=None): 295 | assert_equal(len(extra_args), num_nodes) 296 | assert_equal(len(binary), num_nodes) 297 | for i in range(num_nodes): 298 | - numnode = len(self.nodes) 299 | - self.nodes.append(TestNode(numnode, get_datadir_path(self.options.tmpdir, numnode), rpchost=rpchost, timewait=self.rpc_timewait, bitcoind=binary[i], bitcoin_cli=self.options.bitcoincli, mocktime=self.mocktime, coverage_dir=self.options.coveragedir, extra_conf=extra_confs[i], extra_args=extra_args[i], use_cli=self.options.usecli)) 300 | + self.nodes.append(TestNode(
much better readable
I added a comment to mention that it should be called once after the parameters for all nodes have been set up.
That's what a method setup_nodes would be expected to do, IMO :)
Fair enough. So the correct was is to call add_nodes once and build a list of the binaries, chain names, etc beforehand?
So the correct was is to call add_nodes once and build a list of the binaries, chain names, etc beforehand?
Yes. If necessary, the node's arguments and config file can be updated later with TestNode.args and append_config().