Skip to content

Conversation

maflcko
Copy link
Member

@maflcko maflcko commented Jan 2, 2018

Commit c53c983 introduced the utility function get_datadir_path, however not all places in the code use this util function. Using the util function everywhere makes it easier to review pull requests related to the datadir.

This commit replaces datadir path creation with the datadir member of TestNode, which itself uses get_datadir_path.

@maflcko maflcko force-pushed the Mf1801-qaUseUtilDatadir branch 3 times, most recently from fa283e9 to fa72ada Compare January 2, 2018 13:41
Copy link
Contributor

@promag promag left a comment

Choose a reason for hiding this comment

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

utACK fa72ada.

BTW, maybe this should be simpler:

foo = self.node_path(1, 'regtest', 'wallets', 'wallet.dat')

self.stop_node(1)

shutil.copyfile(self.tmpdir + "/node1/regtest/wallets/wallet.dat", self.tmpdir + "/wallet.bak")
shutil.copyfile(datadir_regtest_1 + "/wallets/wallet.dat", datadir_regtest_1 + "/wallet.bak")
Copy link
Contributor

Choose a reason for hiding this comment

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

Should also use os.path.join?

@bitcoin bitcoin deleted a comment from markaw67 Jan 3, 2018
@maflcko maflcko force-pushed the Mf1801-qaUseUtilDatadir branch 3 times, most recently from bbbb244 to fad2430 Compare January 3, 2018 12:31
@maflcko maflcko changed the title qa: Use get_datadir_path qa: Use self.node_path Jan 3, 2018
@maflcko maflcko changed the title qa: Use self.node_path qa: Use node_path wrapper in test framwork Jan 3, 2018
@maflcko maflcko force-pushed the Mf1801-qaUseUtilDatadir branch 4 times, most recently from 6a0ae9c to fa3dda1 Compare January 3, 2018 14:09
@promag
Copy link
Contributor

promag commented Jan 3, 2018

utACK fa3dda1, will check for missing changes.

Copy link
Contributor

@promag promag left a comment

Choose a reason for hiding this comment

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

With these suggestions, node_path honours runtime changes to datadir, not to mention get_datadir_path is called once only.

