(t *testing.T)
| 493 | } |
| 494 | |
| 495 | func TestScript_IsStandardScriptPubKey_P2PKH(t *testing.T) { |
| 496 | wantPubKeyType := ScriptPubkeyHash |
| 497 | wantPubKeys := [][]byte{hexToBytes( |
| 498 | "e2b7f7d12a70737429066a449615270b6851d164")} |
| 499 | wantIsStandard := true |
| 500 | |
| 501 | testScript := NewEmptyScript() |
| 502 | testScript.PushOpCode(OP_DUP) |
| 503 | testScript.PushOpCode(OP_HASH160) |
| 504 | testScript.PushSingleData(hexToBytes("e2b7f7d12a70737429066a449615270b6851d164")) |
| 505 | testScript.PushOpCode(OP_EQUALVERIFY) |
| 506 | testScript.PushOpCode(OP_CHECKSIG) |
| 507 | |
| 508 | pubKeyType, pubKeys, isStandard := testScript.IsStandardScriptPubKey() |
| 509 | |
| 510 | assert.Equal(t, wantPubKeyType, pubKeyType) |
| 511 | assert.Equal(t, wantPubKeys, pubKeys) |
| 512 | assert.Equal(t, wantIsStandard, isStandard) |
| 513 | |
| 514 | addr, err := AddressFromString("1Mfn6gFxky3KGq848VGrdA6PsQkkzEt7xo") |
| 515 | if err != nil { |
| 516 | t.Error(err) |
| 517 | } |
| 518 | |
| 519 | sType, address, sigCountRequire, err := testScript.ExtractDestinations() |
| 520 | assert.Equal(t, wantPubKeyType, sType) |
| 521 | assert.EqualValues(t, addr.String(), address[0].String()) |
| 522 | assert.Equal(t, 1, sigCountRequire) |
| 523 | assert.NoError(t, err) |
| 524 | } |
| 525 | |
| 526 | func TestScript_IsStandardScriptPubKey_P2PKHNotStandard_WithoutPubKeyHash(t *testing.T) { |
| 527 | var wantPubKeys [][]byte |
nothing calls this directly
no test coverage detected