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

Function load_test_vectors

bitcoin/tests/test_transactions.py:22–42  ·  view source on GitHub ↗
(name)

Source from the content-addressed store, hash-verified

20from bitcoin.tests.test_scripteval import parse_script
21
22def load_test_vectors(name):
23 with open(os.path.dirname(__file__) + '/data/' + name, 'r') as fd:
24 for test_case in json.load(fd):
25 # Comments designated by single length strings
26 if len(test_case) == 1:
27 continue
28 assert len(test_case) == 3
29
30 prevouts = {}
31 for json_prevout in test_case[0]:
32 assert len(json_prevout) == 3
33 n = json_prevout[1]
34 if n == -1:
35 n = 0xffffffff
36 prevout = COutPoint(lx(json_prevout[0]), n)
37 prevouts[prevout] = parse_script(json_prevout[2])
38
39 tx = CTransaction.deserialize(x(test_case[1]))
40 enforceP2SH = test_case[2]
41
42 yield (prevouts, tx, enforceP2SH)
43
44class Test_COutPoint(unittest.TestCase):
45 def test_is_null(self):

Callers 2

test_tx_validMethod · 0.70
test_tx_invalidMethod · 0.70

Calls 5

parse_scriptFunction · 0.90
COutPointClass · 0.85
lxFunction · 0.85
xFunction · 0.85
deserializeMethod · 0.45

Tested by

no test coverage detected