Skip to content

Commit e194e3e

Browse files
committed
test: PSBT: eliminate magic numbers for global unsigned tx key (0)
1 parent 40c6c85 commit e194e3e

File tree

1 file changed

+5
-5
lines changed
  • test/functional/test_framework

1 file changed

+5
-5
lines changed

test/functional/test_framework/psbt.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,8 @@ def __init__(self, *, g=None, i=None, o=None):
105105
def deserialize(self, f):
106106
assert f.read(5) == b"psbt\xff"
107107
self.g = from_binary(PSBTMap, f)
108-
assert 0 in self.g.map
109-
self.tx = from_binary(CTransaction, self.g.map[0])
108+
assert PSBT_GLOBAL_UNSIGNED_TX in self.g.map
109+
self.tx = from_binary(CTransaction, self.g.map[PSBT_GLOBAL_UNSIGNED_TX])
110110
self.i = [from_binary(PSBTMap, f) for _ in self.tx.vin]
111111
self.o = [from_binary(PSBTMap, f) for _ in self.tx.vout]
112112
return self
@@ -115,8 +115,8 @@ def serialize(self):
115115
assert isinstance(self.g, PSBTMap)
116116
assert isinstance(self.i, list) and all(isinstance(x, PSBTMap) for x in self.i)
117117
assert isinstance(self.o, list) and all(isinstance(x, PSBTMap) for x in self.o)
118-
assert 0 in self.g.map
119-
tx = from_binary(CTransaction, self.g.map[0])
118+
assert PSBT_GLOBAL_UNSIGNED_TX in self.g.map
119+
tx = from_binary(CTransaction, self.g.map[PSBT_GLOBAL_UNSIGNED_TX])
120120
assert len(tx.vin) == len(self.i)
121121
assert len(tx.vout) == len(self.o)
122122

@@ -130,7 +130,7 @@ def make_blank(self):
130130
for m in self.i + self.o:
131131
m.map.clear()
132132

133-
self.g = PSBTMap(map={0: self.g.map[0]})
133+
self.g = PSBTMap(map={PSBT_GLOBAL_UNSIGNED_TX: self.g.map[PSBT_GLOBAL_UNSIGNED_TX]})
134134

135135
def to_base64(self):
136136
return base64.b64encode(self.serialize()).decode("utf8")

0 commit comments

Comments
 (0)