|
|
@ -15,12 +15,10 @@ |
|
|
|
#include "wallet_ismine.h" |
|
|
|
#include "wallet_ismine.h" |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
#include <boost/assign/std/vector.hpp> |
|
|
|
|
|
|
|
#include <boost/foreach.hpp> |
|
|
|
#include <boost/foreach.hpp> |
|
|
|
#include <boost/test/unit_test.hpp> |
|
|
|
#include <boost/test/unit_test.hpp> |
|
|
|
|
|
|
|
|
|
|
|
using namespace std; |
|
|
|
using namespace std; |
|
|
|
using namespace boost::assign; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
typedef vector<unsigned char> valtype; |
|
|
|
typedef vector<unsigned char> valtype; |
|
|
|
|
|
|
|
|
|
|
@ -81,22 +79,21 @@ BOOST_AUTO_TEST_CASE(multisig_verify) |
|
|
|
CScript s; |
|
|
|
CScript s; |
|
|
|
|
|
|
|
|
|
|
|
// Test a AND b:
|
|
|
|
// Test a AND b:
|
|
|
|
keys.clear(); |
|
|
|
keys.assign(1,key[0]); |
|
|
|
keys += key[0],key[1]; // magic operator+= from boost.assign
|
|
|
|
keys.push_back(key[1]); |
|
|
|
s = sign_multisig(a_and_b, keys, txTo[0], 0); |
|
|
|
s = sign_multisig(a_and_b, keys, txTo[0], 0); |
|
|
|
BOOST_CHECK(VerifyScript(s, a_and_b, flags, SignatureChecker(txTo[0], 0), &err)); |
|
|
|
BOOST_CHECK(VerifyScript(s, a_and_b, flags, SignatureChecker(txTo[0], 0), &err)); |
|
|
|
BOOST_CHECK_MESSAGE(err == SCRIPT_ERR_OK, ScriptErrorString(err)); |
|
|
|
BOOST_CHECK_MESSAGE(err == SCRIPT_ERR_OK, ScriptErrorString(err)); |
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < 4; i++) |
|
|
|
for (int i = 0; i < 4; i++) |
|
|
|
{ |
|
|
|
{ |
|
|
|
keys.clear(); |
|
|
|
keys.assign(1,key[i]); |
|
|
|
keys += key[i]; |
|
|
|
|
|
|
|
s = sign_multisig(a_and_b, keys, txTo[0], 0); |
|
|
|
s = sign_multisig(a_and_b, keys, txTo[0], 0); |
|
|
|
BOOST_CHECK_MESSAGE(!VerifyScript(s, a_and_b, flags, SignatureChecker(txTo[0], 0), &err), strprintf("a&b 1: %d", i)); |
|
|
|
BOOST_CHECK_MESSAGE(!VerifyScript(s, a_and_b, flags, SignatureChecker(txTo[0], 0), &err), strprintf("a&b 1: %d", i)); |
|
|
|
BOOST_CHECK_MESSAGE(err == SCRIPT_ERR_INVALID_STACK_OPERATION, ScriptErrorString(err)); |
|
|
|
BOOST_CHECK_MESSAGE(err == SCRIPT_ERR_INVALID_STACK_OPERATION, ScriptErrorString(err)); |
|
|
|
|
|
|
|
|
|
|
|
keys.clear(); |
|
|
|
keys.assign(1,key[1]); |
|
|
|
keys += key[1],key[i]; |
|
|
|
keys.push_back(key[i]); |
|
|
|
s = sign_multisig(a_and_b, keys, txTo[0], 0); |
|
|
|
s = sign_multisig(a_and_b, keys, txTo[0], 0); |
|
|
|
BOOST_CHECK_MESSAGE(!VerifyScript(s, a_and_b, flags, SignatureChecker(txTo[0], 0), &err), strprintf("a&b 2: %d", i)); |
|
|
|
BOOST_CHECK_MESSAGE(!VerifyScript(s, a_and_b, flags, SignatureChecker(txTo[0], 0), &err), strprintf("a&b 2: %d", i)); |
|
|
|
BOOST_CHECK_MESSAGE(err == SCRIPT_ERR_EVAL_FALSE, ScriptErrorString(err)); |
|
|
|
BOOST_CHECK_MESSAGE(err == SCRIPT_ERR_EVAL_FALSE, ScriptErrorString(err)); |
|
|
@ -105,8 +102,7 @@ BOOST_AUTO_TEST_CASE(multisig_verify) |
|
|
|
// Test a OR b:
|
|
|
|
// Test a OR b:
|
|
|
|
for (int i = 0; i < 4; i++) |
|
|
|
for (int i = 0; i < 4; i++) |
|
|
|
{ |
|
|
|
{ |
|
|
|
keys.clear(); |
|
|
|
keys.assign(1,key[i]); |
|
|
|
keys += key[i]; |
|
|
|
|
|
|
|
s = sign_multisig(a_or_b, keys, txTo[1], 0); |
|
|
|
s = sign_multisig(a_or_b, keys, txTo[1], 0); |
|
|
|
if (i == 0 || i == 1) |
|
|
|
if (i == 0 || i == 1) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -132,8 +128,8 @@ BOOST_AUTO_TEST_CASE(multisig_verify) |
|
|
|
for (int i = 0; i < 4; i++) |
|
|
|
for (int i = 0; i < 4; i++) |
|
|
|
for (int j = 0; j < 4; j++) |
|
|
|
for (int j = 0; j < 4; j++) |
|
|
|
{ |
|
|
|
{ |
|
|
|
keys.clear(); |
|
|
|
keys.assign(1,key[i]); |
|
|
|
keys += key[i],key[j]; |
|
|
|
keys.push_back(key[j]); |
|
|
|
s = sign_multisig(escrow, keys, txTo[2], 0); |
|
|
|
s = sign_multisig(escrow, keys, txTo[2], 0); |
|
|
|
if (i < j && i < 3 && j < 3) |
|
|
|
if (i < j && i < 3 && j < 3) |
|
|
|
{ |
|
|
|
{ |
|
|
|