-
Notifications
You must be signed in to change notification settings - Fork 38.7k
[tests] Add test for wallet rebroadcasts #15646
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[tests] Add test for wallet rebroadcasts #15646
Conversation
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ConflictsReviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. Coverage
Updated at: 2019-03-22T20:15:25.016978. |
|
I'm seeing this locally on x86_64 Linux Debian 4.19.16-1 (2019-01-17): |
|
If helpful, this version of the test passes for me locally: jonatack@0608a16. Main change is the last # Transaction should be broadcast after 30 minutes. Give it ~60 (31 + 29) to be sure.
node.setmocktime(time_now + 60 * 29) |
promag
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IIUC doing the following forces CWallet::ResendWalletTransactions at the begin of the test, which sets the correct value for nNextResend.
--- a/test/functional/wallet_resendwallettransactions.py
+++ b/test/functional/wallet_resendwallettransactions.py
@@ -37,6 +37,7 @@ class ResendWalletTransactionsTest(BitcoinTestFramework):
# Create a new transaction. Set time to 31 minutes in the past.
time_now = int(time.time())
self.nodes[0].setmocktime(time_now - 60 * 31)
+ txid = self.nodes[0].generatetoaddress(1, self.nodes[0].getnewaddress())
txid = self.nodes[0].sendtoaddress(self.nodes[0].getnewaddress(), 1)
# Can take a few seconds due to transaction trickling|
Thanks for the review @jonatack and @promag . I've pushed a fixup commit that:
It should pass reliably now. Are you able to rereview/retest? |
|
Concept ACK |
|
@practicalswift No need to "Concept ACK" someone adding tests. This is already encouraged by the contribution guidelines and adding a comment adds no value. It would help if you ran the test or gave feedback about the code, however. |
|
Should be squashed to make ready for review. Also, would be good to explain why |
ryanofsky
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
utACK b5eb0ea42fe32426dd22b77d4146df3a56e2f006
6fc3c40 to
c1a96f0
Compare
|
Commits squashed. I've also made a small update to the commit log to make it clearer that this commit fixes the deficiencies with the previous test.
I intend to remove the |
jonatack
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @jnewbery. The test now passes repeatedly for me on Linux Debian 4.19 x86/64 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was using the same value for node.setmocktime and the block time in create_block a key fix? Good catch.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, sometimes the block was being rejected because of the bad timestamp. The node logs were pretty helpful in identifying the problem.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just an idea: It might be nice to hoist all the local variables for the test setup together at the top, or in a setup function, to see the setup as a whole. Doing this also made it more apparent that we can potentially reduce the number of system time calls.
node = self.nodes[0] # alias
block_time = int(time.time()) + 6 * 60
rebroadcast_time = block_time + 31 * 60There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried this locally as above, simplified to one single call to int(time.time()) and 31 minutes for rebroadcast instead of 35, and the test appears equally robust this way since an extra minute is given for the block.
Edit: I initially thought that defining rebroadcast_time relative to block_time, rather than the current time, might be a more rigorous test of CWallet::ResendWalletTransactions in wallet.cpp. On re-reading it this morning, that was perhaps incorrect, though I am still looking at how all the state is handled. On my system it does appear we can tighten the extra 5 minutes down to 1 minute in the test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be nice to hoist all the local variables for the test setup together at the top
Generally we declare variables at the point of first use (both in the C++ and Python code). You could argue that these are more like constants so declaring them at the top makes sense. I don't have a strong feeling either way, so I'll leave it as is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The logs are a great enhancement:
$ test/functional/wallet_resendwallettransactions.py
2019-03-26T21:05:37.079000Z TestFramework (INFO): Initializing test directory /tmp/bitcoin_func_test_eb5_rvg_
2019-03-26T21:05:37.874000Z TestFramework (INFO): Create a new transaction and wait until it's broadcast.
2019-03-26T21:05:38.807000Z TestFramework (INFO): Create a block.
2019-03-26T21:05:38.864000Z TestFramework (INFO): Transaction should be rebroadcast after 30 minutes.
2019-03-26T21:05:40.021000Z TestFramework (INFO): Stopping nodes
2019-03-26T21:05:40.329000Z TestFramework (INFO): Cleaning up /tmp/bitcoin_func_test_eb5_rvg_ on exit
2019-03-26T21:05:40.329000Z TestFramework (INFO): Tests successful
Note that the auto logging does not appear to terminate with periods, if you wish to do the same.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed!
|
utACK c1a96f0f339987d48cdaba75e628030cbf6391b8 |
The existing wallet_resendwallettransactions.py test only tests the resendwallettransactions RPC. It does not test whether transactions are actually rebroadcast, or whether the rebroadcast logic is called on a timer. This commit updates the test to not use the resendwallettransactions RPC and test that transactions are rebroadcast on a timer.
c1a96f0 to
529c1ae
Compare
|
Thanks for the review/test @jonatack . I've changed the log messages, but kept the time variables as they were. |
|
re-utACK 529c1ae Only change is punctuation |
529c1ae [tests] Add test for wallet rebroadcasts (John Newbery) Pull request description: The existing wallet_resendwallettransactions.py test only tests the resendwallettransactions RPC. It does not test whether transactions are actually rebroadcast, or whether the rebroadcast logic is called on a timer. Update the test to not use the resendwallettransactions RPC and test that transactions are resent on a timer. ACKs for commit 529c1a: MarcoFalke: re-utACK 529c1ae Tree-SHA512: 7341e7dd07cdc8ecbc08b1949121824148d2b58133a8e298ecdc5b7555713df3cecffb49854443cef9f033ef847cbf329e879a3bf57ab4e1fc733be432e9f718
|
This will be backported to 0.18.0rc3 |
The existing wallet_resendwallettransactions.py test only tests the resendwallettransactions RPC. It does not test whether transactions are actually rebroadcast, or whether the rebroadcast logic is called on a timer. This commit updates the test to not use the resendwallettransactions RPC and test that transactions are rebroadcast on a timer. Github-Pull: bitcoin#15646 Rebased-From: 529c1ae
Concept ACK on this, I think it can be useful to send individual transactions, but this can be done by getting the transaction hex from |
The existing wallet_resendwallettransactions.py test only tests the resendwallettransactions RPC. It does not test whether transactions are actually rebroadcast, or whether the rebroadcast logic is called on a timer. This commit updates the test to not use the resendwallettransactions RPC and test that transactions are rebroadcast on a timer. Github-Pull: bitcoin#15646 Rebased-From: 529c1ae
Summary: The existing wallet_resendwallettransactions.py test only tests the resendwallettransactions RPC. It does not test whether transactions are actually rebroadcast, or whether the rebroadcast logic is called on a timer. This commit updates the test to not use the resendwallettransactions RPC and test that transactions are rebroadcast on a timer. --- This is a backport of Core [[bitcoin/bitcoin#15646 | PR15646]] Test Plan: cmake .. -GNinja ./test/functional/test_runner.py wallet_resendwallettransactions.py Reviewers: #bitcoin_abc, jasonbcox Reviewed By: #bitcoin_abc, jasonbcox Differential Revision: https://reviews.bitcoinabc.org/D5947
Summary: The existing wallet_resendwallettransactions.py test only tests the resendwallettransactions RPC. It does not test whether transactions are actually rebroadcast, or whether the rebroadcast logic is called on a timer. This commit updates the test to not use the resendwallettransactions RPC and test that transactions are rebroadcast on a timer. --- This is a backport of Core [[bitcoin/bitcoin#15646 | PR15646]] Test Plan: cmake .. -GNinja ./test/functional/test_runner.py wallet_resendwallettransactions.py Reviewers: #bitcoin_abc, jasonbcox Reviewed By: #bitcoin_abc, jasonbcox Differential Revision: https://reviews.bitcoinabc.org/D5947
529c1ae [tests] Add test for wallet rebroadcasts (John Newbery) Pull request description: The existing wallet_resendwallettransactions.py test only tests the resendwallettransactions RPC. It does not test whether transactions are actually rebroadcast, or whether the rebroadcast logic is called on a timer. Update the test to not use the resendwallettransactions RPC and test that transactions are resent on a timer. ACKs for commit 529c1a: MarcoFalke: re-utACK 529c1ae Tree-SHA512: 7341e7dd07cdc8ecbc08b1949121824148d2b58133a8e298ecdc5b7555713df3cecffb49854443cef9f033ef847cbf329e879a3bf57ab4e1fc733be432e9f718
Co-authored-by: UdjinM6 <UdjinM6@users.noreply.github.com>
The existing wallet_resendwallettransactions.py test only tests the
resendwallettransactions RPC. It does not test whether transactions are
actually rebroadcast, or whether the rebroadcast logic is called on a
timer.
Update the test to not use the resendwallettransactions RPC and test
that transactions are resent on a timer.