Skip to content

Coloured coin GUI test#207

Merged
azuchi merged 5 commits intochaintope:masterfrom
Naviabheeman:77_ColoredCoinGUI_6
Apr 27, 2026
Merged

Coloured coin GUI test#207
azuchi merged 5 commits intochaintope:masterfrom
Naviabheeman:77_ColoredCoinGUI_6

Conversation

@Naviabheeman
Copy link
Copy Markdown
Contributor

@Naviabheeman Naviabheeman commented Jun 22, 2022

For each type of token this test does:

  • Issue → check IssueTokenDialog table shows type/balance, OverviewPage balance , transaction record = TokenIssue
  • Send to own address -> check balance, transaction = SendToAddress
  • Burn -> check balance, transaction = TokenBurn
  • Reissue token -> check balance, transaction = TokenIssue
  • Verify that then token is removed from OverviewPage combo and token table when the balance is 0

Receive / payment request (using the surviving REISSUABLE token)

  • Switch ReceiveCoinsDialog to token mode, select the token, enter label/amount/message
  • Click Receive → verify the payment info popup shows correct URI, token colorId, amount, label, message
  • Verify entry added to requested-payments table
  • Click Clear → inputs reset, token combo disabled
  • Remove the entry → row count decreases

@Naviabheeman Naviabheeman force-pushed the 77_ColoredCoinGUI_6 branch 3 times, most recently from 58fc682 to 3eeac5b Compare March 31, 2026 16:21
@Naviabheeman Naviabheeman requested a review from azuchi March 31, 2026 16:36
@Naviabheeman Naviabheeman force-pushed the 77_ColoredCoinGUI_6 branch 2 times, most recently from 661ef30 to 391c33d Compare April 8, 2026 12:41
@Naviabheeman Naviabheeman force-pushed the 77_ColoredCoinGUI_6 branch from 391c33d to 0d046a3 Compare April 9, 2026 16:27
Naviabheeman and others added 2 commits April 10, 2026 11:42
- 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>
Comment thread src/qt/transactionrecord.cpp Outdated
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]);
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Contributor

@azuchi azuchi left a comment

Choose a reason for hiding this comment

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

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
@azuchi azuchi merged commit 10affd6 into chaintope:master Apr 27, 2026
14 of 20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants