Coloured coin GUI test#207
Conversation
58fc682 to
3eeac5b
Compare
661ef30 to
391c33d
Compare
391c33d to
0d046a3
Compare
- wallettests.cpp: add TestGUI_coloredCoin covering token issue, transfer and burn for NFT, reissuable and non-reissuable token types end-to-end. - src/qt/test/CMakeLists.txt: register the new test; add import_plugins() to statically link Qt6::QMinimalIntegrationPlugin (and QXcbIntegrationPlugin on Linux) so the test binary has a platform plugin available at runtime. - src/qt/CMakeLists.txt: add callback.h to tapyrusqt library sources (required by wallettests.cpp); rename BUILD_GUI_TESTS -> ENABLE_GUI_TESTS. - .github/workflows/daily-test.yml: switch QT_QPA_PLATFORM from offscreen to minimal, matching the plugin linked above. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
0d046a3 to
e011590
Compare
| for (unsigned int i = 0; i < wtx.tx->vout.size(); i++) { | ||
| if (!wtx.txout_color_id[i].empty()) | ||
| allColorHexes.insert(wtx.txout_color_id[i]); | ||
| } |
There was a problem hiding this comment.
This loop is unnecessary since we have already iterated through all colored outputs in the tokenCredit loop (lines 193-196).
| if (wtx.txout_color_id[i].empty()) continue; | ||
| if (wtx.txout_is_mine[i] != ISMINE_NO) | ||
| tokenCredit[wtx.txout_color_id[i]] += wtx.tx->vout[i].nValue; | ||
| tokenCredit[wtx.txout_color_id[i]] += wtx.tx->vout[i].nValue; |
There was a problem hiding this comment.
In transactionrecord.cpp, removing the ISMINE_NO check on line 197 changes the code path for send transactions:
Before: creditAmt = 20 (change only), netAmt = -80 → falls into else if (debitAmt > 0) branch → tokenAmount = -80
After: creditAmt = 100 (all outputs), netAmt = 0 → falls into netAmt == 0 branch → tokenAmount = +80
The sign of tokenAmount flips from negative to positive for sends. Is this intentional? If so, it might be worth adding a test assertion to verify the expected tokenAmount value (e.g., checking that a send of 30 tokens shows tokenAmount = 30).
There was a problem hiding this comment.
This was added to identify the token issue and token burn transactions properly. Whether or not the output belongs to us, we include it in the total credit calculation. Then token issue is tokenCredit > 0 and tokenDebit =0 and burn is tokenCredit < tokenDebit. However I hadn't noticed that it flipped the amount in the case of token transfers. I'll check.
azuchi
left a comment
There was a problem hiding this comment.
I have a few remaining items:
Outstanding Items
1. Redundant loop (unaddressed from previous review)
The explicit loop at transactionrecord.cpp:208-211:
for (unsigned int i = 0; i < wtx.tx->vout.size(); i++) {
if (!wtx.txout_color_id[i].empty())
allColorHexes.insert(wtx.txout_color_id[i]);
}is redundant. Since the ISMINE_NO check was removed at line 197, tokenCredit now contains every colored output already, so the immediately preceding for (const auto& e : tokenCredit) allColorHexes.insert(e.first) covers it. Please remove this loop.
2. Add tokenAmount value assertion in tests
The sign-flip fix is not covered by the test suite. checkLatestTx only verifies the record type (e.g., SendToAddress), not the tokenAmount value. A regression that re-flips the sign or zeroes out the amount would pass silently.
Please extend the helper, e.g.:
checkLatestTx(TransactionRecord::SendToAddress, cid, /*expectedAmount=*/-30);and assert the expected signed value for at least the issue / send / burn cases.
3. Add an external-recipient transfer test
All current tests use getColoredAddress(cid) (self-transfer). The code path that the sign fix actually corrects — sending to a non-wallet recipient — is not exercised. Please add at least one case sending to an address owned by a separate CWallet instance and verify the sender side records tokenAmount = - and type SendToAddress.
4. (Optional) Clarify isIssue to match the stated intent
In your earlier reply you described the intent as "issue = tokenCredit > 0 && tokenDebit == 0". The current expression goes through netAmt:
bool isIssue = (netAmt > 0 && fAllFromMe && !isBurn); Rewriting it to mirror the stated invariant directly would make the logic easier to read and harder to break in future edits:
bool isIssue = (debitAmt == 0 && colorOutputTotal > 0 && fAllFromMe);The !isBurn guard becomes unnecessary because debitAmt == 0 already excludes burns.
Items 1–3 are blocking; item 4 is a nice-to-have. Once items 1–3 are addressed, this is good to merge.
… it could vary in consecutive calls. This difference seems to have started after the GUI fix to report IBD progress
…rison in token amount, remove redundant loop and improve isIssue detection logic
For each type of token this test does:
Receive / payment request (using the surviving REISSUABLE token)