Skip to content

Commit

Permalink
fix(test): adjust chunk size calculation for APDU length limits
Browse files Browse the repository at this point in the history
- Subtract data length from MAX_APDU_LEN when splitting messages
- Fix chunk size calculation in deployModule and initContract
- Update split_message calls to account for header bytes
- Ensure first chunk (len + data) stays within MAX_APDU_LEN limit

Fixes APDU length overflow where first chunk (2 bytes length + data)
exceeded MAX_APDU_LEN by not accounting for the length bytes in the
available space calculation.
  • Loading branch information
keiff3r committed Dec 11, 2024
1 parent 0619980 commit b413ab5
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions tests/application_client/boilerplate_command_sender.py
Original file line number Diff line number Diff line change
Expand Up @@ -825,7 +825,7 @@ def init_contract(
raise ExceptionRAPDU(temp_response.status)
# Send the name
data = len(name).to_bytes(2, byteorder="big")
name_chunks = split_message(name, MAX_APDU_LEN)
name_chunks = split_message(name, MAX_APDU_LEN - len(data))
for i, chunk in enumerate(name_chunks):
if i == 0:
data += chunk
Expand All @@ -842,7 +842,7 @@ def init_contract(
raise ExceptionRAPDU(temp_response.status)
# Send the params
data = len(params).to_bytes(2, byteorder="big")
params_chunks = split_message(params, MAX_APDU_LEN)
params_chunks = split_message(params, MAX_APDU_LEN - len(data))
last_chunk = params_chunks.pop()
for i, chunk in enumerate(params_chunks):
if i == 0:
Expand Down

0 comments on commit b413ab5

Please sign in to comment.