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