mirror of
https://github.com/logos-blockchain/lez-programs.git
synced 2026-07-23 15:23:16 +00:00
fix(wallet): release completed snapshot state
This commit is contained in:
parent
3508bfbf42
commit
0ef3c21fd3
@ -581,7 +581,7 @@ void LogosWalletProvider::loadSnapshotAsync(quint64 generation, SnapshotCallback
|
||||
}
|
||||
|
||||
auto finishOne = std::make_shared<std::function<void()>>();
|
||||
*finishOne = [this, generation, state, finishOne]() mutable {
|
||||
*finishOne = [this, generation, state]() mutable {
|
||||
if (generation != m_generation || --state->remaining > 0)
|
||||
return;
|
||||
for (qsizetype index = 0;
|
||||
|
||||
@ -8,6 +8,8 @@
|
||||
#include <QTimer>
|
||||
#include <QtTest>
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "FakeWalletProvider.h"
|
||||
#include "LogosWalletProvider.h"
|
||||
#include "WalletAccountModel.h"
|
||||
@ -61,6 +63,7 @@ private slots:
|
||||
void controllerOwnsUiWalletFlow();
|
||||
void controllerOpenDoesNotWaitForWalletSync();
|
||||
void controllerStopsReachabilityChecksAfterDisconnect();
|
||||
void completedAsyncSnapshotReleasesCallback();
|
||||
};
|
||||
|
||||
void LogosWalletProviderTest::adoptsOpenWalletAndCachesSnapshots()
|
||||
@ -478,6 +481,29 @@ void LogosWalletProviderTest::controllerStopsReachabilityChecksAfterDisconnect()
|
||||
settings.clear();
|
||||
}
|
||||
|
||||
void LogosWalletProviderTest::completedAsyncSnapshotReleasesCallback()
|
||||
{
|
||||
LogosModules modules;
|
||||
modules.logos_execution_zone.sequencerAddress = QStringLiteral("http://sequencer");
|
||||
LogosWalletProvider provider(&modules);
|
||||
QVERIFY(provider.connect({}).ok());
|
||||
|
||||
bool completed = false;
|
||||
std::weak_ptr<int> callbackLifetime;
|
||||
{
|
||||
auto lifetime = std::make_shared<int>(1);
|
||||
callbackLifetime = lifetime;
|
||||
provider.snapshotAsync(true,
|
||||
[lifetime = std::move(lifetime), &completed](WalletSnapshot snapshot) {
|
||||
QVERIFY(snapshot.ok());
|
||||
completed = true;
|
||||
});
|
||||
}
|
||||
|
||||
QVERIFY(completed);
|
||||
QVERIFY(callbackLifetime.expired());
|
||||
}
|
||||
|
||||
QTEST_GUILESS_MAIN(LogosWalletProviderTest)
|
||||
|
||||
#include "LogosWalletProviderTest.moc"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user