mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-15 12:51:00 +02:00
tests: Test for expected return values when calling functions returning a success code
This commit is contained in:
parent
6d0a14703e
commit
c84c2b8c92
16 changed files with 161 additions and 161 deletions
|
|
@ -1185,7 +1185,7 @@ BOOST_AUTO_TEST_CASE(script_combineSigs)
|
|||
key.MakeNewKey(i%2 == 1);
|
||||
keys.push_back(key);
|
||||
pubkeys.push_back(key.GetPubKey());
|
||||
keystore.AddKey(key);
|
||||
BOOST_CHECK(keystore.AddKey(key));
|
||||
}
|
||||
|
||||
CMutableTransaction txFrom = BuildCreditingTransaction(GetScriptForDestination(keys[0].GetPubKey().GetID()));
|
||||
|
|
@ -1198,7 +1198,7 @@ BOOST_AUTO_TEST_CASE(script_combineSigs)
|
|||
BOOST_CHECK(combined.scriptSig.empty());
|
||||
|
||||
// Single signature case:
|
||||
SignSignature(keystore, CTransaction(txFrom), txTo, 0, SIGHASH_ALL); // changes scriptSig
|
||||
BOOST_CHECK(SignSignature(keystore, CTransaction(txFrom), txTo, 0, SIGHASH_ALL)); // changes scriptSig
|
||||
scriptSig = DataFromTransaction(txTo, 0, txFrom.vout[0]);
|
||||
combined = CombineSignatures(txFrom.vout[0], txTo, scriptSig, empty);
|
||||
BOOST_CHECK(combined.scriptSig == scriptSig.scriptSig);
|
||||
|
|
@ -1206,31 +1206,31 @@ BOOST_AUTO_TEST_CASE(script_combineSigs)
|
|||
BOOST_CHECK(combined.scriptSig == scriptSig.scriptSig);
|
||||
SignatureData scriptSigCopy = scriptSig;
|
||||
// Signing again will give a different, valid signature:
|
||||
SignSignature(keystore, CTransaction(txFrom), txTo, 0, SIGHASH_ALL);
|
||||
BOOST_CHECK(SignSignature(keystore, CTransaction(txFrom), txTo, 0, SIGHASH_ALL));
|
||||
scriptSig = DataFromTransaction(txTo, 0, txFrom.vout[0]);
|
||||
combined = CombineSignatures(txFrom.vout[0], txTo, scriptSigCopy, scriptSig);
|
||||
BOOST_CHECK(combined.scriptSig == scriptSigCopy.scriptSig || combined.scriptSig == scriptSig.scriptSig);
|
||||
|
||||
// P2SH, single-signature case:
|
||||
CScript pkSingle; pkSingle << ToByteVector(keys[0].GetPubKey()) << OP_CHECKSIG;
|
||||
keystore.AddCScript(pkSingle);
|
||||
BOOST_CHECK(keystore.AddCScript(pkSingle));
|
||||
scriptPubKey = GetScriptForDestination(CScriptID(pkSingle));
|
||||
SignSignature(keystore, CTransaction(txFrom), txTo, 0, SIGHASH_ALL);
|
||||
BOOST_CHECK(SignSignature(keystore, CTransaction(txFrom), txTo, 0, SIGHASH_ALL));
|
||||
scriptSig = DataFromTransaction(txTo, 0, txFrom.vout[0]);
|
||||
combined = CombineSignatures(txFrom.vout[0], txTo, scriptSig, empty);
|
||||
BOOST_CHECK(combined.scriptSig == scriptSig.scriptSig);
|
||||
combined = CombineSignatures(txFrom.vout[0], txTo, empty, scriptSig);
|
||||
BOOST_CHECK(combined.scriptSig == scriptSig.scriptSig);
|
||||
scriptSigCopy = scriptSig;
|
||||
SignSignature(keystore, CTransaction(txFrom), txTo, 0, SIGHASH_ALL);
|
||||
BOOST_CHECK(SignSignature(keystore, CTransaction(txFrom), txTo, 0, SIGHASH_ALL));
|
||||
scriptSig = DataFromTransaction(txTo, 0, txFrom.vout[0]);
|
||||
combined = CombineSignatures(txFrom.vout[0], txTo, scriptSigCopy, scriptSig);
|
||||
BOOST_CHECK(combined.scriptSig == scriptSigCopy.scriptSig || combined.scriptSig == scriptSig.scriptSig);
|
||||
|
||||
// Hardest case: Multisig 2-of-3
|
||||
scriptPubKey = GetScriptForMultisig(2, pubkeys);
|
||||
keystore.AddCScript(scriptPubKey);
|
||||
SignSignature(keystore, CTransaction(txFrom), txTo, 0, SIGHASH_ALL);
|
||||
BOOST_CHECK(keystore.AddCScript(scriptPubKey));
|
||||
BOOST_CHECK(SignSignature(keystore, CTransaction(txFrom), txTo, 0, SIGHASH_ALL));
|
||||
scriptSig = DataFromTransaction(txTo, 0, txFrom.vout[0]);
|
||||
combined = CombineSignatures(txFrom.vout[0], txTo, scriptSig, empty);
|
||||
BOOST_CHECK(combined.scriptSig == scriptSig.scriptSig);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue