Salvaging #15104 which adds unit tests for CompressScript function in compressor.cpp
Tested following cases for the CScript:
- CKeyID
- CScriptID
- Uncompressed CPubKey (of size: 65)
- Compressed CPubKey (of size: 32)
69 | + key.MakeNewKey(true); 70 | + CPubKey pubkey = key.GetPubKey(); 71 | + 72 | + CScript script; 73 | + script.clear(); 74 | + script << OP_DUP << OP_HASH160 << ToByteVector(pubkey.GetID()) << OP_EQUALVERIFY << OP_CHECKSIG;
nit: This could be put in one line by immediately assigning the script on the declaration: CScript script = CScript() << OP_DUP ..... << OP_CHECKSIG (also applies to the other three functions).
wouldn't assigning the script on the declaration remove the opportunity to call .clear() on it?
I don't think that calling .clear() is needed here at all, since newly constructed CScripts are empty anyway?
I don't think we need to clear() it, since the default constructor CScript() constructs a (logically) empty CScript.
ACK, thanks for adding tests.
ACK 3208906574ed07cf9c8ae7a6efa69dc20890f664 Read code, ran tests, feel free to ignore the nit!