tx.file.format(): remove false boolean values from outputs
This commit is contained in:
parent
b3bda1b62b
commit
73efa84b48
2 changed files with 12 additions and 2 deletions
|
|
@ -269,7 +269,8 @@ class MMGenTxFile(MMGenObject):
|
|||
k: getattr(tx, k) for k in self.attrs
|
||||
} | {
|
||||
'inputs': [e._asdict() for e in tx.inputs],
|
||||
'outputs': [e._asdict() for e in tx.outputs]
|
||||
'outputs': [{k:v for k,v in e._asdict().items() if not (type(v) is bool and v is False)}
|
||||
for e in tx.outputs]
|
||||
} | {
|
||||
k: getattr(tx, k) for k in self.extra_attrs if getattr(tx, k)
|
||||
})
|
||||
|
|
|
|||
|
|
@ -30,10 +30,19 @@ async def do_txfile_test(desc, fns, cfg=cfg, check=False):
|
|||
assert fn_gen == os.path.basename(fn), f'{fn_gen} != {fn}'
|
||||
|
||||
if check:
|
||||
import json
|
||||
from mmgen.tx.file import json_dumps
|
||||
from mmgen.util import make_chksum_6
|
||||
text = f.format()
|
||||
with open(fpath) as fh:
|
||||
text_chk = fh.read()
|
||||
assert text == text_chk, f'\nformatted text:\n{text}\n !=\noriginal file:\n{text_chk}'
|
||||
data_chk = json.loads(text_chk)
|
||||
outputs = data_chk['MMGenTransaction']['outputs']
|
||||
for n, o in enumerate(outputs):
|
||||
outputs[n] = {k:v for k,v in o.items() if not (type(v) is bool and v is False)}
|
||||
data_chk['chksum'] = make_chksum_6(json_dumps(data_chk['MMGenTransaction']))
|
||||
text_chk_fixed = json_dumps(data_chk)
|
||||
assert text == text_chk_fixed, f'\nformatted text:\n{text}\n !=\noriginal file:\n{text_chk_fixed}'
|
||||
|
||||
qmsg(' OK')
|
||||
return True
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue