2022-07-04 21:14:13 +00:00
|
|
|
#include "ServiceMock.h"
|
|
|
|
|
|
|
|
#include <Constants.h>
|
2022-10-19 13:41:53 +00:00
|
|
|
#include <IOTestHelpers.h>
|
2022-07-04 21:14:13 +00:00
|
|
|
|
2022-07-07 18:16:59 +00:00
|
|
|
#include <StatusGo/Accounts/Accounts.h>
|
|
|
|
|
2022-07-04 21:14:13 +00:00
|
|
|
#include <Onboarding/Accounts/AccountsService.h>
|
2022-07-07 18:16:59 +00:00
|
|
|
#include <Onboarding/Common/Constants.h>
|
2022-07-04 21:14:13 +00:00
|
|
|
|
|
|
|
#include <gtest/gtest.h>
|
|
|
|
|
|
|
|
namespace Testing = Status::Testing;
|
|
|
|
namespace Onboarding = Status::Onboarding;
|
|
|
|
|
|
|
|
namespace fs = std::filesystem;
|
|
|
|
|
2022-10-19 13:41:53 +00:00
|
|
|
namespace Status::Testing
|
|
|
|
{
|
2022-07-04 21:14:13 +00:00
|
|
|
|
2022-07-07 18:16:59 +00:00
|
|
|
class AccountsService : public ::testing::Test
|
2022-07-04 21:14:13 +00:00
|
|
|
{
|
|
|
|
protected:
|
|
|
|
std::unique_ptr<Onboarding::AccountsService> m_accountsService;
|
|
|
|
std::unique_ptr<Testing::AutoCleanTempTestDir> m_fusedTestFolder;
|
|
|
|
|
2022-10-19 13:41:53 +00:00
|
|
|
void SetUp() override
|
|
|
|
{
|
2022-07-07 18:16:59 +00:00
|
|
|
m_fusedTestFolder = std::make_unique<Testing::AutoCleanTempTestDir>("TestAccountsService");
|
2022-07-04 21:14:13 +00:00
|
|
|
m_accountsService = std::make_unique<Onboarding::AccountsService>();
|
|
|
|
m_accountsService->init(m_fusedTestFolder->tempFolder() / Constants::statusGoDataDirName);
|
|
|
|
}
|
|
|
|
|
2022-10-19 13:41:53 +00:00
|
|
|
void TearDown() override
|
|
|
|
{
|
2022-07-04 21:14:13 +00:00
|
|
|
m_fusedTestFolder.reset();
|
|
|
|
m_accountsService.reset();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2022-07-07 18:16:59 +00:00
|
|
|
TEST_F(AccountsService, GeneratedAccounts)
|
2022-07-04 21:14:13 +00:00
|
|
|
{
|
|
|
|
auto genAccounts = m_accountsService->generatedAccounts();
|
|
|
|
|
|
|
|
ASSERT_EQ(5, genAccounts.size());
|
|
|
|
|
|
|
|
for(const auto& acc : genAccounts)
|
|
|
|
{
|
|
|
|
ASSERT_STRNE(qUtf8Printable(acc.id), "");
|
|
|
|
ASSERT_STRNE(qUtf8Printable(acc.publicKey), "");
|
|
|
|
ASSERT_STRNE(qUtf8Printable(acc.address), "");
|
|
|
|
ASSERT_STRNE(qUtf8Printable(acc.keyUid), "");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-10-19 13:41:53 +00:00
|
|
|
TEST_F(
|
|
|
|
AccountsService,
|
|
|
|
DISABLED_GenerateAlias) // temporary disabled till we see what's happening on the status-go side since it doesn't return aliases for any pk
|
2022-07-04 21:14:13 +00:00
|
|
|
{
|
2022-10-19 13:41:53 +00:00
|
|
|
QString testPubKey =
|
|
|
|
"0x04487f44bac3e90825bfa9720148308cb64835bebb7e888f519cebc127223187067629f8b70d0661a35d4af6516b225286";
|
2022-07-04 21:14:13 +00:00
|
|
|
|
|
|
|
auto alias = m_accountsService->generateAlias(testPubKey);
|
|
|
|
|
|
|
|
ASSERT_NE(alias, QString(""));
|
|
|
|
}
|
|
|
|
|
2022-10-19 13:41:53 +00:00
|
|
|
} // namespace Status::Testing
|