Skip to content

Commit 5baa88f

Browse files
ryanofskyMarcoFalke
and
MarcoFalke
committedDec 8, 2020
test: Remove no longer needed MakeChain calls
These calls are no longer needed after edc3160 from bitcoin#19098 which started instantiating BasicTestingSetup.m_node.chain Patch from MarcoFalke <falke.marco@gmail.com> in bitcoin#19425 (comment) Co-authored-by: MarcoFalke <falke.marco@gmail.com>
1 parent 6965f13 commit 5baa88f

9 files changed

+14
-20
lines changed
 

‎src/test/interfaces_tests.cpp

+6-6
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ BOOST_FIXTURE_TEST_SUITE(interfaces_tests, TestChain100Setup)
1717

1818
BOOST_AUTO_TEST_CASE(findBlock)
1919
{
20-
auto chain = interfaces::MakeChain(m_node);
20+
auto& chain = m_node.chain;
2121
const CChain& active = Assert(m_node.chainman)->ActiveChain();
2222

2323
uint256 hash;
@@ -61,7 +61,7 @@ BOOST_AUTO_TEST_CASE(findBlock)
6161

6262
BOOST_AUTO_TEST_CASE(findFirstBlockWithTimeAndHeight)
6363
{
64-
auto chain = interfaces::MakeChain(m_node);
64+
auto& chain = m_node.chain;
6565
const CChain& active = Assert(m_node.chainman)->ActiveChain();
6666
uint256 hash;
6767
int height;
@@ -73,7 +73,7 @@ BOOST_AUTO_TEST_CASE(findFirstBlockWithTimeAndHeight)
7373

7474
BOOST_AUTO_TEST_CASE(findAncestorByHeight)
7575
{
76-
auto chain = interfaces::MakeChain(m_node);
76+
auto& chain = m_node.chain;
7777
const CChain& active = Assert(m_node.chainman)->ActiveChain();
7878
uint256 hash;
7979
BOOST_CHECK(chain->findAncestorByHeight(active[20]->GetBlockHash(), 10, FoundBlock().hash(hash)));
@@ -83,7 +83,7 @@ BOOST_AUTO_TEST_CASE(findAncestorByHeight)
8383

8484
BOOST_AUTO_TEST_CASE(findAncestorByHash)
8585
{
86-
auto chain = interfaces::MakeChain(m_node);
86+
auto& chain = m_node.chain;
8787
const CChain& active = Assert(m_node.chainman)->ActiveChain();
8888
int height = -1;
8989
BOOST_CHECK(chain->findAncestorByHash(active[20]->GetBlockHash(), active[10]->GetBlockHash(), FoundBlock().height(height)));
@@ -93,7 +93,7 @@ BOOST_AUTO_TEST_CASE(findAncestorByHash)
9393

9494
BOOST_AUTO_TEST_CASE(findCommonAncestor)
9595
{
96-
auto chain = interfaces::MakeChain(m_node);
96+
auto& chain = m_node.chain;
9797
const CChain& active = Assert(m_node.chainman)->ActiveChain();
9898
auto* orig_tip = active.Tip();
9999
for (int i = 0; i < 10; ++i) {
@@ -123,7 +123,7 @@ BOOST_AUTO_TEST_CASE(findCommonAncestor)
123123

124124
BOOST_AUTO_TEST_CASE(hasBlocks)
125125
{
126-
auto chain = interfaces::MakeChain(m_node);
126+
auto& chain = m_node.chain;
127127
const CChain& active = Assert(m_node.chainman)->ActiveChain();
128128

129129
// Test ranges

‎src/wallet/test/coinselector_tests.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ BOOST_AUTO_TEST_CASE(bnb_search_test)
283283
// Make sure that can use BnB when there are preset inputs
284284
empty_wallet();
285285
{
286-
std::unique_ptr<CWallet> wallet = MakeUnique<CWallet>(m_chain.get(), "", CreateMockWalletDatabase());
286+
std::unique_ptr<CWallet> wallet = MakeUnique<CWallet>(m_node.chain.get(), "", CreateMockWalletDatabase());
287287
bool firstRun;
288288
wallet->LoadWallet(firstRun);
289289
wallet->SetupLegacyScriptPubKeyMan();

‎src/wallet/test/init_test_fixture.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
InitWalletDirTestingSetup::InitWalletDirTestingSetup(const std::string& chainName) : BasicTestingSetup(chainName)
1212
{
13-
m_wallet_client = MakeWalletClient(*m_chain, *Assert(m_node.args));
13+
m_wallet_client = MakeWalletClient(*m_node.chain, *Assert(m_node.args));
1414

1515
std::string sep;
1616
sep += fs::path::preferred_separator;

‎src/wallet/test/init_test_fixture.h

-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ struct InitWalletDirTestingSetup: public BasicTestingSetup {
1919
fs::path m_datadir;
2020
fs::path m_cwd;
2121
std::map<std::string, fs::path> m_walletdir_path_cases;
22-
std::unique_ptr<interfaces::Chain> m_chain = interfaces::MakeChain(m_node);
2322
std::unique_ptr<interfaces::WalletClient> m_wallet_client;
2423
};
2524

‎src/wallet/test/ismine_tests.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@ BOOST_AUTO_TEST_CASE(ismine_standard)
2727
CKey uncompressedKey;
2828
uncompressedKey.MakeNewKey(false);
2929
CPubKey uncompressedPubkey = uncompressedKey.GetPubKey();
30-
NodeContext node;
31-
std::unique_ptr<interfaces::Chain> chain = interfaces::MakeChain(node);
30+
std::unique_ptr<interfaces::Chain>& chain = m_node.chain;
3231

3332
CScript scriptPubKey;
3433
isminetype result;

‎src/wallet/test/scriptpubkeyman_tests.cpp

+1-3
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,7 @@ BOOST_FIXTURE_TEST_SUITE(scriptpubkeyman_tests, BasicTestingSetup)
1717
BOOST_AUTO_TEST_CASE(CanProvide)
1818
{
1919
// Set up wallet and keyman variables.
20-
NodeContext node;
21-
std::unique_ptr<interfaces::Chain> chain = interfaces::MakeChain(node);
22-
CWallet wallet(chain.get(), "", CreateDummyWalletDatabase());
20+
CWallet wallet(m_node.chain.get(), "", CreateDummyWalletDatabase());
2321
LegacyScriptPubKeyMan& keyman = *wallet.GetOrCreateLegacyScriptPubKeyMan();
2422

2523
// Make a 1 of 2 multisig script

‎src/wallet/test/wallet_test_fixture.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66

77
WalletTestingSetup::WalletTestingSetup(const std::string& chainName)
88
: TestingSetup(chainName),
9-
m_wallet(m_chain.get(), "", CreateMockWalletDatabase())
9+
m_wallet(m_node.chain.get(), "", CreateMockWalletDatabase())
1010
{
1111
bool fFirstRun;
1212
m_wallet.LoadWallet(fFirstRun);
13-
m_chain_notifications_handler = m_chain->handleNotifications({ &m_wallet, [](CWallet*) {} });
13+
m_chain_notifications_handler = m_node.chain->handleNotifications({ &m_wallet, [](CWallet*) {} });
1414
m_wallet_client->registerRpcs();
1515
}

‎src/wallet/test/wallet_test_fixture.h

+1-2
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@
2020
struct WalletTestingSetup : public TestingSetup {
2121
explicit WalletTestingSetup(const std::string& chainName = CBaseChainParams::MAIN);
2222

23-
std::unique_ptr<interfaces::Chain> m_chain = interfaces::MakeChain(m_node);
24-
std::unique_ptr<interfaces::WalletClient> m_wallet_client = interfaces::MakeWalletClient(*m_chain, *Assert(m_node.args));
23+
std::unique_ptr<interfaces::WalletClient> m_wallet_client = interfaces::MakeWalletClient(*m_node.chain, *Assert(m_node.args));
2524
CWallet m_wallet;
2625
std::unique_ptr<interfaces::Handler> m_chain_notifications_handler;
2726
};

‎src/wallet/test/wallet_tests.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -786,8 +786,7 @@ BOOST_FIXTURE_TEST_CASE(CreateWallet, TestChain100Setup)
786786

787787
BOOST_FIXTURE_TEST_CASE(ZapSelectTx, TestChain100Setup)
788788
{
789-
auto chain = interfaces::MakeChain(m_node);
790-
auto wallet = TestLoadWallet(*chain);
789+
auto wallet = TestLoadWallet(*m_node.chain);
791790
CKey key;
792791
key.MakeNewKey(true);
793792
AddKey(*wallet, key);

0 commit comments

Comments
 (0)