Changeset View
Changeset View
Standalone View
Standalone View
src/qt/test/wallettests.cpp
Show First 20 Lines • Show All 47 Lines • ▼ Show 20 Lines | QTimer::singleShot(0, Qt::PreciseTimer, [text, cancel]() { | ||||
button->setEnabled(true); | button->setEnabled(true); | ||||
button->click(); | button->click(); | ||||
} | } | ||||
} | } | ||||
}); | }); | ||||
} | } | ||||
//! Send coins to address and return txid. | //! Send coins to address and return txid. | ||||
uint256 SendCoins(CWallet &wallet, SendCoinsDialog &sendCoinsDialog, | TxId SendCoins(CWallet &wallet, SendCoinsDialog &sendCoinsDialog, | ||||
const CTxDestination &address, Amount amount) { | const CTxDestination &address, Amount amount) { | ||||
QVBoxLayout *entries = sendCoinsDialog.findChild<QVBoxLayout *>("entries"); | QVBoxLayout *entries = sendCoinsDialog.findChild<QVBoxLayout *>("entries"); | ||||
SendCoinsEntry *entry = | SendCoinsEntry *entry = | ||||
qobject_cast<SendCoinsEntry *>(entries->itemAt(0)->widget()); | qobject_cast<SendCoinsEntry *>(entries->itemAt(0)->widget()); | ||||
entry->findChild<QValidatedLineEdit *>("payTo")->setText( | entry->findChild<QValidatedLineEdit *>("payTo")->setText( | ||||
QString::fromStdString(EncodeCashAddr(address, Params()))); | QString::fromStdString(EncodeCashAddr(address, Params()))); | ||||
entry->findChild<BitcoinAmountField *>("payAmount")->setValue(amount); | entry->findChild<BitcoinAmountField *>("payAmount")->setValue(amount); | ||||
uint256 txid; | TxId txid; | ||||
boost::signals2::scoped_connection c = | boost::signals2::scoped_connection c = | ||||
wallet.NotifyTransactionChanged.connect( | wallet.NotifyTransactionChanged.connect( | ||||
[&txid](CWallet *, const uint256 &hash, ChangeType status) { | [&txid](CWallet *, const TxId &hash, ChangeType status) { | ||||
if (status == CT_NEW) { | if (status == CT_NEW) { | ||||
txid = hash; | txid = hash; | ||||
} | } | ||||
}); | }); | ||||
ConfirmSend(); | ConfirmSend(); | ||||
QMetaObject::invokeMethod(&sendCoinsDialog, "on_sendButton_clicked"); | QMetaObject::invokeMethod(&sendCoinsDialog, "on_sendButton_clicked"); | ||||
return txid; | return txid; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 61 Lines • ▼ Show 20 Lines | WalletModel walletModel(std::move(node->getWallets().back()), *node, | ||||
platformStyle.get(), &optionsModel); | platformStyle.get(), &optionsModel); | ||||
RemoveWallet(&wallet); | RemoveWallet(&wallet); | ||||
// Send two transactions, and verify they are added to transaction list. | // Send two transactions, and verify they are added to transaction list. | ||||
SendCoinsDialog sendCoinsDialog(platformStyle.get(), &walletModel); | SendCoinsDialog sendCoinsDialog(platformStyle.get(), &walletModel); | ||||
TransactionTableModel *transactionTableModel = | TransactionTableModel *transactionTableModel = | ||||
walletModel.getTransactionTableModel(); | walletModel.getTransactionTableModel(); | ||||
QCOMPARE(transactionTableModel->rowCount({}), 105); | QCOMPARE(transactionTableModel->rowCount({}), 105); | ||||
uint256 txid1 = | TxId txid1 = | ||||
SendCoins(wallet, sendCoinsDialog, CTxDestination(CKeyID()), 5 * COIN); | SendCoins(wallet, sendCoinsDialog, CTxDestination(CKeyID()), 5 * COIN); | ||||
uint256 txid2 = | TxId 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); | ||||
▲ Show 20 Lines • Show All 91 Lines • Show Last 20 Lines |