Skip to content

Commit 49f3d57

Browse files
committed
Merge #11116: [script] Unit tests for script/standard and IsMine functions.
7a1e873 [script] Unit tests for IsMine (Jim Posen) d7afe2d [script] Unit tests for script/standard functions (Jim Posen) Pull request description: Simply adding unit test coverage. Tree-SHA512: aaf16b1b07b6d43c884a67f4fd5f83c31bf2c560f78798036d7aa37a3efe71a7ca3c82c4b3ba1f3119bcbe3b78013e64bb0020fe57ebc69aea1cb54943881959
2 parents 9821274 + 7a1e873 commit 49f3d57

File tree

4 files changed

+743
-91
lines changed

4 files changed

+743
-91
lines changed

src/Makefile.test.include

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ BITCOIN_TESTS =\
6565
test/scheduler_tests.cpp \
6666
test/script_P2SH_tests.cpp \
6767
test/script_tests.cpp \
68+
test/script_standard_tests.cpp \
6869
test/scriptnum_tests.cpp \
6970
test/serialize_tests.cpp \
7071
test/sighash_tests.cpp \

src/script/ismine.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ isminetype IsMine(const CKeyStore &keystore, const CTxDestination& dest, bool& i
4646

4747
isminetype IsMine(const CKeyStore &keystore, const CScript& scriptPubKey, bool& isInvalid, SigVersion sigversion)
4848
{
49+
isInvalid = false;
50+
4951
std::vector<valtype> vSolutions;
5052
txnouttype whichType;
5153
if (!Solver(scriptPubKey, whichType, vSolutions)) {

src/test/multisig_tests.cpp

Lines changed: 0 additions & 91 deletions
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)