Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/spark/sparkwallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,17 @@ void CSparkWallet::FinishTasks() {
}
}

void CSparkWallet::WaitForPendingTasks() {
if (!threadPool)
return;

auto* pool = (ParallelOpThreadPool<void>*)threadPool;
if (pool->IsPoolShutdown())
return;

pool->PostTask([]() {}).wait();
Comment thread
coderabbitai[bot] marked this conversation as resolved.
}

void CSparkWallet::resetDiversifierFromDB(CWalletDB& walletdb) {
LOCK(cs_spark_wallet);
walletdb.readDiversifier(lastDiversifier);
Expand Down
2 changes: 2 additions & 0 deletions src/spark/sparkwallet.h
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,8 @@ class CSparkWallet {
// Returns the list of pairs of coins and metadata for that coin,
std::list<CSparkMintMeta> GetAvailableSparkCoins(const CCoinControl *coinControl = NULL) const;

/** Wait for all Spark wallet tasks queued before this call. */
void WaitForPendingTasks();
void FinishTasks();

public:
Expand Down
5 changes: 3 additions & 2 deletions src/test/fixtures.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include "ui_interface.h"
#include "rpc/server.h"
#include "rpc/register.h"
#include "spark/state.h"

#include "test/testutil.h"
#include "test/fixtures.h"
Expand Down Expand Up @@ -313,5 +314,5 @@ CTransaction SparkTestingSetup::GenerateSparkSpend(

SparkTestingSetup::~SparkTestingSetup()
{
pwalletMain->sparkWallet->FinishTasks();
}
spark::CSparkState::GetState()->Reset();

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggestion: Reset() leaves ltagTxhash and extendedMintMetaInfo populated, so later Spark tests can inherit stale global indexes despite this fixture cleanup. [stale reference]

Assessment: 🟠 Major · 🔁 Occurrence: Sometimes

Use CodeAnt Skill Fix in Cursor Fix in VSCode Claude

Prompt for AI Agent 🤖
This is a comment left during a code review.

**Path:** src/test/fixtures.cpp
**Line:** 317:317
**Comment:**
	*Stale Reference: `Reset()` leaves `ltagTxhash` and `extendedMintMetaInfo` populated, so later Spark tests can inherit stale global indexes despite this fixture cleanup.

Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix
👍 | 👎

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 correct, but preexisting and not related to this. Will send separate pr.

}
Comment thread
navidR marked this conversation as resolved.
3 changes: 3 additions & 0 deletions src/test/spark_mintspend_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ BOOST_AUTO_TEST_CASE(spark_mintspend_test)
BOOST_CHECK_MESSAGE(mempool.size() == 0, "Mempool not cleared");
GenerateBlocks(2);

// Block and mempool updates reach the Spark wallet asynchronously. Drain
// them before deliberately rewinding the wallet and chain spend state.
pwalletMain->sparkWallet->WaitForPendingTasks();
auto tempTags = sparkState->usedLTags;
sparkState->usedLTags.clear();

Expand Down
Loading