mirror of
https://github.com/btcsuite/btcd.git
synced 2024-11-19 18:00:11 +01:00
Test empty scripts and out of bounds for DisasmScript()
give disasmscript a defined error return for out of bounds.
This commit is contained in:
parent
244ce4b96e
commit
e5a2756795
@ -3885,12 +3885,25 @@ func testOpcode(t *testing.T, test *detailedTest) {
|
||||
// disassemble.
|
||||
var disScript, disPC string
|
||||
if test.disassembly != "" {
|
||||
var err error
|
||||
dis0, err := engine.DisasmScript(0)
|
||||
if err != nil {
|
||||
t.Errorf("failed to disassemble script0 for %s: %v",
|
||||
test.name, err)
|
||||
}
|
||||
if dis0 != "" {
|
||||
t.Errorf("disassembly of empty script gave \"%s\"",
|
||||
test.name, dis0)
|
||||
}
|
||||
disScript, err = engine.DisasmScript(1)
|
||||
if err != nil {
|
||||
t.Errorf("failed to disassemble script for %s: %v",
|
||||
test.name, err)
|
||||
}
|
||||
_, err = engine.DisasmScript(2)
|
||||
if err != btcscript.StackErrInvalidIndex {
|
||||
t.Errorf("%s: got unexpected error for invalid "+
|
||||
"disassembly index: \"%v\"", test.name, err)
|
||||
}
|
||||
}
|
||||
|
||||
done := false
|
||||
|
@ -100,6 +100,10 @@ var StackErrInvalidParseType = errors.New("internal error: invalid parsetype fou
|
||||
// ony if the internal data tables are wrong.
|
||||
var StackErrInvalidAddrOffset = errors.New("internal error: invalid offset found")
|
||||
|
||||
// StackErrInvalidIndex is returned when an out-of-bounds index was passed to
|
||||
// a function.
|
||||
var StackErrInvalidIndex = errors.New("Invalid script index")
|
||||
|
||||
// Bip16Activation is the timestamp where BIP0016 is valid to use in the
|
||||
// blockchain. To be used to determine if BIP0016 should be called for or not.
|
||||
// This timestamp corresponds to Sun Apr 1 00:00:00 UTC 2012.
|
||||
@ -521,7 +525,7 @@ func (m *Script) validPC() error {
|
||||
// ``idx''. Where 0 is the scriptSig and 1 is the scriptPubKey.
|
||||
func (m *Script) DisasmScript(idx int) (disstr string, err error) {
|
||||
if idx >= len(m.scripts) {
|
||||
return "", fmt.Errorf("Invalid script index")
|
||||
return "", StackErrInvalidIndex
|
||||
}
|
||||
for i := range m.scripts[idx] {
|
||||
disstr = disstr + m.disasm(idx, i) + "\n"
|
||||
|
@ -59,80 +59,80 @@ github.com/conformal/btcscript/stack.go Stack.PickN 100.00% (5/5)
|
||||
github.com/conformal/btcscript/stack.go Stack.RollN 100.00% (5/5)
|
||||
github.com/conformal/btcscript/script.go removeOpcode 100.00% (5/5)
|
||||
github.com/conformal/btcscript/script.go Script.validPC 100.00% (5/5)
|
||||
github.com/conformal/btcscript/stack.go asBool 100.00% (4/4)
|
||||
github.com/conformal/btcscript/script.go getStack 100.00% (4/4)
|
||||
github.com/conformal/btcscript/stack.go Stack.PopBool 100.00% (4/4)
|
||||
github.com/conformal/btcscript/stack.go Stack.PopInt 100.00% (4/4)
|
||||
github.com/conformal/btcscript/opcode.go opcodeNumEqualVerify 100.00% (4/4)
|
||||
github.com/conformal/btcscript/stack.go Stack.PeekInt 100.00% (4/4)
|
||||
github.com/conformal/btcscript/stack.go Stack.PeekByteArray 100.00% (4/4)
|
||||
github.com/conformal/btcscript/script.go Script.DisasmScript 100.00% (5/5)
|
||||
github.com/conformal/btcscript/opcode.go opcodeCheckMultiSigVerify 100.00% (4/4)
|
||||
github.com/conformal/btcscript/script.go GetSigOpCount 100.00% (4/4)
|
||||
github.com/conformal/btcscript/opcode.go opcodeEqualVerify 100.00% (4/4)
|
||||
github.com/conformal/btcscript/script.go Script.DisasmPC 100.00% (4/4)
|
||||
github.com/conformal/btcscript/opcode.go opcodeEndif 100.00% (4/4)
|
||||
github.com/conformal/btcscript/script.go Script.curPC 100.00% (4/4)
|
||||
github.com/conformal/btcscript/script.go isPushOnly 100.00% (4/4)
|
||||
github.com/conformal/btcscript/script.go IsPayToScriptHash 100.00% (4/4)
|
||||
github.com/conformal/btcscript/script.go unparseScript 100.00% (4/4)
|
||||
github.com/conformal/btcscript/script.go getStack 100.00% (4/4)
|
||||
github.com/conformal/btcscript/opcode.go opcodeNumEqualVerify 100.00% (4/4)
|
||||
github.com/conformal/btcscript/stack.go Stack.PopBool 100.00% (4/4)
|
||||
github.com/conformal/btcscript/stack.go asBool 100.00% (4/4)
|
||||
github.com/conformal/btcscript/stack.go Stack.PeekByteArray 100.00% (4/4)
|
||||
github.com/conformal/btcscript/stack.go Stack.PeekInt 100.00% (4/4)
|
||||
github.com/conformal/btcscript/stack.go Stack.PopInt 100.00% (4/4)
|
||||
github.com/conformal/btcscript/script.go GetSigOpCount 100.00% (4/4)
|
||||
github.com/conformal/btcscript/stack.go Stack.PeekBool 100.00% (4/4)
|
||||
github.com/conformal/btcscript/script.go scriptUInt32 100.00% (3/3)
|
||||
github.com/conformal/btcscript/script.go scriptUInt16 100.00% (3/3)
|
||||
github.com/conformal/btcscript/address.go ScriptType.String 100.00% (3/3)
|
||||
github.com/conformal/btcscript/script.go scriptUInt8 100.00% (3/3)
|
||||
github.com/conformal/btcscript/script.go unparseScript 100.00% (4/4)
|
||||
github.com/conformal/btcscript/script.go IsPayToScriptHash 100.00% (4/4)
|
||||
github.com/conformal/btcscript/script.go isPushOnly 100.00% (4/4)
|
||||
github.com/conformal/btcscript/script.go Script.curPC 100.00% (4/4)
|
||||
github.com/conformal/btcscript/script.go Script.DisasmPC 100.00% (4/4)
|
||||
github.com/conformal/btcscript/opcode.go opcodeEqualVerify 100.00% (4/4)
|
||||
github.com/conformal/btcscript/script.go setStack 100.00% (3/3)
|
||||
github.com/conformal/btcscript/stack.go fromBool 100.00% (3/3)
|
||||
github.com/conformal/btcscript/opcode.go opcodeDepth 100.00% (2/2)
|
||||
github.com/conformal/btcscript/opcode.go opcodeCodeSeparator 100.00% (2/2)
|
||||
github.com/conformal/btcscript/script.go scriptUInt8 100.00% (3/3)
|
||||
github.com/conformal/btcscript/address.go ScriptType.String 100.00% (3/3)
|
||||
github.com/conformal/btcscript/script.go scriptUInt16 100.00% (3/3)
|
||||
github.com/conformal/btcscript/script.go scriptUInt32 100.00% (3/3)
|
||||
github.com/conformal/btcscript/opcode.go opcodeFalse 100.00% (2/2)
|
||||
github.com/conformal/btcscript/opcode.go opcodeN 100.00% (2/2)
|
||||
github.com/conformal/btcscript/address.go ScriptToAddress 100.00% (2/2)
|
||||
github.com/conformal/btcscript/opcode.go calcHash 100.00% (2/2)
|
||||
github.com/conformal/btcscript/opcode.go opcodeCodeSeparator 100.00% (2/2)
|
||||
github.com/conformal/btcscript/opcode.go opcode1Negate 100.00% (2/2)
|
||||
github.com/conformal/btcscript/opcode.go opcodePushData 100.00% (2/2)
|
||||
github.com/conformal/btcscript/stack.go Stack.Depth 100.00% (2/2)
|
||||
github.com/conformal/btcscript/stack.go Stack.NipN 100.00% (2/2)
|
||||
github.com/conformal/btcscript/opcode.go opcodePushData 100.00% (2/2)
|
||||
github.com/conformal/btcscript/address.go ScriptToAddress 100.00% (2/2)
|
||||
github.com/conformal/btcscript/opcode.go opcodeFalse 100.00% (2/2)
|
||||
github.com/conformal/btcscript/opcode.go opcodeInvalid 100.00% (1/1)
|
||||
github.com/conformal/btcscript/opcode.go opcodeReserved 100.00% (1/1)
|
||||
github.com/conformal/btcscript/opcode.go opcodeTuck 100.00% (1/1)
|
||||
github.com/conformal/btcscript/opcode.go opcode2Dup 100.00% (1/1)
|
||||
github.com/conformal/btcscript/opcode.go opcode3Dup 100.00% (1/1)
|
||||
github.com/conformal/btcscript/opcode.go opcode2Over 100.00% (1/1)
|
||||
github.com/conformal/btcscript/opcode.go opcode2Rot 100.00% (1/1)
|
||||
github.com/conformal/btcscript/stack.go Stack.PopByteArray 100.00% (1/1)
|
||||
github.com/conformal/btcscript/opcode.go opcodeSwap 100.00% (1/1)
|
||||
github.com/conformal/btcscript/stack.go Stack.PushInt 100.00% (1/1)
|
||||
github.com/conformal/btcscript/opcode.go opcodeRot 100.00% (1/1)
|
||||
github.com/conformal/btcscript/stack.go Stack.PushByteArray 100.00% (1/1)
|
||||
github.com/conformal/btcscript/opcode.go opcode2Drop 100.00% (1/1)
|
||||
github.com/conformal/btcscript/opcode.go opcodeDisabled 100.00% (1/1)
|
||||
github.com/conformal/btcscript/opcode.go opcodeDepth 100.00% (2/2)
|
||||
github.com/conformal/btcscript/opcode.go opcodeOver 100.00% (1/1)
|
||||
github.com/conformal/btcscript/opcode.go opcodeNip 100.00% (1/1)
|
||||
github.com/conformal/btcscript/script.go Script.SetAltStack 100.00% (1/1)
|
||||
github.com/conformal/btcscript/opcode.go opcodeDup 100.00% (1/1)
|
||||
github.com/conformal/btcscript/log.go init 100.00% (1/1)
|
||||
github.com/conformal/btcscript/opcode.go init 100.00% (1/1)
|
||||
github.com/conformal/btcscript/stack.go Stack.PushBool 100.00% (1/1)
|
||||
github.com/conformal/btcscript/script.go Script.GetAltStack 100.00% (1/1)
|
||||
github.com/conformal/btcscript/script.go Script.subScript 100.00% (1/1)
|
||||
github.com/conformal/btcscript/script.go Script.SetStack 100.00% (1/1)
|
||||
github.com/conformal/btcscript/opcode.go opcodeDrop 100.00% (1/1)
|
||||
github.com/conformal/btcscript/script.go isPubkey 100.00% (1/1)
|
||||
github.com/conformal/btcscript/script.go isPubkeyHash 100.00% (1/1)
|
||||
github.com/conformal/btcscript/script.go isScriptHash 100.00% (1/1)
|
||||
github.com/conformal/btcscript/script.go Script.GetStack 100.00% (1/1)
|
||||
github.com/conformal/btcscript/opcode.go opcodeNip 100.00% (1/1)
|
||||
github.com/conformal/btcscript/log.go newLogClosure 100.00% (1/1)
|
||||
github.com/conformal/btcscript/opcode.go opcodeDup 100.00% (1/1)
|
||||
github.com/conformal/btcscript/opcode.go opcodeTuck 100.00% (1/1)
|
||||
github.com/conformal/btcscript/opcode.go calcHash160 100.00% (1/1)
|
||||
github.com/conformal/btcscript/stack.go Stack.PushByteArray 100.00% (1/1)
|
||||
github.com/conformal/btcscript/stack.go Stack.PushInt 100.00% (1/1)
|
||||
github.com/conformal/btcscript/stack.go Stack.PopByteArray 100.00% (1/1)
|
||||
github.com/conformal/btcscript/opcode.go opcode2Swap 100.00% (1/1)
|
||||
github.com/conformal/btcscript/log.go UseLogger 100.00% (1/1)
|
||||
github.com/conformal/btcscript/opcode.go opcodeNop 100.00% (1/1)
|
||||
github.com/conformal/btcscript/opcode.go opcodeInvalid 100.00% (1/1)
|
||||
github.com/conformal/btcscript/opcode.go opcodeReserved 100.00% (1/1)
|
||||
github.com/conformal/btcscript/opcode.go opcodeDisabled 100.00% (1/1)
|
||||
github.com/conformal/btcscript/script.go Script.SetAltStack 100.00% (1/1)
|
||||
github.com/conformal/btcscript/opcode.go opcodeSwap 100.00% (1/1)
|
||||
github.com/conformal/btcscript/opcode.go init 100.00% (1/1)
|
||||
github.com/conformal/btcscript/stack.go Stack.PushBool 100.00% (1/1)
|
||||
github.com/conformal/btcscript/script.go Script.subScript 100.00% (1/1)
|
||||
github.com/conformal/btcscript/opcode.go opcodeRot 100.00% (1/1)
|
||||
github.com/conformal/btcscript/log.go init 100.00% (1/1)
|
||||
github.com/conformal/btcscript/opcode.go opcode3Dup 100.00% (1/1)
|
||||
github.com/conformal/btcscript/opcode.go opcode2Dup 100.00% (1/1)
|
||||
github.com/conformal/btcscript/opcode.go opcode2Drop 100.00% (1/1)
|
||||
github.com/conformal/btcscript/opcode.go opcodeReturn 100.00% (1/1)
|
||||
github.com/conformal/btcscript/script.go Script.disasm 100.00% (1/1)
|
||||
github.com/conformal/btcscript/opcode.go opcodeNop 100.00% (1/1)
|
||||
github.com/conformal/btcscript/log.go DisableLog 100.00% (1/1)
|
||||
github.com/conformal/btcscript/script.go Script.GetStack 100.00% (1/1)
|
||||
github.com/conformal/btcscript/script.go Script.SetStack 100.00% (1/1)
|
||||
github.com/conformal/btcscript/script.go Script.GetAltStack 100.00% (1/1)
|
||||
github.com/conformal/btcscript/script.go Script.disasm 100.00% (1/1)
|
||||
github.com/conformal/btcscript/log.go UseLogger 100.00% (1/1)
|
||||
github.com/conformal/btcscript/opcode.go opcodeDrop 100.00% (1/1)
|
||||
github.com/conformal/btcscript/opcode.go opcode2Rot 100.00% (1/1)
|
||||
github.com/conformal/btcscript/opcode.go opcode2Over 100.00% (1/1)
|
||||
github.com/conformal/btcscript/opcode.go opcodeCheckMultiSig 98.21% (55/56)
|
||||
github.com/conformal/btcscript/script.go parseScript 96.88% (31/32)
|
||||
github.com/conformal/btcscript/opcode.go opcodeCheckSig 96.15% (25/26)
|
||||
github.com/conformal/btcscript/script.go Script.DisasmScript 80.00% (4/5)
|
||||
github.com/conformal/btcscript/script.go Script.CheckErrorCondition 78.57% (11/14)
|
||||
github.com/conformal/btcscript/opcode.go opcodeCheckSigVerify 75.00% (3/4)
|
||||
github.com/conformal/btcscript/script.go Script.calcScriptHash 71.43% (25/35)
|
||||
@ -140,5 +140,5 @@ github.com/conformal/btcscript/opcode.go opcodeSha1 60.00% (3/5)
|
||||
github.com/conformal/btcscript/script.go Script.Execute 44.44% (8/18)
|
||||
github.com/conformal/btcscript/log.go SetLogWriter 0.00% (0/7)
|
||||
github.com/conformal/btcscript/log.go logClosure.String 0.00% (0/1)
|
||||
github.com/conformal/btcscript -------------------------- 95.92% (893/931)
|
||||
github.com/conformal/btcscript -------------------------- 96.03% (894/931)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user