MCPcopy Create free account
hub / github.com/btcsuite/btcd / scriptTestName

Function scriptTestName

txscript/reference_test.go:78–105  ·  view source on GitHub ↗

scriptTestName returns a descriptive test name for the given reference script test data.

(test []interface{})

Source from the content-addressed store, hash-verified

76// scriptTestName returns a descriptive test name for the given reference script
77// test data.
78func scriptTestName(test []interface{}) (string, error) {
79 // Account for any optional leading witness data.
80 witnessOffset := scriptTestWitnessOffset(test)
81
82 // In addition to the optional leading witness data, the test must
83 // consist of at least a signature script, public key script, flags,
84 // and expected error. Finally, it may optionally contain a comment.
85 if len(test) < witnessOffset+scriptTestExpectedOffset+1 ||
86 len(test) > witnessOffset+scriptTestCommentOffset+1 {
87
88 return "", fmt.Errorf("invalid test length %d", len(test))
89 }
90
91 // Use the comment for the test name if one is specified, otherwise,
92 // construct the name based on the signature script, public key script,
93 // and flags.
94 var name string
95 if len(test) == witnessOffset+scriptTestCommentOffset+1 {
96 name = fmt.Sprintf("test (%s)",
97 test[witnessOffset+scriptTestCommentOffset])
98 } else {
99 name = fmt.Sprintf("test ([%s, %s, %s])",
100 test[witnessOffset+scriptTestSigScriptOffset],
101 test[witnessOffset+scriptTestPkScriptOffset],
102 test[witnessOffset+scriptTestFlagsOffset])
103 }
104 return name, nil
105}
106
107// parse hex string into a []byte.
108func parseHex(tok string) ([]byte, error) {

Callers 1

testScriptsFunction · 0.85

Calls 1

scriptTestWitnessOffsetFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…