scriptTestName returns a descriptive test name for the given reference script test data.
(test []interface{})
| 76 | // scriptTestName returns a descriptive test name for the given reference script |
| 77 | // test data. |
| 78 | func 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. |
| 108 | func parseHex(tok string) ([]byte, error) { |
no test coverage detected
searching dependent graphs…