@@ -217,7 +217,6 @@ struct KeyData
217
217
218
218
KeyData ()
219
219
{
220
-
221
220
key0.Set (vchKey0, vchKey0 + 32 , false );
222
221
key0C.Set (vchKey0, vchKey0 + 32 , true );
223
222
pubkey0 = key0.GetPubKey ();
@@ -272,9 +271,9 @@ class TestBuilder
272
271
273
272
void DoPush (const std::vector<unsigned char >& data)
274
273
{
275
- DoPush ();
276
- push = data;
277
- havePush = true ;
274
+ DoPush ();
275
+ push = data;
276
+ havePush = true ;
278
277
}
279
278
280
279
public:
@@ -306,10 +305,10 @@ class TestBuilder
306
305
return *this ;
307
306
}
308
307
309
- TestBuilder& Add (const CScript& _script )
308
+ TestBuilder& Opcode (const opcodetype& _op )
310
309
{
311
310
DoPush ();
312
- spendTx.vin [0 ].scriptSig += _script ;
311
+ spendTx.vin [0 ].scriptSig << _op ;
313
312
return *this ;
314
313
}
315
314
@@ -326,8 +325,9 @@ class TestBuilder
326
325
return *this ;
327
326
}
328
327
329
- TestBuilder& Push (const CScript& _script) {
330
- DoPush (std::vector<unsigned char >(_script.begin (), _script.end ()));
328
+ TestBuilder& Push (const CScript& _script)
329
+ {
330
+ DoPush (std::vector<unsigned char >(_script.begin (), _script.end ()));
331
331
return *this ;
332
332
}
333
333
@@ -681,22 +681,22 @@ BOOST_AUTO_TEST_CASE(script_build)
681
681
682
682
tests.push_back (TestBuilder (CScript () << OP_2 << ToByteVector (keys.pubkey1C ) << ToByteVector (keys.pubkey1C ) << OP_2 << OP_CHECKMULTISIG,
683
683
" 2-of-2 with two identical keys and sigs pushed using OP_DUP but no SIGPUSHONLY" , 0
684
- ).Num (0 ).PushSig (keys.key1 ).Add ( CScript () << OP_DUP));
684
+ ).Num (0 ).PushSig (keys.key1 ).Opcode ( OP_DUP));
685
685
tests.push_back (TestBuilder (CScript () << OP_2 << ToByteVector (keys.pubkey1C ) << ToByteVector (keys.pubkey1C ) << OP_2 << OP_CHECKMULTISIG,
686
686
" 2-of-2 with two identical keys and sigs pushed using OP_DUP" , SCRIPT_VERIFY_SIGPUSHONLY
687
- ).Num (0 ).PushSig (keys.key1 ).Add ( CScript () << OP_DUP).ScriptError (SCRIPT_ERR_SIG_PUSHONLY));
687
+ ).Num (0 ).PushSig (keys.key1 ).Opcode ( OP_DUP).ScriptError (SCRIPT_ERR_SIG_PUSHONLY));
688
688
tests.push_back (TestBuilder (CScript () << ToByteVector (keys.pubkey2C ) << OP_CHECKSIG,
689
689
" P2SH(P2PK) with non-push scriptSig but no P2SH or SIGPUSHONLY" , 0 , true
690
- ).PushSig (keys.key2 ).Add ( CScript () << OP_NOP8).PushRedeem ());
690
+ ).PushSig (keys.key2 ).Opcode ( OP_NOP8).PushRedeem ());
691
691
tests.push_back (TestBuilder (CScript () << ToByteVector (keys.pubkey2C ) << OP_CHECKSIG,
692
692
" P2PK with non-push scriptSig but with P2SH validation" , 0
693
- ).PushSig (keys.key2 ).Add ( CScript () << OP_NOP8));
693
+ ).PushSig (keys.key2 ).Opcode ( OP_NOP8));
694
694
tests.push_back (TestBuilder (CScript () << ToByteVector (keys.pubkey2C ) << OP_CHECKSIG,
695
695
" P2SH(P2PK) with non-push scriptSig but no SIGPUSHONLY" , SCRIPT_VERIFY_P2SH, true
696
- ).PushSig (keys.key2 ).Add ( CScript () << OP_NOP8).PushRedeem ().ScriptError (SCRIPT_ERR_SIG_PUSHONLY));
696
+ ).PushSig (keys.key2 ).Opcode ( OP_NOP8).PushRedeem ().ScriptError (SCRIPT_ERR_SIG_PUSHONLY));
697
697
tests.push_back (TestBuilder (CScript () << ToByteVector (keys.pubkey2C ) << OP_CHECKSIG,
698
698
" P2SH(P2PK) with non-push scriptSig but not P2SH" , SCRIPT_VERIFY_SIGPUSHONLY, true
699
- ).PushSig (keys.key2 ).Add ( CScript () << OP_NOP8).PushRedeem ().ScriptError (SCRIPT_ERR_SIG_PUSHONLY));
699
+ ).PushSig (keys.key2 ).Opcode ( OP_NOP8).PushRedeem ().ScriptError (SCRIPT_ERR_SIG_PUSHONLY));
700
700
tests.push_back (TestBuilder (CScript () << OP_2 << ToByteVector (keys.pubkey1C ) << ToByteVector (keys.pubkey1C ) << OP_2 << OP_CHECKMULTISIG,
701
701
" 2-of-2 with two identical keys and sigs pushed" , SCRIPT_VERIFY_SIGPUSHONLY
702
702
).Num (0 ).PushSig (keys.key1 ).PushSig (keys.key1 ));
@@ -1470,24 +1470,6 @@ BOOST_AUTO_TEST_CASE(script_HasValidOps)
1470
1470
BOOST_CHECK (!script.HasValidOps ());
1471
1471
}
1472
1472
1473
- BOOST_AUTO_TEST_CASE (script_can_append_self)
1474
- {
1475
- CScript s, d;
1476
-
1477
- s = ScriptFromHex (" 00" );
1478
- s += s;
1479
- d = ScriptFromHex (" 0000" );
1480
- BOOST_CHECK (s == d);
1481
-
1482
- // check doubling a script that's large enough to require reallocation
1483
- static const char hex[] = " 04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5f" ;
1484
- s = CScript () << ParseHex (hex) << OP_CHECKSIG;
1485
- d = CScript () << ParseHex (hex) << OP_CHECKSIG << ParseHex (hex) << OP_CHECKSIG;
1486
- s += s;
1487
- BOOST_CHECK (s == d);
1488
- }
1489
-
1490
-
1491
1473
#if defined(HAVE_CONSENSUS_LIB)
1492
1474
1493
1475
/* Test simple (successful) usage of bitcoinconsensus_verify_script */
0 commit comments