MCPcopy
hub / github.com/petertodd/python-bitcoinlib / load_test_vectors

Function load_test_vectors

bitcoin/tests/test_scripteval.py:52–79  ·  view source on GitHub ↗
(name)

Source from the content-addressed store, hash-verified

50
51
52def load_test_vectors(name):
53 with open(os.path.dirname(__file__) + '/data/' + name, 'r') as fd:
54 for test_case in json.load(fd):
55 if len(test_case) == 1:
56 continue # comment
57
58 if len(test_case) == 3:
59 test_case.append('') # add missing comment
60
61 scriptSig, scriptPubKey, flags, comment = test_case
62
63 scriptSig = parse_script(scriptSig)
64 scriptPubKey = parse_script(scriptPubKey)
65
66 flag_set = set()
67 for flag in flags.split(','):
68 if flag == '' or flag == 'NONE':
69 pass
70
71 else:
72 try:
73 flag = SCRIPT_VERIFY_FLAGS_BY_NAME[flag]
74 except IndexError:
75 raise Exception('Unknown script verify flag %r' % flag)
76
77 flag_set.add(flag)
78
79 yield (scriptSig, scriptPubKey, flag_set, comment, test_case)
80
81
82class Test_EvalScript(unittest.TestCase):

Callers 2

test_script_validMethod · 0.70
test_script_invalidMethod · 0.70

Calls 1

parse_scriptFunction · 0.85

Tested by

no test coverage detected