MCPcopy Create free account
hub / github.com/copernet/copernicus / TestScript_IsStandardScriptPubKey_P2PKH

Function TestScript_IsStandardScriptPubKey_P2PKH

model/script/script_test.go:495–524  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

493}
494
495func 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
526func TestScript_IsStandardScriptPubKey_P2PKHNotStandard_WithoutPubKeyHash(t *testing.T) {
527 var wantPubKeys [][]byte

Callers

nothing calls this directly

Calls 10

hexToBytesFunction · 0.85
NewEmptyScriptFunction · 0.85
AddressFromStringFunction · 0.85
PushOpCodeMethod · 0.80
PushSingleDataMethod · 0.80
ExtractDestinationsMethod · 0.80
StringMethod · 0.65
EqualMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected