-
Notifications
You must be signed in to change notification settings - Fork 32
test: Add multiple transactions and error handling tests for getreceivedbyaddress #8
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -124,6 +124,18 @@ def run_test(self): | |
| # Trying to getreceivedby for an address the wallet doesn't own should return an error | ||
| assert_raises_rpc_error(-4, "Address not found in wallet", self.nodes[0].getreceivedbyaddress, addr) | ||
|
|
||
| # Test multiple transactions to the same address | ||
| addr_with_multiple_txs = self.nodes[1].getnewaddress() | ||
| self.nodes[0].sendtoaddress(addr_with_multiple_txs, Decimal("0.1")) | ||
| self.nodes[0].sendtoaddress(addr_with_multiple_txs, Decimal("0.2")) | ||
| self.generatetoaddress(self.nodes[0], 1, addr_with_multiple_txs) | ||
| self.generate(self.nodes[0], 1) | ||
| balance = self.nodes[1].getreceivedbyaddress(addr_with_multiple_txs, 5, True) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. min confirmation set to 5, and only 2 blocks has been mined. This is making the test to break There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This has two issues:
Make sure tests in CI are all passing! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Can confirm, tested locally and this is exactly what happened. |
||
| assert_equal(balance, Decimal("0.3")) | ||
|
|
||
| # Test invalid address format error | ||
| assert_raises_rpc_error(-5, "Invalid Bitcoin address", self.nodes[1].getreceivedbyaddress, "invalid_address") | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe it would make sense to have this change in a separate commit for each commit to address only one of the issues presented in the goals of the PR. |
||
|
|
||
| self.log.info("listreceivedbylabel + getreceivedbylabel Test") | ||
|
|
||
| # set pre-state | ||
|
|
@@ -144,7 +156,7 @@ def run_test(self): | |
| {"label": label}, | ||
| received_by_label_json) | ||
|
|
||
| # getreceivedbyaddress should return same balance because of 0 confirmations | ||
| # getreceivedbylabel should return same balance because of 0 confirmations | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a necessary cleanup, but don't forget to add it in the PR description. |
||
| balance = self.nodes[1].getreceivedbylabel(label) | ||
| assert_equal(balance, balance_by_label) | ||
|
|
||
|
|
||
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.
Remove this and just call
generatewith 5 blocks. Otherwise the test fails.