diff --git a/src/qt/test/wallettests.cpp b/src/qt/test/wallettests.cpp --- a/src/qt/test/wallettests.cpp +++ b/src/qt/test/wallettests.cpp @@ -29,14 +29,18 @@ #include namespace { -//! Press "Yes" button in modal send confirmation dialog. -void ConfirmSend() { - QTimer::singleShot(0, Qt::PreciseTimer, []() { +//! Press "Yes" or "Cancel" buttons in modal send confirmation dialog. +void ConfirmSend(QString *text = nullptr, bool cancel = false) { + QTimer::singleShot(0, Qt::PreciseTimer, [text, cancel]() { for (QWidget *widget : QApplication::topLevelWidgets()) { if (widget->inherits("SendConfirmationDialog")) { SendConfirmationDialog *dialog = qobject_cast(widget); - QAbstractButton *button = dialog->button(QMessageBox::Yes); + if (text) { + *text = dialog->text(); + } + QAbstractButton *button = dialog->button( + cancel ? QMessageBox::Cancel : QMessageBox::Yes); button->setEnabled(true); button->click(); } @@ -107,10 +111,12 @@ } #endif - // Set up wallet and chain with 101 blocks (1 mature block for spending). + // Set up wallet and chain with 105 blocks (5 mature blocks for spending). TestChain100Setup test; - test.CreateAndProcessBlock( - {}, GetScriptForRawPubKey(test.coinbaseKey.GetPubKey())); + for (int i = 0; i < 5; ++i) { + test.CreateAndProcessBlock( + {}, GetScriptForRawPubKey(test.coinbaseKey.GetPubKey())); + } bitdb.MakeMock(); std::unique_ptr dbw( new CWalletDBWrapper(&bitdb, "wallet_test.dat")); @@ -140,12 +146,12 @@ // Send two transactions, and verify they are added to transaction list. TransactionTableModel *transactionTableModel = walletModel.getTransactionTableModel(); - QCOMPARE(transactionTableModel->rowCount({}), 101); + QCOMPARE(transactionTableModel->rowCount({}), 105); uint256 txid1 = SendCoins(wallet, sendCoinsDialog, CTxDestination(CKeyID()), 5 * COIN); uint256 txid2 = SendCoins(wallet, sendCoinsDialog, CTxDestination(CKeyID()), 10 * COIN); - QCOMPARE(transactionTableModel->rowCount({}), 103); + QCOMPARE(transactionTableModel->rowCount({}), 107); QVERIFY(FindTx(*transactionTableModel, txid1).isValid()); QVERIFY(FindTx(*transactionTableModel, txid2).isValid()); diff --git a/src/qt/transactionview.cpp b/src/qt/transactionview.cpp --- a/src/qt/transactionview.cpp +++ b/src/qt/transactionview.cpp @@ -415,7 +415,7 @@ abandonAction->setEnabled(model->transactionCanBeAbandoned(txid)); if (index.isValid()) { - contextMenu->exec(QCursor::pos()); + contextMenu->popup(transactionView->viewport()->mapToGlobal(point)); } }