lbcd/internal_test.go
Owain G. Ainsworth 8035de426b Check that the pc validation code works ok.
Add a testing only interface to set the pc and set it to a few invalid
settings to check that step and disasmPC all blow up correctly.
2013-06-19 23:31:44 +01:00

51 lines
1.4 KiB
Go

// Copyright (c) 2013 Conformal Systems LLC.
// Use of this source code is governed by an ISC
// license that can be found in the LICENSE file.
package btcscript
// this file is present to export some internal interfaces so that we can
// test them reliably.
func TstRemoveOpcode(pkscript []byte, opcode byte) ([]byte, error) {
pops, err := parseScript(pkscript)
if err != nil {
return nil, err
}
pops = removeOpcode(pops, opcode)
return unparseScript(pops), nil
}
func TstRemoveOpcodeByData(pkscript []byte, data []byte) ([]byte, error) {
pops, err := parseScript(pkscript)
if err != nil {
return nil, err
}
pops = removeOpcodeByData(pops, data)
return unparseScript(pops), nil
}
type TstScriptType scriptType
const (
TstPubKeyTy TstScriptType = TstScriptType(pubKeyTy)
TstPubKeyHashTy = TstScriptType(pubKeyHashTy)
TstScriptHashTy = TstScriptType(scriptHashTy)
TstMultiSigTy = TstScriptType(multiSigTy)
TstNonStandardTy = TstScriptType(nonStandardTy)
)
func TstTypeOfScript(script []byte) TstScriptType {
pops, err := parseScript(script)
if err != nil {
return TstNonStandardTy
}
return TstScriptType(typeOfScript(pops))
}
// TestSetPC allows the test modules to set the program counter to whatever they
// want.
func (s *Script) TstSetPC(script, off int) {
s.scriptidx = script
s.scriptoff = off
}