11import fd58
22from test_suite .context .codec_utils import decode_acct_state , encode_acct_state
3+ from test_suite .fuzz_interface import decode_hex_compact , encode_hex_compact
34import test_suite .invoke_pb2 as invoke_pb
45
56
@@ -11,12 +12,18 @@ def decode_input(instruction_context: invoke_pb.InstrContext):
1112 Args:
1213 - instruction_context (invoke_pb.InstrContext): Instruction context (will be modified).
1314 """
15+ # Program ID
1416 if instruction_context .program_id :
1517 instruction_context .program_id = fd58 .dec32 (instruction_context .program_id )
1618
19+ # Accounts
1720 for i in range (len (instruction_context .accounts )):
1821 decode_acct_state (instruction_context .accounts [i ])
1922
23+ # Data
24+ if instruction_context .data :
25+ instruction_context .data = decode_hex_compact (instruction_context .data )
26+
2027
2128def encode_input (instruction_context : invoke_pb .InstrContext ):
2229 """
@@ -26,12 +33,18 @@ def encode_input(instruction_context: invoke_pb.InstrContext):
2633 Args:
2734 - instruction_context (invoke_pb.InstrContext): Instruction context (will be modified).
2835 """
36+ # Program ID
2937 if instruction_context .program_id :
3038 instruction_context .program_id = fd58 .enc32 (instruction_context .program_id )
3139
40+ # Accounts
3241 for i in range (len (instruction_context .accounts )):
3342 encode_acct_state (instruction_context .accounts [i ])
3443
44+ # Data
45+ if instruction_context .data :
46+ instruction_context .data = encode_hex_compact (instruction_context .data )
47+
3548
3649def encode_output (instruction_effects : invoke_pb .InstrEffects ):
3750 """
@@ -41,5 +54,12 @@ def encode_output(instruction_effects: invoke_pb.InstrEffects):
4154 Args:
4255 - instruction_effects (invoke_pb.InstrEffects): Instruction effects (will be modified).
4356 """
57+ # Accounts
4458 for i in range (len (instruction_effects .modified_accounts )):
4559 encode_acct_state (instruction_effects .modified_accounts [i ])
60+
61+ # Return data
62+ if instruction_effects .return_data :
63+ instruction_effects .return_data = encode_hex_compact (
64+ instruction_effects .return_data
65+ )
0 commit comments