-
Notifications
You must be signed in to change notification settings - Fork 38.8k
[qt] [tests] Clarify address book error messages, add tests #12830
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
[qt] [tests] Clarify address book error messages, add tests #12830
Conversation
src/qt/editaddressdialog.cpp
Outdated
|
|
||
| if (bad_addr_purpose == "receive" && | ||
| (mode == NewSendingAddress || mode == EditSendingAddress)) { | ||
| fmt_str = "Receiving address \"%1\" cannot be added as a sending address."; |
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.
Would it be possible (or desirable) to include the label of the address that can't be added along with the raw address string in these error messages? Seems like this would provide more context.
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.
Yeah, that's a good idea. Will add.
9af990a to
97318bc
Compare
|
Incorporated @ryanofsky's feedback and rebased (diff). |
97318bc to
af66060
Compare
|
Concept ACK. Will review later. |
af66060 to
a540696
Compare
|
Fixed Travis failures (unchecked |
jnewbery
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.
Tested ACK a5406962daa18a20e21eda8b578bccfad1630fd4
Looks great. Thanks for the new tests!
src/qt/test/addressbooktests.cpp
Outdated
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.
would should
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.
Oops, fixed.
a540696 to
2d15e9c
Compare
|
Thanks for the review, @jnewbery. Typo fixed and rebased. $ diff -u <(git diff master...a540696) <(git diff master...2d15e9c)
--- /proc/self/fd/11 2018-04-02 11:30:04.855218939 -0400
+++ /proc/self/fd/12 2018-04-02 11:30:04.855218939 -0400
@@ -192,7 +192,7 @@
Mode mode;
diff --git a/src/qt/test/addressbooktests.cpp b/src/qt/test/addressbooktests.cpp
new file mode 100644
-index 0000000000..bc9ace14d7
+index 0000000000..84c765e48a
--- /dev/null
+++ b/src/qt/test/addressbooktests.cpp
@@ -0,0 +1,140 @@
@@ -243,7 +243,7 @@
+ *
+ * There are three cases tested:
+ *
-+ * - new_address: a new address would should add as a send address successfully.
++ * - new_address: a new address which should add as a send address successfully.
+ * - existing_s_address: an existing sending address which won't add successfully.
+ * - existing_r_address: an existing receiving address which won't add successfully.
+ * |
|
reACK 2d15e9ce7d2ca4cc48ce0010e3c1c227a81f3b78 |
c42cbc1 to
4e531b1
Compare
|
Rebased, conflicts from the #10244 merge resolved. |
src/interfaces/wallet.h
Outdated
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.
This list of optional arguments slightly scares me. How much diff would it be to remove the defaults and change all the places this is called to pass in nullptr?
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.
There are ~9 replacements this'd entail, so not too bad. Willfix.
src/qt/test/addressbooktests.cpp
Outdated
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.
unused?
qt/test/addressbooktests.cpp: In function ‘void {anonymous}::TestAddAddressesToSendBook()’:
qt/test/addressbooktests.cpp:109:24: warning: unused variable ‘addressTableModel’ [-Wunused-variable]
AddressTableModel* addressTableModel = walletModel.getAddressTableModel();
^
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.
Good catch, thanks.
src/Makefile.qttest.include
Outdated
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.
This line is added in the wrong commit (commit Add tests for address book manipulation via EditAddressDialog instead of commit Introduce qt/test/util with a generalized ConfirmMessage). The intermediate commit fails linking.
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 for spotting this.
ba55832 to
2251fdc
Compare
jnewbery
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.
Nearly there!
src/qt/addresstablemodel.h
Outdated
|
|
||
| class AddressTablePriv; | ||
| class WalletModel; | ||
| class CAddressBookData; |
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.
forward declaration unused. Please remove
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.
Good catch, thanks. Will spend some time figuring out a sensible clang-tidy config to catch this sort of stuff.
2251fdc to
41180ac
Compare
|
utACK 41180ac. Good stuff! |
src/qt/editaddressdialog.cpp
Outdated
| "Address \"%1\" already exists as a receiving address with label " | ||
| "\"%2\" and so cannot be added as a sending address."; | ||
| } | ||
| return tr(fmt_str.c_str()).arg(ui->addressEdit->text()).arg(existing_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.
I guess with this, the new translation strings won't end up in the auto. generated translation source file?
Maybe use the tr().arg() part twice above or use the QT_TR_NOOP() (http://doc.qt.io/qt-5/qtglobal.html#QT_TR_NOOP)?
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.
Good catch, fixed.
41180ac to
2dd9606
Compare
|
Incorporated @jonasschnelli's good feedback about |
|
utACK the change to editaddressdialog.cpp. Not sure about bitcoin_en.ts - is that something that usually gets changed in each commit, or just once before a release? |
|
@jnewbery happy to revert the change to bitcoin_en.ts, but @jonasschnelli seemed to think it'd be best to squash them in. The documentation on translation also seems to suggest that the EN locale file should be changed in tandem with QT strings:
|
2dd9606 to
e6e1da3
Compare
|
Reverted EN locale changes per @jonasschnelli's advice on IRC. |
|
utACK e6e1da33783408182e52fa73a11b6559ee0022f7 |
jonasschnelli
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 e6e1da33783408182e52fa73a11b6559ee0022f7
|
Any other feedback here? |
Also make all arguments to getAddress required and document args at call sites.
Addresses bitcoin#12796. When we're unable to add a sending address to the address book because it already exists as a receiving address, display a message indicating as much. This should help avoid confusion about an address supposedly already in the book but which isn't currently visible in the interface.
ConfirmMessage is reused in future tests apart from its single usage here.
…ialog Also modifies corresponding QT code to allow for use within test cases.
e6e1da3 to
5109fc4
Compare
|
utACK 5109fc4 |
…ests 5109fc4 [tests] [qt] Add tests for address book manipulation via EditAddressDialog (James O'Beirne) 9c01be1 [tests] [qt] Introduce qt/test/util with a generalized ConfirmMessage (James O'Beirne) 8cdcaee [qt] Display more helpful message when adding a send address has failed (James O'Beirne) c5b2770 Add purpose arg to Wallet::getAddress (James O'Beirne) Pull request description: Addresses #12796. When a user attempts to add to the address book a sending address which is already present as a receiving address, they're presented with a confusing error indicating the address is already present in the book, despite the fact that this row is currently invisible.  This change adds a more specific error message indicating its existence as a receiving address (as discussed in the linked issue).  This change also adds some tests exercising use of the address book via QT. Adding so much test code for such a trivial change may seem weird, but it's my hope that this will make further test-writing for address book usage (and other QT features) more approachable. Tree-SHA512: fbdd5564f7a9a2380bbe437f3378e8d4d5fd9201efff4879b72bc23f2cc1c2eecaf2b811994c25070ee052422e48e47901787c2e62cc584774a997fe6a2a327a
jimpo
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.
In commit [tests] [qt] Introduce qt/test/util with a generalized ConfirmMessage, new files are missing copyright notice headers.
I tried testing manually. The error message when adding a new address works as expected. However, when editing an existing address book entry and changing the address, the behavior is pretty funky. If the address was previously in the address book, it will close the dialog and do nothing, displaying no error. If it is not in the address book, it will edit the entry but also change the label to the address, despite the label in the form not changing.
|
|
||
| bool isMultiwallet(); | ||
|
|
||
| AddressTableModel* getAddressTableModel() const { return addressTableModel; } |
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.
commit: [tests] [qt] Add tests for address book manipulation via EditAddressDialog
This method is already defined on line 139 but without const. I think the non-const variant is actually better because it returns a non-const pointer. (While technically allowed, it feels wrong to me to return a non-const pointer to a member from a const method).
| bool firstRun; | ||
| wallet.LoadWallet(firstRun); | ||
|
|
||
| auto build_address = [&wallet]() { |
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.
commit: [tests] [qt] Add tests for address book manipulation via EditAddressDialog
nit: Any particular reason for this to be a lambda expression instead of a regular function in the anonymous namespace?
| wallet.SetAddressBook(s_key_dest, s_label.toStdString(), "send"); | ||
| } | ||
|
|
||
| auto check_addbook_size = [&wallet](int expected_size) { |
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.
nit: Also could be a regular function.
| check_addbook_size(2); | ||
|
|
||
| // Initialize relevant QT models. | ||
| std::unique_ptr<const PlatformStyle> platformStyle(PlatformStyle::instantiate("other")); |
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.
commit: [tests] [qt] Add tests for address book manipulation via EditAddressDialog
nit: camelCase vs snake_case of local variables in this function is inconsistent (r_key_dest vs platformStyle). I think snake_case is preferred for new code.
…, add tests 5109fc4 [tests] [qt] Add tests for address book manipulation via EditAddressDialog (James O'Beirne) 9c01be1 [tests] [qt] Introduce qt/test/util with a generalized ConfirmMessage (James O'Beirne) 8cdcaee [qt] Display more helpful message when adding a send address has failed (James O'Beirne) c5b2770 Add purpose arg to Wallet::getAddress (James O'Beirne) Pull request description: Addresses bitcoin#12796. When a user attempts to add to the address book a sending address which is already present as a receiving address, they're presented with a confusing error indicating the address is already present in the book, despite the fact that this row is currently invisible.  This change adds a more specific error message indicating its existence as a receiving address (as discussed in the linked issue).  This change also adds some tests exercising use of the address book via QT. Adding so much test code for such a trivial change may seem weird, but it's my hope that this will make further test-writing for address book usage (and other QT features) more approachable. Tree-SHA512: fbdd5564f7a9a2380bbe437f3378e8d4d5fd9201efff4879b72bc23f2cc1c2eecaf2b811994c25070ee052422e48e47901787c2e62cc584774a997fe6a2a327a
Addresses #12796.
When a user attempts to add to the address book a sending address which is already present as a receiving address, they're presented with a confusing error indicating the address is already present in the book, despite the fact that this row is currently invisible.
This change adds a more specific error message indicating its existence as a receiving address (as discussed in the linked issue).
This change also adds some tests exercising use of the address book via QT. Adding so much test code for such a trivial change may seem weird, but it's my hope that this will make further test-writing for address book usage (and other QT features) more approachable.