Skip to content

Commit fbc7a96

Browse files
committed
Re-enable miner tests in --disable-wallet mode
Use a fixed script instead of a CReserveKey from the wallet. This does not affect the functionality or result of the tests as they never check the state of the wallet in the first place.
1 parent acfa033 commit fbc7a96

File tree

2 files changed

+14
-15
lines changed

2 files changed

+14
-15
lines changed

src/test/Makefile.am

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,14 @@ test_bitcoin_SOURCES = alert_tests.cpp \
3131
allocator_tests.cpp base32_tests.cpp base58_tests.cpp base64_tests.cpp \
3232
bignum_tests.cpp bloom_tests.cpp canonical_tests.cpp checkblock_tests.cpp \
3333
Checkpoints_tests.cpp compress_tests.cpp DoS_tests.cpp getarg_tests.cpp \
34-
key_tests.cpp mruset_tests.cpp multisig_tests.cpp \
34+
key_tests.cpp miner_tests.cpp mruset_tests.cpp multisig_tests.cpp \
3535
netbase_tests.cpp pmt_tests.cpp rpc_tests.cpp script_P2SH_tests.cpp \
3636
script_tests.cpp serialize_tests.cpp sigopcount_tests.cpp test_bitcoin.cpp \
3737
transaction_tests.cpp uint160_tests.cpp uint256_tests.cpp util_tests.cpp \
3838
sighash_tests.cpp $(JSON_TEST_FILES) $(RAW_TEST_FILES)
3939

4040
if ENABLE_WALLET
41-
test_bitcoin_SOURCES += accounting_tests.cpp wallet_tests.cpp miner_tests.cpp rpc_wallet_tests.cpp
41+
test_bitcoin_SOURCES += accounting_tests.cpp wallet_tests.cpp rpc_wallet_tests.cpp
4242
endif
4343

4444
nodist_test_bitcoin_SOURCES = $(BUILT_SOURCES)

src/test/miner_tests.cpp

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
#include <boost/test/unit_test.hpp>
1010

11-
extern CWallet* pwalletMain;
1211
extern void SHA256Transform(void* pstate, void* pinput, const void* pinit);
1312

1413
BOOST_AUTO_TEST_SUITE(miner_tests)
@@ -51,7 +50,7 @@ struct {
5150
// NOTE: These tests rely on CreateNewBlock doing its own self-validation!
5251
BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
5352
{
54-
CReserveKey reservekey(pwalletMain);
53+
CScript scriptPubKey = CScript() << ParseHex("04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5f") << OP_CHECKSIG;
5554
CBlockTemplate *pblocktemplate;
5655
CTransaction tx;
5756
CScript script;
@@ -60,7 +59,7 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
6059
LOCK(cs_main);
6160

6261
// Simple block creation, nothing special yet:
63-
BOOST_CHECK(pblocktemplate = CreateNewBlockWithKey(reservekey));
62+
BOOST_CHECK(pblocktemplate = CreateNewBlock(scriptPubKey));
6463

6564
// We can't make transactions until we have inputs
6665
// Therefore, load 100 blocks :)
@@ -86,7 +85,7 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
8685
delete pblocktemplate;
8786

8887
// Just to make sure we can still make simple blocks
89-
BOOST_CHECK(pblocktemplate = CreateNewBlockWithKey(reservekey));
88+
BOOST_CHECK(pblocktemplate = CreateNewBlock(scriptPubKey));
9089
delete pblocktemplate;
9190

9291
// block sigops > limit: 1000 CHECKMULTISIG + 1
@@ -104,7 +103,7 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
104103
mempool.addUnchecked(hash, CTxMemPoolEntry(tx, 11, GetTime(), 111.0, 11));
105104
tx.vin[0].prevout.hash = hash;
106105
}
107-
BOOST_CHECK(pblocktemplate = CreateNewBlockWithKey(reservekey));
106+
BOOST_CHECK(pblocktemplate = CreateNewBlock(scriptPubKey));
108107
delete pblocktemplate;
109108
mempool.clear();
110109

@@ -124,14 +123,14 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
124123
mempool.addUnchecked(hash, CTxMemPoolEntry(tx, 11, GetTime(), 111.0, 11));
125124
tx.vin[0].prevout.hash = hash;
126125
}
127-
BOOST_CHECK(pblocktemplate = CreateNewBlockWithKey(reservekey));
126+
BOOST_CHECK(pblocktemplate = CreateNewBlock(scriptPubKey));
128127
delete pblocktemplate;
129128
mempool.clear();
130129

