Skip to content

Conversation

@jnewbery
Copy link
Contributor

@sdaftuar - I never reviewed the dbcrash.py test in #10148 . This PR fixes up a few nits:

  • tidy up imports (don't import time indirectly, no need for try-except importing httplib since that's a python 2/3 compatibility trick, and our tests always run in Py3)
  • move function-level comments to docstrings
  • combine module-level docstrings
  • a few other small whitespace, etc nits

low-priority, should be fairly uncontroversial, but let me know if you disagree with any of these.

@laanwj
Copy link
Member

laanwj commented Jun 29, 2017

Looks like this test is acting up:
https://travis-ci.org/bitcoin/bitcoin/jobs/248398016
https://travis-ci.org/bitcoin/bitcoin/jobs/248398018
Might need a similar change to #10659.

Copy link
Member

@sdaftuar sdaftuar left a comment

Choose a reason for hiding this comment

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

Looks good, thanks for cleaning this up. Please take a look at the fixes needed to make travis happy as well.

Copy link
Member

Choose a reason for hiding this comment

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

I don't feel strongly, but the reason I put this in was that I didn't think that changes to the default test framework should cause tests to break -- since this test relies on a particular configuration, I felt it was best to define that locally.

Copy link
Member

Choose a reason for hiding this comment

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

Also, can you set a custom timewait for the RPC connections in this test to resolve the travis issues that have come up so far:
https://travis-ci.org/bitcoin/bitcoin/jobs/248398018#L2153

Copy link
Member

Choose a reason for hiding this comment

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

We might as well just get rid of the default value. There is nothing special about "4" that justifies to use it as default value.

Copy link
Contributor Author

@jnewbery jnewbery Jun 30, 2017

Choose a reason for hiding this comment

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

ok, you've convinced me. I'll leave this in for now.

We can remove the default num_nodes in a future PR (and probably remove the default topology and premine while we're at it).

Copy link
Member

Choose a reason for hiding this comment

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

I think this RemoteDisconnected exception may not exist pre-3.5, which would explain this travis failure:
https://travis-ci.org/bitcoin/bitcoin/jobs/248398016#L3321

I'm not sure what the best way to handle that is...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think I've fixed this in my fixup commit b394a00f6c34e20e5ff555c8a07c6558e319a34a. Just catch different errors depending on which version of Python is being run.

I think later we should move this logic to a separate method named send_rpc_may_fail() or similar in TestNode to keep the test script code clean.

Copy link
Member

Choose a reason for hiding this comment

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

Feel free to address the TODO as well :) I think you just do something like relayfee = self.nodes[0].getnetworkinfo()['relayfee'], and then convert to the right units.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I haven't addressed this. What are the downsides to using a fixed fee?

@jnewbery
Copy link
Contributor Author

I think I've fixed the Travis issues, although it's difficult to tell for sure since Travis only runs extended tests in master.

For the first, I split the generate call in create_confirmed_utxos() into many smaller generate calls. For the second, I catch different errors depending on the Python version.

Both of these solutions should be moved into TestNode once that's merged (ie a node_generate() method which automatically breaks the generate call into smaller pieces, and a send_rpc_may_fail() method for RPCs that may or may not time out).

I haven't addressed the fixed fee todo. I don't think that's too much of a problem, but let me know if you think it could cause issues.

One question: I'm confused about the randomness in re-org'ing. As far as I can see, the way this works:

  • pick a block at random between the start of the test and the current tip.
  • pick random x in [0,1]. If x < 1 / (depth of random block + 4), then re-org back to random block
  • build to current tip + 1
    (repeat x 40)

That throws up events with very low probabilities. For example, we'll re-org back 40 blocks in 1/40 * 1/44 = 1/1760 tests. For me, such indeterminateness is troubling. If there was a problem that caused large re-orgs to fail, then they'd only be caught very intermittently by this test, and it'd be difficult to debug.

I prefer my tests to be more deterministic where possible. How would you feel about changing the re-orgs to a fixed schedule (ie make sure the test covers re-orgs of 1, 2, 4, 8, 16 and 32 blocks, or some similar schedule)?

@maflcko
Copy link
Member

maflcko commented Jul 2, 2017

utACK b394a00f6c34e20e5ff555c8a07c6558e319a34a. Feel free to squash.

@jnewbery
Copy link
Contributor Author

jnewbery commented Jul 2, 2017

squashed

@maflcko
Copy link
Member

maflcko commented Jul 3, 2017

Going to merge this now, since it might fix the test failures we see on master right now. Further cleanup can always be completed in later commits.

@maflcko maflcko merged commit 27c63dc into bitcoin:master Jul 3, 2017
maflcko pushed a commit that referenced this pull request Jul 3, 2017
27c63dc [tests] nits in dbcrash.py (John Newbery)

Tree-SHA512: 2a75feeb65e6147e3337200cde982248bea8977a9585d5ee284d62bbc25f6d7c368754da0083aec37338c8f66cf698ee25bbd9e192df14a9fb976b8f75afa986
@sdaftuar
Copy link
Member

sdaftuar commented Jul 6, 2017

That throws up events with very low probabilities. For example, we'll re-org back 40 blocks in 1/40 * 1/44 = 1/1760 tests. For me, such indeterminateness is troubling. If there was a problem that caused large re-orgs to fail, then they'd only be caught very intermittently by this test, and it'd be difficult to debug.

I prefer my tests to be more deterministic where possible. How would you feel about changing the re-orgs to a fixed schedule (ie make sure the test covers re-orgs of 1, 2, 4, 8, 16 and 32 blocks, or some similar schedule)?

@jnewbery I don't think the right way to think of this test is that we're testing reorgs. Really, we're testing a more complex state (utxo cache + disk state) and trying to get as much coverage of various edge cases as we can. Since it's hard for me to imagine all the possible states we could be in, I wanted to simulate as much normal looking bitcoin transaction volume as I reasonably could, and then randomly stress it with reorgs and crashes in the hopes that if an edge case had a bug, we'd eventually see it.

If I knew exactly how to enumerate all the edge cases, then I'd happily convert this to a deterministic set of tests, but lacking that I think the randomness here is an appropriate test strategy.

@jnewbery
Copy link
Contributor Author

jnewbery commented Jul 6, 2017

I don't think the right way to think of this test ... , but lacking that I think the randomness here is an appropriate test strategy.

ACK

PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Jul 23, 2019
27c63dc [tests] nits in dbcrash.py (John Newbery)

Tree-SHA512: 2a75feeb65e6147e3337200cde982248bea8977a9585d5ee284d62bbc25f6d7c368754da0083aec37338c8f66cf698ee25bbd9e192df14a9fb976b8f75afa986
UdjinM6 pushed a commit to UdjinM6/dash that referenced this pull request Jul 6, 2021
27c63dc [tests] nits in dbcrash.py (John Newbery)

Tree-SHA512: 2a75feeb65e6147e3337200cde982248bea8977a9585d5ee284d62bbc25f6d7c368754da0083aec37338c8f66cf698ee25bbd9e192df14a9fb976b8f75afa986
UdjinM6 pushed a commit to UdjinM6/dash that referenced this pull request Jul 6, 2021
27c63dc [tests] nits in dbcrash.py (John Newbery)

Tree-SHA512: 2a75feeb65e6147e3337200cde982248bea8977a9585d5ee284d62bbc25f6d7c368754da0083aec37338c8f66cf698ee25bbd9e192df14a9fb976b8f75afa986
@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.

5 participants