Skip to content

Commit 1545299

Browse files
BitHighlanderclaude
andcommitted
fix(report): Decode line renders real values (scaled amounts, 0x.. addrs), not arg names twice
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent 2b924bf commit 1545299

1 file changed

Lines changed: 25 additions & 2 deletions

File tree

scripts/generate-test-report.py

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -342,8 +342,31 @@ def _v_catalog_tests(start_id=17):
342342
if f['key'] == 'aave-v3-supply':
343343
continue
344344
method = 'test_clearsign_' + f['key'].replace('-', '_').replace('.', '_')
345-
shows = '; '.join('%s: %s' % (a['name'], a['value'].decode('ascii', 'replace')
346-
if a['format'] == 4 else a['name'])
345+
346+
def _arg_shown(a):
347+
# Render what the OLED will actually show for this arg:
348+
# STRING -> the attested label; ADDRESS -> abbreviated 0x…;
349+
# TOKEN_AMOUNT -> decimal-scaled amount + symbol (or UNLIMITED).
350+
v = a['value']
351+
if a['format'] == 4: # ARG_FORMAT_STRING
352+
return v.decode('ascii', 'replace')
353+
if a['format'] == 1: # ARG_FORMAT_ADDRESS
354+
return '0x%s..%s' % (v.hex()[:4], v.hex()[-4:])
355+
if a['format'] == 5: # ARG_FORMAT_TOKEN_AMOUNT
356+
dec, symlen = v[0], v[1]
357+
sym = v[2:2+symlen].decode('ascii', 'replace')
358+
amt = v[2+symlen:]
359+
if len(amt) == 32 and amt == b'\xff' * 32:
360+
return 'UNLIMITED ' + sym
361+
n = int.from_bytes(amt, 'big')
362+
if dec:
363+
scaled = ('%f' % (n / 10 ** dec)).rstrip('0').rstrip('.')
364+
else:
365+
scaled = str(n)
366+
return '%s %s' % (scaled, sym)
367+
return a['name']
368+
369+
shows = '; '.join('%s: %s' % (a['name'], _arg_shown(a))
347370
for a in f['args'][:3])
348371
# Prefer any TOKEN_AMOUNT/ADDRESS/STRING label as the screenshot hint
349372
# so it reads like what the OLED will actually show.

0 commit comments

Comments
 (0)