131130
// orphan in mempool
132131
hash = tx.GetHash();
133132
mempool.addUnchecked(hash, CTxMemPoolEntry(tx, 11, GetTime(), 111.0, 11));
134-
BOOST_CHECK(pblocktemplate = CreateNewBlockWithKey(reservekey));
133+
BOOST_CHECK(pblocktemplate = CreateNewBlock(scriptPubKey));
135134
delete pblocktemplate;
136135
mempool.clear();
137136

@@ -149,7 +148,7 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
149148
tx.vout[0].nValue = 5900000000LL;
150149
hash = tx.GetHash();
151150
mempool.addUnchecked(hash, CTxMemPoolEntry(tx, 11, GetTime(), 111.0, 11));
152-
BOOST_CHECK(pblocktemplate = CreateNewBlockWithKey(reservekey));
151+
BOOST_CHECK(pblocktemplate = CreateNewBlock(scriptPubKey));
153152
delete pblocktemplate;
154153
mempool.clear();
155154

@@ -160,7 +159,7 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
160159
tx.vout[0].nValue = 0;
161160
hash = tx.GetHash();
162161
mempool.addUnchecked(hash, CTxMemPoolEntry(tx, 11, GetTime(), 111.0, 11));
163-
BOOST_CHECK(pblocktemplate = CreateNewBlockWithKey(reservekey));
162+
BOOST_CHECK(pblocktemplate = CreateNewBlock(scriptPubKey));
164163
delete pblocktemplate;
165164
mempool.clear();
166165

@@ -178,7 +177,7 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
178177
tx.vout[0].nValue -= 1000000;
179178
hash = tx.GetHash();
180179
mempool.addUnchecked(hash, CTxMemPoolEntry(tx, 11, GetTime(), 111.0, 11));
181-
BOOST_CHECK(pblocktemplate = CreateNewBlockWithKey(reservekey));
180+
BOOST_CHECK(pblocktemplate = CreateNewBlock(scriptPubKey));
182181
delete pblocktemplate;
183182
mempool.clear();
184183

@@ -192,17 +191,17 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
192191
tx.vout[0].scriptPubKey = CScript() << OP_2;
193192
hash = tx.GetHash();
194193
mempool.addUnchecked(hash, CTxMemPoolEntry(tx, 11, GetTime(), 111.0, 11));
195-
BOOST_CHECK(pblocktemplate = CreateNewBlockWithKey(reservekey));
194+
BOOST_CHECK(pblocktemplate = CreateNewBlock(scriptPubKey));
196195
delete pblocktemplate;
197196
mempool.clear();
198197

199198
// subsidy changing
200199
int nHeight = chainActive.Height();
201200
chainActive.Tip()->nHeight = 209999;
202-
BOOST_CHECK(pblocktemplate = CreateNewBlockWithKey(reservekey));
201+
BOOST_CHECK(pblocktemplate = CreateNewBlock(scriptPubKey));
203202
delete pblocktemplate;
204203
chainActive.Tip()->nHeight = 210000;
205-
BOOST_CHECK(pblocktemplate = CreateNewBlockWithKey(reservekey));
204+
BOOST_CHECK(pblocktemplate = CreateNewBlock(scriptPubKey));
206205
delete pblocktemplate;
207206
chainActive.Tip()->nHeight = nHeight;
208207

0 commit comments

Comments
 (0)