Skip to content

Conversation

@maflcko
Copy link
Member

@maflcko maflcko commented Dec 13, 2018

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.)

@maflcko maflcko added the Tests label Dec 13, 2018
@jnewbery
Copy link
Contributor

utACK faa8311

reasons: #14805 (comment)

sorry @stevenroose !

@laanwj
Copy link
Member

laanwj commented Dec 13, 2018

I'm not sure this is worth reverting, but okay

utACK faa8311
(really confused by Travis here)

@jnewbery
Copy link
Contributor

Can you add a comment to add_nodes() explaining why it should only be called once.

@maflcko
Copy link
Member Author

maflcko commented Dec 13, 2018

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.

@jnewbery
Copy link
Contributor

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.

for i in range(num_nodes):
numnode = len(self.nodes)
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))
self.nodes.append(TestNode(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

much better readable

@stevenroose
Copy link
Contributor

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?

@jnewbery
Copy link
Contributor

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().

maflcko pushed a commit to maflcko/bitcoin-core that referenced this pull request Dec 14, 2018
…an once"

fa4b8c9 test: add_nodes can only be called once after set_test_params (MarcoFalke)
faa8311 Revert "tests: Support calling add_nodes more than once" (MarcoFalke)

Pull request description:

  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.)

Tree-SHA512: 83a67f2cba9d97e21d80847ff405a4633fcb0d5674486efa57ee1813e46efe8709ae0fb462b8339a01ebeca5c4f2d29ecb1807d648b8fd9ee8ce336b08d580a8
@maflcko maflcko merged commit fa4b8c9 into bitcoin:master Dec 14, 2018
@maflcko maflcko deleted the Mf1812-TestrevertAddNodes branch December 14, 2018 18:29
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Sep 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants