Skip to content

Commit ed82988

Browse files
authored
Merge pull request #3110 from codablock/pr_backports_v15_v16_2
Backport same PRs as done in bitcoin#11445
2 parents 3ac583c + 297e9a0 commit ed82988

File tree

114 files changed

+1548
-1022
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

114 files changed

+1548
-1022
lines changed

configure.ac

+1
Original file line numberDiff line numberDiff line change
@@ -1295,6 +1295,7 @@ AC_SUBST(DSYMUTIL_FLAT)
12951295
AC_CONFIG_FILES([Makefile src/Makefile doc/man/Makefile share/setup.nsi share/qt/Info.plist test/config.ini])
12961296
AC_CONFIG_FILES([contrib/devtools/split-debug.sh],[chmod +x contrib/devtools/split-debug.sh])
12971297
AC_CONFIG_FILES([doc/Doxyfile])
1298+
AC_CONFIG_LINKS([contrib/filter-lcov.py:contrib/filter-lcov.py])
12981299
AC_CONFIG_LINKS([test/functional/test_runner.py:test/functional/test_runner.py])
12991300
AC_CONFIG_LINKS([test/util/bitcoin-util-test.py:test/util/bitcoin-util-test.py])
13001301

src/Makefile.qttest.include

+2-5
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,10 @@ TEST_QT_H = \
2828
qt/test/wallettests.h
2929

3030
TEST_BITCOIN_CPP = \
31-
test/test_dash.cpp \
32-
test/testutil.cpp
31+
test/test_dash.cpp
3332

3433
TEST_BITCOIN_H = \
35-
test/test_dash.h \
36-
test/testutil.h
37-
34+
test/test_dash.h
3835
qt_test_test_dash_qt_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES) $(BITCOIN_QT_INCLUDES) \
3936
$(QT_INCLUDES) $(QT_TEST_INCLUDES) $(PROTOBUF_CFLAGS)
4037

src/Makefile.test.include

+2-3
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ BITCOIN_TESTS =\
7979
test/script_P2PK_tests.cpp \
8080
test/script_P2PKH_tests.cpp \
8181
test/script_tests.cpp \
82+
test/script_standard_tests.cpp \
8283
test/scriptnum_tests.cpp \
8384
test/serialize_tests.cpp \
8485
test/sighash_tests.cpp \
@@ -89,8 +90,6 @@ BITCOIN_TESTS =\
8990
test/test_dash.cpp \
9091
test/test_dash.h \
9192
test/test_dash_main.cpp \
92-
test/testutil.cpp \
93-
test/testutil.h \
9493
test/timedata_tests.cpp \
9594
test/torcontrol_tests.cpp \
9695
test/transaction_tests.cpp \
@@ -163,7 +162,7 @@ dash_test_clean : FORCE
163162

164163
check-local:
165164
@echo "Running test/util/bitcoin-util-test.py..."
166-
$(top_builddir)/test/util/bitcoin-util-test.py
165+
$(PYTHON) $(top_builddir)/test/util/bitcoin-util-test.py
167166
$(AM_V_at)$(MAKE) $(AM_MAKEFLAGS) -C secp256k1 check
168167
if EMBEDDED_UNIVALUE
169168
$(AM_V_at)$(MAKE) $(AM_MAKEFLAGS) -C univalue check

src/qt/test/rpcnestedtests.cpp

-8
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
#include "rpc/register.h"
1212
#include "rpc/server.h"
1313
#include "rpcconsole.h"
14-
#include "test/testutil.h"
1514
#include "test/test_dash.h"
1615
#include "univalue.h"
1716
#include "util.h"
@@ -40,11 +39,6 @@ void RPCNestedTests::rpcNestedTests()
4039
// do some test setup
4140
// could be moved to a more generic place when we add more tests on QT level
4241
tableRPC.appendCommand("rpcNestedTest", &vRPCCommands[0]);
43-
ClearDatadirCache();
44-
std::string path = QDir::tempPath().toStdString() + "/" + strprintf("test_dash_qt_%lu_%i", (unsigned long)GetTime(), (int)(GetRand(100000)));
45-
QDir dir(QString::fromStdString(path));
46-
dir.mkpath(".");
47-
gArgs.ForceSetArg("-datadir", path);
4842
//mempool.setSanityCheck(1.0);
4943

5044
TestingSetup test;
@@ -139,6 +133,4 @@ void RPCNestedTests::rpcNestedTests()
139133
QVERIFY_EXCEPTION_THROWN(RPCConsole::RPCExecuteCommandLine(result, "rpcNestedTest(abc,,abc)"), std::runtime_error); //don't tollerate empty arguments when using ,
140134
QVERIFY_EXCEPTION_THROWN(RPCConsole::RPCExecuteCommandLine(result, "rpcNestedTest(abc,,)"), std::runtime_error); //don't tollerate empty arguments when using ,
141135
#endif
142-
143-
fs::remove_all(fs::path(path));
144136
}

src/qt/test/test_main.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ int main(int argc, char *argv[])
5555
SetupNetworking();
5656
SelectParams(CBaseChainParams::MAIN);
5757
noui_connect();
58+
ClearDatadirCache();
59+
fs::path pathTemp = fs::temp_directory_path() / strprintf("test_dash-qt_%lu_%i", (unsigned long)GetTime(), (int)GetRand(100000));
60+
fs::create_directories(pathTemp);
61+
gArgs.ForceSetArg("-datadir", pathTemp.string());
5862

5963
bool fInvalid = false;
6064

src/rpc/blockchain.cpp

+4-3
Original file line numberDiff line numberDiff line change
@@ -1211,9 +1211,10 @@ UniValue gettxout(const JSONRPCRequest& request)
12111211
"gettxout \"txid\" n ( include_mempool )\n"
12121212
"\nReturns details about an unspent transaction output.\n"
12131213
"\nArguments:\n"
1214-
"1. \"txid\" (string, required) The transaction id\n"
1215-
"2. n (numeric, required) vout number\n"
1216-
"3. include_mempool (boolean, optional) Whether to include the mempool\n"
1214+
"1. \"txid\" (string, required) The transaction id\n"
1215+
"2. \"n\" (numeric, required) vout number\n"
1216+
"3. \"include_mempool\" (boolean, optional) Whether to include the mempool. Default: true."
1217+
" Note that an unspent output that is spent in the mempool won't appear.\n"
12171218
"\nResult:\n"
12181219
"{\n"
12191220
" \"bestblock\" : \"hash\", (string) the block hash\n"

src/test/dbwrapper_tests.cpp

+14-2
Original file line numberDiff line numberDiff line change
@@ -204,19 +204,31 @@ BOOST_AUTO_TEST_CASE(iterator_ordering)
204204
for (int x=0x00; x<256; ++x) {
205205
uint8_t key = x;
206206
uint32_t value = x*x;
207-
BOOST_CHECK(dbw.Write(key, value));
207+
if (!(x & 1)) BOOST_CHECK(dbw.Write(key, value));
208208
}
209209

210+
// Check that creating an iterator creates a snapshot
210211
std::unique_ptr<CDBIterator> it(const_cast<CDBWrapper&>(dbw).NewIterator());
212+
213+
for (int x=0x00; x<256; ++x) {
214+
uint8_t key = x;
215+
uint32_t value = x*x;
216+
if (x & 1) BOOST_CHECK(dbw.Write(key, value));
217+
}
218+
211219
for (int seek_start : {0x00, 0x80}) {
212220
it->Seek((uint8_t)seek_start);
213-
for (int x=seek_start; x<256; ++x) {
221+
for (int x=seek_start; x<255; ++x) {
214222
uint8_t key;
215223
uint32_t value;
216224
BOOST_CHECK(it->Valid());
217225
if (!it->Valid()) // Avoid spurious errors about invalid iterator's key and value in case of failure
218226
break;
219227
BOOST_CHECK(it->GetKey(key));
228+
if (x & 1) {
229+
BOOST_CHECK_EQUAL(key, x + 1);
230+
continue;
231+
}
220232
BOOST_CHECK(it->GetValue(value));
221233
BOOST_CHECK_EQUAL(key, x);
222234
BOOST_CHECK_EQUAL(value, x*x);

src/test/multisig_tests.cpp

-91
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616

1717
#include <boost/test/unit_test.hpp>
1818

19-
typedef std::vector<unsigned char> valtype;
20-
2119
BOOST_FIXTURE_TEST_SUITE(multisig_tests, BasicTestingSetup)
2220

2321
CScript
@@ -173,95 +171,6 @@ BOOST_AUTO_TEST_CASE(multisig_IsStandard)
173171
BOOST_CHECK(!::IsStandard(malformed[i], whichType));
174172
}
175173

176-
BOOST_AUTO_TEST_CASE(multisig_Solver1)
177-
{
178-
// Tests Solver() that returns lists of keys that are
179-
// required to satisfy a ScriptPubKey
180-
//
181-
// Also tests IsMine() and ExtractDestination()
182-
//
183-
// Note: ExtractDestination for the multisignature transactions
184-
// always returns false for this release, even if you have
185-
// one key that would satisfy an (a|b) or 2-of-3 keys needed
186-
// to spend an escrow transaction.
187-
//
188-
CBasicKeyStore keystore, emptykeystore, partialkeystore;
189-
CKey key[3];
190-
CTxDestination keyaddr[3];
191-
for (int i = 0; i < 3; i++)
192-
{
193-
key[i].MakeNewKey(true);
194-
keystore.AddKey(key[i]);
195-
keyaddr[i] = key[i].GetPubKey().GetID();
196-
}
197-
partialkeystore.AddKey(key[0]);
198-
199-
{
200-
std::vector<valtype> solutions;
201-
txnouttype whichType;
202-
CScript s;
203-
s << ToByteVector(key[0].GetPubKey()) << OP_CHECKSIG;
204-
BOOST_CHECK(Solver(s, whichType, solutions));
205-
BOOST_CHECK(solutions.size() == 1);
206-
CTxDestination addr;
207-
BOOST_CHECK(ExtractDestination(s, addr));
208-
BOOST_CHECK(addr == keyaddr[0]);
209-
BOOST_CHECK(IsMine(keystore, s));
210-
BOOST_CHECK(!IsMine(emptykeystore, s));
211-
}
212-
{
213-
std::vector<valtype> solutions;
214-
txnouttype whichType;
215-
CScript s;
216-
s << OP_DUP << OP_HASH160 << ToByteVector(key[0].GetPubKey().GetID()) << OP_EQUALVERIFY << OP_CHECKSIG;
217-
BOOST_CHECK(Solver(s, whichType, solutions));
218-
BOOST_CHECK(solutions.size() == 1);
219-
CTxDestination addr;
220-
BOOST_CHECK(ExtractDestination(s, addr));
221-
BOOST_CHECK(addr == keyaddr[0]);
222-
BOOST_CHECK(IsMine(keystore, s));
223-
BOOST_CHECK(!IsMine(emptykeystore, s));
224-
}
225-
{
226-
std::vector<valtype> solutions;
227-
txnouttype whichType;
228-
CScript s;
229-
s << OP_2 << ToByteVector(key[0].GetPubKey()) << ToByteVector(key[1].GetPubKey()) << OP_2 << OP_CHECKMULTISIG;
230-
BOOST_CHECK(Solver(s, whichType, solutions));
231-
BOOST_CHECK_EQUAL(solutions.size(), 4U);
232-
CTxDestination addr;
233-
BOOST_CHECK(!ExtractDestination(s, addr));
234-
BOOST_CHECK(IsMine(keystore, s));
235-
BOOST_CHECK(!IsMine(emptykeystore, s));
236-
BOOST_CHECK(!IsMine(partialkeystore, s));
237-
}
238-
{
239-
std::vector<valtype> solutions;
240-
txnouttype whichType;
241-
CScript s;
242-
s << OP_1 << ToByteVector(key[0].GetPubKey()) << ToByteVector(key[1].GetPubKey()) << OP_2 << OP_CHECKMULTISIG;
243-
BOOST_CHECK(Solver(s, whichType, solutions));
244-
BOOST_CHECK_EQUAL(solutions.size(), 4U);
245-
std::vector<CTxDestination> addrs;
246-
int nRequired;
247-
BOOST_CHECK(ExtractDestinations(s, whichType, addrs, nRequired));
248-
BOOST_CHECK(addrs[0] == keyaddr[0]);
249-
BOOST_CHECK(addrs[1] == keyaddr[1]);
250-
BOOST_CHECK(nRequired == 1);
251-
BOOST_CHECK(IsMine(keystore, s));
252-
BOOST_CHECK(!IsMine(emptykeystore, s));
253-
BOOST_CHECK(!IsMine(partialkeystore, s));
254-
}
255-
{
256-
std::vector<valtype> solutions;
257-
txnouttype whichType;
258-
CScript s;
259-
s << OP_2 << ToByteVector(key[0].GetPubKey()) << ToByteVector(key[1].GetPubKey()) << ToByteVector(key[2].GetPubKey()) << OP_3 << OP_CHECKMULTISIG;
260-
BOOST_CHECK(Solver(s, whichType, solutions));
261-
BOOST_CHECK(solutions.size() == 5);
262-
}
263-
}
264-
265174
BOOST_AUTO_TEST_CASE(multisig_Sign)
266175
{
267176
// Test SignSignature() (and therefore the version of Solver() that signs transactions)

0 commit comments

Comments
 (0)