mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-04-04 04:45:10 +02:00
Pass NodeContext, ConnMan, BanMan references more places
So g_connman and g_banman globals can be removed next commit.
This commit is contained in:
@@ -51,11 +51,10 @@ void EditAddressAndSubmit(
|
||||
* In each case, verify the resulting state of the address book and optionally
|
||||
* the warning message presented to the user.
|
||||
*/
|
||||
void TestAddAddressesToSendBook()
|
||||
void TestAddAddressesToSendBook(interfaces::Node& node)
|
||||
{
|
||||
TestChain100Setup test;
|
||||
auto chain = interfaces::MakeChain();
|
||||
std::shared_ptr<CWallet> wallet = std::make_shared<CWallet>(chain.get(), WalletLocation(), WalletDatabase::CreateMock());
|
||||
std::shared_ptr<CWallet> wallet = std::make_shared<CWallet>(node.context()->chain.get(), WalletLocation(), WalletDatabase::CreateMock());
|
||||
bool firstRun;
|
||||
wallet->LoadWallet(firstRun);
|
||||
|
||||
@@ -101,10 +100,9 @@ void TestAddAddressesToSendBook()
|
||||
|
||||
// Initialize relevant QT models.
|
||||
std::unique_ptr<const PlatformStyle> platformStyle(PlatformStyle::instantiate("other"));
|
||||
auto node = interfaces::MakeNode();
|
||||
OptionsModel optionsModel(*node);
|
||||
OptionsModel optionsModel(node);
|
||||
AddWallet(wallet);
|
||||
WalletModel walletModel(std::move(node->getWallets()[0]), *node, platformStyle.get(), &optionsModel);
|
||||
WalletModel walletModel(interfaces::MakeWallet(wallet), node, platformStyle.get(), &optionsModel);
|
||||
RemoveWallet(wallet);
|
||||
EditAddressDialog editAddressDialog(EditAddressDialog::NewSendingAddress);
|
||||
editAddressDialog.setModel(walletModel.getAddressTableModel());
|
||||
@@ -150,5 +148,5 @@ void AddressBookTests::addressBookTests()
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
TestAddAddressesToSendBook();
|
||||
TestAddAddressesToSendBook(m_node);
|
||||
}
|
||||
|
||||
@@ -4,8 +4,16 @@
|
||||
#include <QObject>
|
||||
#include <QTest>
|
||||
|
||||
namespace interfaces {
|
||||
class Node;
|
||||
} // namespace interfaces
|
||||
|
||||
class AddressBookTests : public QObject
|
||||
{
|
||||
public:
|
||||
AddressBookTests(interfaces::Node& node) : m_node(node) {}
|
||||
interfaces::Node& m_node;
|
||||
|
||||
Q_OBJECT
|
||||
|
||||
private Q_SLOTS:
|
||||
|
||||
@@ -41,7 +41,7 @@ void RPCNestedTests::rpcNestedTests()
|
||||
std::string result;
|
||||
std::string result2;
|
||||
std::string filtered;
|
||||
auto node = interfaces::MakeNode();
|
||||
interfaces::Node* node = &m_node;
|
||||
RPCConsole::RPCExecuteCommandLine(*node, result, "getblockchaininfo()[chain]", &filtered); //simple result filtering with path
|
||||
QVERIFY(result=="main");
|
||||
QVERIFY(filtered == "getblockchaininfo()[chain]");
|
||||
|
||||
@@ -8,8 +8,16 @@
|
||||
#include <QObject>
|
||||
#include <QTest>
|
||||
|
||||
namespace interfaces {
|
||||
class Node;
|
||||
} // namespace interfaces
|
||||
|
||||
class RPCNestedTests : public QObject
|
||||
{
|
||||
public:
|
||||
RPCNestedTests(interfaces::Node& node) : m_node(node) {}
|
||||
interfaces::Node& m_node;
|
||||
|
||||
Q_OBJECT
|
||||
|
||||
private Q_SLOTS:
|
||||
|
||||
@@ -50,7 +50,7 @@ int main(int argc, char *argv[])
|
||||
BasicTestingSetup dummy{CBaseChainParams::REGTEST};
|
||||
}
|
||||
|
||||
auto node = interfaces::MakeNode();
|
||||
std::unique_ptr<interfaces::Node> node = interfaces::MakeNode();
|
||||
|
||||
bool fInvalid = false;
|
||||
|
||||
@@ -76,7 +76,7 @@ int main(int argc, char *argv[])
|
||||
if (QTest::qExec(&test1) != 0) {
|
||||
fInvalid = true;
|
||||
}
|
||||
RPCNestedTests test3;
|
||||
RPCNestedTests test3(*node);
|
||||
if (QTest::qExec(&test3) != 0) {
|
||||
fInvalid = true;
|
||||
}
|
||||
@@ -85,11 +85,11 @@ int main(int argc, char *argv[])
|
||||
fInvalid = true;
|
||||
}
|
||||
#ifdef ENABLE_WALLET
|
||||
WalletTests test5;
|
||||
WalletTests test5(*node);
|
||||
if (QTest::qExec(&test5) != 0) {
|
||||
fInvalid = true;
|
||||
}
|
||||
AddressBookTests test6;
|
||||
AddressBookTests test6(*node);
|
||||
if (QTest::qExec(&test6) != 0) {
|
||||
fInvalid = true;
|
||||
}
|
||||
|
||||
@@ -126,15 +126,14 @@ void BumpFee(TransactionView& view, const uint256& txid, bool expectDisabled, st
|
||||
// QT_QPA_PLATFORM=xcb src/qt/test/test_bitcoin-qt # Linux
|
||||
// QT_QPA_PLATFORM=windows src/qt/test/test_bitcoin-qt # Windows
|
||||
// QT_QPA_PLATFORM=cocoa src/qt/test/test_bitcoin-qt # macOS
|
||||
void TestGUI()
|
||||
void TestGUI(interfaces::Node& node)
|
||||
{
|
||||
// Set up wallet and chain with 105 blocks (5 mature blocks for spending).
|
||||
TestChain100Setup test;
|
||||
for (int i = 0; i < 5; ++i) {
|
||||
test.CreateAndProcessBlock({}, GetScriptForRawPubKey(test.coinbaseKey.GetPubKey()));
|
||||
}
|
||||
auto chain = interfaces::MakeChain();
|
||||
std::shared_ptr<CWallet> wallet = std::make_shared<CWallet>(chain.get(), WalletLocation(), WalletDatabase::CreateMock());
|
||||
std::shared_ptr<CWallet> wallet = std::make_shared<CWallet>(node.context()->chain.get(), WalletLocation(), WalletDatabase::CreateMock());
|
||||
bool firstRun;
|
||||
wallet->LoadWallet(firstRun);
|
||||
{
|
||||
@@ -159,10 +158,9 @@ void TestGUI()
|
||||
std::unique_ptr<const PlatformStyle> platformStyle(PlatformStyle::instantiate("other"));
|
||||
SendCoinsDialog sendCoinsDialog(platformStyle.get());
|
||||
TransactionView transactionView(platformStyle.get());
|
||||
auto node = interfaces::MakeNode();
|
||||
OptionsModel optionsModel(*node);
|
||||
OptionsModel optionsModel(node);
|
||||
AddWallet(wallet);
|
||||
WalletModel walletModel(std::move(node->getWallets().back()), *node, platformStyle.get(), &optionsModel);
|
||||
WalletModel walletModel(interfaces::MakeWallet(wallet), node, platformStyle.get(), &optionsModel);
|
||||
RemoveWallet(wallet);
|
||||
sendCoinsDialog.setModel(&walletModel);
|
||||
transactionView.setModel(&walletModel);
|
||||
@@ -260,5 +258,5 @@ void WalletTests::walletTests()
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
TestGUI();
|
||||
TestGUI(m_node);
|
||||
}
|
||||
|
||||
@@ -4,8 +4,16 @@
|
||||
#include <QObject>
|
||||
#include <QTest>
|
||||
|
||||
namespace interfaces {
|
||||
class Node;
|
||||
} // namespace interfaces
|
||||
|
||||
class WalletTests : public QObject
|
||||
{
|
||||
public:
|
||||
WalletTests(interfaces::Node& node) : m_node(node) {}
|
||||
interfaces::Node& m_node;
|
||||
|
||||
Q_OBJECT
|
||||
|
||||
private Q_SLOTS:
|
||||
|
||||
Reference in New Issue
Block a user