Skip to content

Commit

Permalink
quick test for push tx import
Browse files Browse the repository at this point in the history
  • Loading branch information
anatolse committed Dec 13, 2023
1 parent 5b50af3 commit 461c301
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
7 changes: 5 additions & 2 deletions wallet/core/wallet_db.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1319,7 +1319,7 @@ namespace beam::wallet

CreateAddressesTable(db, LASER_ADDRESSES_NAME);

LOG_INFO() << "Create laser tables";
LOG_DEBUG() << "Create laser tables";
}

void CreateAssetsTable(sqlite3* db)
Expand Down Expand Up @@ -4141,7 +4141,10 @@ namespace beam::wallet
storage::setTxParameter(*this, p.m_txId, TxParameterID::MinHeight, p.m_minHeight, false);
}
storage::setTxParameter(*this, p.m_txId, TxParameterID::PeerAddr, p.m_peerAddr, false);
storage::setTxParameter(*this, p.m_txId, TxParameterID::MyAddr, p.m_myAddr, false);
if (p.m_myAddr != Zero)
{
storage::setTxParameter(*this, p.m_txId, TxParameterID::MyAddr, p.m_myAddr, false);
}
storage::setTxParameter(*this, p.m_txId, TxParameterID::Message, p.m_message, false);
storage::setTxParameter(*this, p.m_txId, TxParameterID::CreateTime, p.m_createTime, false);
storage::setTxParameter(*this, p.m_txId, TxParameterID::ModifyTime, p.m_modifyTime, false);
Expand Down
19 changes: 19 additions & 0 deletions wallet/unittests/wallet_db_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -759,15 +759,34 @@ void TestExportImportTx()
tr2.m_myAddr = wa2.m_BbsAddr;
walletDB->saveTx(tr2); // without MyAddressID

TxDescription tr3( TxID{ {79, 8, 9, 13} }, TxType::PushTransaction ); // lelanatus
tr3.m_amount = 71;
tr3.m_minHeight = 285;
tr3.m_createTime = 4628;
tr3.m_modifyTime = 45285;
tr3.m_status = TxStatus::Completed;
walletDB->saveTx(tr3);

auto exported = storage::ExportDataToJson(*walletDB);
walletDB->deleteTx(tr.m_txId);
WALLET_CHECK(walletDB->getTxHistory().size() == 1);
WALLET_CHECK(walletDB->getTxHistory(TxType::PushTransaction).size() == 1);
WALLET_CHECK(storage::ImportDataFromJson(*walletDB, &exported[0], exported.size()));
auto _tr = walletDB->getTx(tr.m_txId);
WALLET_CHECK(_tr.is_initialized());
WALLET_CHECK(_tr.value().m_createTime == tr.m_createTime);
WALLET_CHECK(_tr.value().m_minHeight == tr.m_minHeight);
WALLET_CHECK(walletDB->getTxHistory().size() == 2);
WALLET_CHECK(walletDB->getTxHistory(TxType::PushTransaction).size() == 1);

walletDB->deleteTx(tr.m_txId);
walletDB->deleteTx(tr2.m_txId);
walletDB->deleteTx(tr3.m_txId);
WALLET_CHECK(walletDB->getTxHistory().size() == 0);
WALLET_CHECK(walletDB->getTxHistory(TxType::PushTransaction).size() == 0);
WALLET_CHECK(storage::ImportDataFromJson(*walletDB, &exported[0], exported.size()));
WALLET_CHECK(walletDB->getTxHistory().size() == 2);
WALLET_CHECK(walletDB->getTxHistory(TxType::PushTransaction).size() == 1);

storage::setTxParameter(
*walletDB,
Expand Down

0 comments on commit 461c301

Please sign in to comment.