Changeset View
Changeset View
Standalone View
Standalone View
src/qt/test/wallettests.cpp
Show First 20 Lines • Show All 136 Lines • ▼ Show 20 Lines | #endif | ||||
wallet.SetBroadcastTransactions(true); | wallet.SetBroadcastTransactions(true); | ||||
// Create widgets for sending coins and listing transactions. | // Create widgets for sending coins and listing transactions. | ||||
std::unique_ptr<const PlatformStyle> platformStyle( | std::unique_ptr<const PlatformStyle> platformStyle( | ||||
PlatformStyle::instantiate("other")); | PlatformStyle::instantiate("other")); | ||||
SendCoinsDialog sendCoinsDialog(platformStyle.get()); | SendCoinsDialog sendCoinsDialog(platformStyle.get()); | ||||
auto node = interfaces::MakeNode(); | auto node = interfaces::MakeNode(); | ||||
OptionsModel optionsModel(*node); | OptionsModel optionsModel(*node); | ||||
WalletModel walletModel(platformStyle.get(), &wallet, &optionsModel); | vpwallets.insert(vpwallets.begin(), &wallet); | ||||
WalletModel walletModel(std::move(node->getWallets()[0]), *node, | |||||
platformStyle.get(), &wallet, &optionsModel); | |||||
vpwallets.erase(vpwallets.begin()); | |||||
sendCoinsDialog.setModel(&walletModel); | sendCoinsDialog.setModel(&walletModel); | ||||
// Send two transactions, and verify they are added to transaction list. | // Send two transactions, and verify they are added to transaction list. | ||||
TransactionTableModel *transactionTableModel = | TransactionTableModel *transactionTableModel = | ||||
walletModel.getTransactionTableModel(); | walletModel.getTransactionTableModel(); | ||||
QCOMPARE(transactionTableModel->rowCount({}), 105); | QCOMPARE(transactionTableModel->rowCount({}), 105); | ||||
uint256 txid1 = | uint256 txid1 = | ||||
SendCoins(wallet, sendCoinsDialog, CTxDestination(CKeyID()), 5 * COIN); | SendCoins(wallet, sendCoinsDialog, CTxDestination(CKeyID()), 5 * COIN); | ||||
uint256 txid2 = | uint256 txid2 = | ||||
SendCoins(wallet, sendCoinsDialog, CTxDestination(CKeyID()), 10 * COIN); | SendCoins(wallet, sendCoinsDialog, CTxDestination(CKeyID()), 10 * COIN); | ||||
QCOMPARE(transactionTableModel->rowCount({}), 107); | QCOMPARE(transactionTableModel->rowCount({}), 107); | ||||
QVERIFY(FindTx(*transactionTableModel, txid1).isValid()); | QVERIFY(FindTx(*transactionTableModel, txid1).isValid()); | ||||
QVERIFY(FindTx(*transactionTableModel, txid2).isValid()); | QVERIFY(FindTx(*transactionTableModel, txid2).isValid()); | ||||
// Check current balance on OverviewPage | // Check current balance on OverviewPage | ||||
OverviewPage overviewPage(platformStyle.get()); | OverviewPage overviewPage(platformStyle.get()); | ||||
overviewPage.setWalletModel(&walletModel); | overviewPage.setWalletModel(&walletModel); | ||||
QLabel *balanceLabel = overviewPage.findChild<QLabel *>("labelBalance"); | QLabel *balanceLabel = overviewPage.findChild<QLabel *>("labelBalance"); | ||||
QString balanceText = balanceLabel->text(); | QString balanceText = balanceLabel->text(); | ||||
int unit = walletModel.getOptionsModel()->getDisplayUnit(); | int unit = walletModel.getOptionsModel()->getDisplayUnit(); | ||||
Amount balance = walletModel.getBalance(); | Amount balance = walletModel.wallet().getBalance(); | ||||
QString balanceComparison = BitcoinUnits::formatWithUnit( | QString balanceComparison = BitcoinUnits::formatWithUnit( | ||||
unit, balance, false, BitcoinUnits::separatorAlways); | unit, balance, false, BitcoinUnits::separatorAlways); | ||||
QCOMPARE(balanceText, balanceComparison); | QCOMPARE(balanceText, balanceComparison); | ||||
// Check Request Payment button | // Check Request Payment button | ||||
const Config &config = GetConfig(); | const Config &config = GetConfig(); | ||||
ReceiveCoinsDialog receiveCoinsDialog(platformStyle.get(), &config); | ReceiveCoinsDialog receiveCoinsDialog(platformStyle.get(), &config); | ||||
receiveCoinsDialog.setModel(&walletModel); | receiveCoinsDialog.setModel(&walletModel); | ||||
▲ Show 20 Lines • Show All 71 Lines • Show Last 20 Lines |