(t *testing.T)
| 413 | } |
| 414 | |
| 415 | func TestScriptCHECKMULTISIG12(t *testing.T) { |
| 416 | var flag uint32 = script.ScriptVerifyP2SH | script.ScriptVerifyStrictEnc |
| 417 | key1 := NewPrivateKey() |
| 418 | key2 := NewPrivateKey() |
| 419 | key3 := NewPrivateKey() |
| 420 | scriptPubKey12 := script.NewEmptyScript() |
| 421 | scriptPubKey12.PushOpCode(opcodes.OP_1) |
| 422 | scriptPubKey12.PushSingleData(key1.PubKey().ToBytes()) |
| 423 | scriptPubKey12.PushSingleData(key2.PubKey().ToBytes()) |
| 424 | scriptPubKey12.PushOpCode(opcodes.OP_2) |
| 425 | scriptPubKey12.PushOpCode(opcodes.OP_CHECKMULTISIG) |
| 426 | |
| 427 | var txFrom12, txTo12 tx.Tx |
| 428 | txFrom12.AddTxOut(txout.NewTxOut(0, scriptPubKey12)) |
| 429 | txTo12.AddTxIn(txin.NewTxIn(outpoint.NewOutPoint(txFrom12.GetHash(), 0), |
| 430 | script.NewEmptyScript(), script.SequenceFinal)) |
| 431 | goodsig1 := signMultisig(scriptPubKey12, []crypto.PrivateKey{key1}, &txTo12) |
| 432 | if err := VerifyScript(&txTo12, goodsig1, scriptPubKey12, 0, 0, flag, NewScriptRealChecker()); err != nil { |
| 433 | t.Errorf("checkMultiSig fail, sk = key1, pk = key12") |
| 434 | } |
| 435 | |
| 436 | txTo12.AddTxOut(txout.NewTxOut(0, script.NewEmptyScript())) |
| 437 | if err := VerifyScript(&txTo12, goodsig1, scriptPubKey12, 0, 0, flag, NewScriptRealChecker()); err == nil { |
| 438 | t.Errorf("checkMultiSig should fail, sk = key1, pk = key12, bug sig damaged") |
| 439 | } |
| 440 | |
| 441 | goodsig2 := signMultisig(scriptPubKey12, []crypto.PrivateKey{key2}, &txTo12) |
| 442 | if err := VerifyScript(&txTo12, goodsig2, scriptPubKey12, 0, 0, flag, NewScriptRealChecker()); err != nil { |
| 443 | t.Errorf("checkMultiSig fail, sk = key2, pk = key12") |
| 444 | } |
| 445 | |
| 446 | badsig1 := signMultisig(scriptPubKey12, []crypto.PrivateKey{key3}, &txTo12) |
| 447 | if err := VerifyScript(&txTo12, badsig1, scriptPubKey12, 0, 0, flag, NewScriptRealChecker()); err == nil { |
| 448 | t.Errorf("checkMultiSig should fail, sk = key3, pk = key12") |
| 449 | } |
| 450 | } |
| 451 | |
| 452 | func TestScriptCHECKMULTISIG23(t *testing.T) { |
| 453 | var flag uint32 = script.ScriptVerifyP2SH | script.ScriptVerifyStrictEnc |
nothing calls this directly
no test coverage detected