MCPcopy Index your code
hub / github.com/btcsuite/btcd / tstCheckScriptError

Function tstCheckScriptError

txscript/stack_test.go:18–45  ·  view source on GitHub ↗

tstCheckScriptError ensures the type of the two passed errors are of the same type (either both nil or both of type Error) and their error codes match when not nil.

(gotErr, wantErr error)

Source from the content-addressed store, hash-verified

16// same type (either both nil or both of type Error) and their error codes
17// match when not nil.
18func tstCheckScriptError(gotErr, wantErr error) error {
19 // Ensure the error code is of the expected type and the error
20 // code matches the value specified in the test instance.
21 if reflect.TypeOf(gotErr) != reflect.TypeOf(wantErr) {
22 return fmt.Errorf("wrong error - got %T (%[1]v), want %T",
23 gotErr, wantErr)
24 }
25 if gotErr == nil {
26 return nil
27 }
28
29 // Ensure the want error type is a script error.
30 werr, ok := wantErr.(Error)
31 if !ok {
32 return fmt.Errorf("unexpected test error type %T", wantErr)
33 }
34
35 // Ensure the error codes match. It's safe to use a raw type assert
36 // here since the code above already proved they are the same type and
37 // the want error is a script error.
38 gotErrorCode := gotErr.(Error).ErrorCode
39 if gotErrorCode != werr.ErrorCode {
40 return fmt.Errorf("mismatched error code - got %v (%v), want %v",
41 gotErrorCode, gotErr, werr.ErrorCode)
42 }
43
44 return nil
45}
46
47// TestStack tests that all of the stack operations work as expected.
48func TestStack(t *testing.T) {

Callers 9

TestMakeScriptNumFunction · 0.85
TestStackFunction · 0.85
TestRemoveOpcodesFunction · 0.85
TestRemoveOpcodeByDataFunction · 0.85
TestCalcScriptInfoFunction · 0.85
TestPayToAddrScriptFunction · 0.85
TestMultiSigScriptFunction · 0.85
TestCalcMultiSigStatsFunction · 0.85
TestNullDataScriptFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…