mirror of
https://github.com/logos-blockchain/lez-programs.git
synced 2026-07-21 14:29:41 +00:00
fix(wallet): report partial creation failures
This commit is contained in:
parent
9c4ade7237
commit
c5e4231890
@ -178,17 +178,22 @@ QString WalletController::createWallet(const QString& configPath,
|
||||
|
||||
m_state.configPath = config;
|
||||
m_state.storagePath = storage;
|
||||
m_state.walletExists = true;
|
||||
QSettings(SETTINGS_ORG, m_settingsApplication).setValue(DISCONNECTED_KEY, false);
|
||||
if (!creation.ok()) {
|
||||
qWarning() << "WalletController: wallet creation failed"
|
||||
<< walletFailureCode(creation.failure);
|
||||
m_state.walletExists = QFileInfo::exists(storage);
|
||||
m_state.isWalletOpen = false;
|
||||
m_state.syncStatus = QStringLiteral("error");
|
||||
m_state.syncError = walletFailureCode(creation.failure);
|
||||
emit stateChanged();
|
||||
return creation.mnemonic;
|
||||
}
|
||||
|
||||
m_state.walletExists = true;
|
||||
m_state.isWalletOpen = true;
|
||||
m_state.syncStatus = QStringLiteral("ready");
|
||||
m_state.syncError.clear();
|
||||
applySnapshot(creation.snapshot);
|
||||
return creation.mnemonic;
|
||||
}
|
||||
|
||||
@ -70,6 +70,7 @@ private slots:
|
||||
void deferredCallbacksIgnoreDestroyedController();
|
||||
void newerReachabilityResultWins();
|
||||
void coalescesReachabilityChecksForSameEndpoint();
|
||||
void controllerReportsPartialWalletCreation();
|
||||
};
|
||||
|
||||
void LogosWalletProviderTest::adoptsOpenWalletAndCachesSnapshots()
|
||||
@ -615,6 +616,25 @@ void LogosWalletProviderTest::coalescesReachabilityChecksForSameEndpoint()
|
||||
settings.clear();
|
||||
}
|
||||
|
||||
void LogosWalletProviderTest::controllerReportsPartialWalletCreation()
|
||||
{
|
||||
const QString settingsApplication = QStringLiteral("WalletPartialCreationTest");
|
||||
QSettings settings(QStringLiteral("Logos"), settingsApplication);
|
||||
settings.clear();
|
||||
|
||||
FakeWalletProvider provider;
|
||||
provider.createWalletResult.mnemonic = QStringLiteral("one two three");
|
||||
provider.createWalletResult.failure = WalletFailure::SaveFailed;
|
||||
WalletController controller(provider, settingsApplication);
|
||||
|
||||
QCOMPARE(controller.createDefaultWallet(QStringLiteral("secret")),
|
||||
provider.createWalletResult.mnemonic);
|
||||
QVERIFY(!controller.state().isWalletOpen);
|
||||
QCOMPARE(controller.state().syncStatus, QStringLiteral("error"));
|
||||
QCOMPARE(controller.state().syncError, QStringLiteral("save_failed"));
|
||||
settings.clear();
|
||||
}
|
||||
|
||||
QTEST_GUILESS_MAIN(LogosWalletProviderTest)
|
||||
|
||||
#include "LogosWalletProviderTest.moc"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user