@@ -213,7 +217,7 @@ def add_nodes(self, num_nodes, extra_args=None, rpchost=None, timewait=None, bin
assert_equal(len(extra_args), num_nodes)
assert_equal(len(binary), num_nodes)
for i in range(num_nodes):
self.nodes.append(TestNode(i, self.options.tmpdir, extra_args[i], rpchost, timewait=timewait, binary=binary[i], stderr=None, mocktime=self.mocktime, coverage_dir=self.options.coveragedir))
self.nodes.append(TestNode(i, self.node_path(i), extra_args[i], rpchost, timewait=timewait, binary=binary[i], stderr=None, mocktime=self.mocktime, coverage_dir=self.options.coveragedir))
Copy link
Contributor

Choose a reason for hiding this comment

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

Use get_datadir_path(self.options.tmpdir, i) instead.

@@ -203,6 +204,9 @@ def run_test(self):

# Public helper methods. These can be accessed by the subclass test scripts.

def node_path(self, i, *paths):
return os.path.join(get_datadir_path(self.options.tmpdir, i), *paths)
Copy link
Contributor

Choose a reason for hiding this comment

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

Use os.path.join(node[i].datadir, *paths) instead.

Copy link
Contributor

@promag promag left a comment

Choose a reason for hiding this comment

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

Nit, there are a couple of these (node[i].datadir) that could be changed:

-        assert os.path.isfile(os.path.join(self.nodes[0].datadir, "regtest", "debug.log"))
+        assert os.path.isfile(self.node_path(0, 'regtest', 'debug.log'))

@laanwj laanwj changed the title qa: Use node_path wrapper in test framwork qa: Use node_path wrapper in test framework Jan 5, 2018
@jnewbery
Copy link
Contributor

jnewbery commented Jan 8, 2018

concept ACK.

What are the benefits of using self.node_path(i) over self.nodes[i].datadir?

@promag
Copy link
Contributor

promag commented Jan 8, 2018

Implicit path join.

@jnewbery
Copy link
Contributor

jnewbery commented Jan 8, 2018

ok, let me rephrase: what are the benefits of implementing this as a method on BitcoinTestFramework rather than on TestNode?

@promag
Copy link
Contributor

promag commented Jan 8, 2018

@jnewbery I guess either are ok. You prefer node[i].path() or something like that? My suggestion was to avoid os.path.join() or datadir + '/' foo all over the tests.

@maflcko maflcko force-pushed the Mf1801-qaUseUtilDatadir branch from fa3dda1 to fa53143 Compare January 13, 2018 00:15
@maflcko maflcko changed the title qa: Use node_path wrapper in test framework qa: Use node.datadir instead of tmpdir in test framework Jan 13, 2018
@maflcko maflcko force-pushed the Mf1801-qaUseUtilDatadir branch 2 times, most recently from fa5519a to fa31ff9 Compare January 13, 2018 14:30
@maflcko maflcko force-pushed the Mf1801-qaUseUtilDatadir branch from fa31ff9 to faada8b Compare March 6, 2018 23:28
@maflcko maflcko force-pushed the Mf1801-qaUseUtilDatadir branch 2 times, most recently from fa8945d to b5aecb2 Compare March 8, 2018 03:57
@maflcko maflcko force-pushed the Mf1801-qaUseUtilDatadir branch from b5aecb2 to 5c2e2a8 Compare March 17, 2018 20:42
@maflcko maflcko force-pushed the Mf1801-qaUseUtilDatadir branch from 5c2e2a8 to c8330d4 Compare March 19, 2018 16:26
@laanwj laanwj merged commit c8330d4 into bitcoin:master Mar 22, 2018
laanwj added a commit that referenced this pull request Mar 22, 2018
c8330d4 qa: Use node.datadir instead of tmpdir in test framework (MarcoFalke)

Pull request description:

  Commit c53c983 introduced the utility function `get_datadir_path`, however not all places in the code use this util function. Using the util function everywhere makes it easier to review pull requests related to the datadir.

  This commit replaces datadir path creation with the `datadir` member of `TestNode`, which itself uses `get_datadir_path`.

Tree-SHA512: c75707ab7149d732a6d56152a5813138a33459d3d07577b60b89f2a207c83b7663fac5f203593677c9892d1c23a5eba4bd45c5c4ababf040d720b437240fcddf
@maflcko maflcko deleted the Mf1801-qaUseUtilDatadir branch March 22, 2018 16:31
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Dec 16, 2020
…ramework

c8330d4 qa: Use node.datadir instead of tmpdir in test framework (MarcoFalke)

Pull request description:

  Commit c53c983 introduced the utility function `get_datadir_path`, however not all places in the code use this util function. Using the util function everywhere makes it easier to review pull requests related to the datadir.

  This commit replaces datadir path creation with the `datadir` member of `TestNode`, which itself uses `get_datadir_path`.

Tree-SHA512: c75707ab7149d732a6d56152a5813138a33459d3d07577b60b89f2a207c83b7663fac5f203593677c9892d1c23a5eba4bd45c5c4ababf040d720b437240fcddf
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Dec 18, 2020
…ramework

c8330d4 qa: Use node.datadir instead of tmpdir in test framework (MarcoFalke)

Pull request description:

  Commit c53c983 introduced the utility function `get_datadir_path`, however not all places in the code use this util function. Using the util function everywhere makes it easier to review pull requests related to the datadir.

  This commit replaces datadir path creation with the `datadir` member of `TestNode`, which itself uses `get_datadir_path`.

Tree-SHA512: c75707ab7149d732a6d56152a5813138a33459d3d07577b60b89f2a207c83b7663fac5f203593677c9892d1c23a5eba4bd45c5c4ababf040d720b437240fcddf
@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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants