File tree Expand file tree Collapse file tree 4 files changed +45
-38
lines changed Expand file tree Collapse file tree 4 files changed +45
-38
lines changed Original file line number Diff line number Diff line change 11import test_suite .context_pb2 as context_pb
22import fd58
3- from test_suite .fuzz_interface import encode_hex_compact , decode_hex_compact
3+ import re
4+
5+
6+ def decode_hex_compact (encoded ):
7+ res = bytearray ()
8+ parts = re .split (r"\.\.\.(\d+) zeros\.\.\." , encoded .decode ("ascii" ))
9+
10+ for i , part in enumerate (parts ):
11+ if i % 2 == 0 :
12+ # Regular hex part
13+ res .extend (bytes .fromhex (part ))
14+ else :
15+ # Skipped zeros part
16+ res .extend (b"\x00 " * int (part ))
17+
18+ return bytes (res )
19+
20+
21+ def encode_hex_compact (buf , gap = 16 ):
22+ res = ""
23+ skipped = 0
24+ for i in range (0 , len (buf ), gap ):
25+ row = buf [i : i + gap ]
26+ if row == bytes ([0 ] * len (row )):
27+ skipped += len (row )
28+ else :
29+ if skipped > 0 :
30+ res += f"...{ skipped } zeros..."
31+ res += "" .join ([f"{ b :0>2x} " for b in buf [i : i + gap ]])
32+ skipped = 0
33+ if skipped > 0 :
34+ res += f"...{ skipped } zeros..."
35+ return bytes (res , "ascii" )
436
537
638def encode_acct_state (acct_state : context_pb .AcctState ):
Original file line number Diff line number Diff line change 11from typing import Callable , Type , TypeVar
22from google .protobuf import message , descriptor , message_factory
33from dataclasses import dataclass , InitVar , field
4- import re
54
65msg_factory = message_factory .MessageFactory ()
76
2726"""
2827
2928
30- def decode_hex_compact (encoded ):
31- res = bytearray ()
32- parts = re .split (r"\.\.\.(\d+) zeros\.\.\." , encoded .decode ("ascii" ))
33-
34- for i , part in enumerate (parts ):
35- if i % 2 == 0 :
36- # Regular hex part
37- res .extend (bytes .fromhex (part ))
38- else :
39- # Skipped zeros part
40- res .extend (b"\x00 " * int (part ))
41-
42- return bytes (res )
43-
44-
45- def encode_hex_compact (buf , gap = 16 ):
46- res = ""
47- skipped = 0
48- for i in range (0 , len (buf ), gap ):
49- row = buf [i : i + gap ]
50- if row == bytes ([0 ] * len (row )):
51- skipped += len (row )
52- else :
53- if skipped > 0 :
54- res += f"...{ skipped } zeros..."
55- res += "" .join ([f"{ b :0>2x} " for b in buf [i : i + gap ]])
56- skipped = 0
57- if skipped > 0 :
58- res += f"...{ skipped } zeros..."
59- return bytes (res , "ascii" )
60-
61-
6229def generic_effects_prune (
6330 ctx : ContextType | None , effects : dict [str , str | None ]
6431) -> dict [str , str | None ] | None :
Original file line number Diff line number Diff line change 11import fd58
2- from 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
2+ from test_suite .context .codec_utils import (
3+ decode_acct_state ,
4+ decode_hex_compact ,
5+ encode_acct_state ,
6+ encode_hex_compact ,
7+ )
48import test_suite .invoke_pb2 as invoke_pb
59
610
Original file line number Diff line number Diff line change 11import fd58
2- from 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
2+ from test_suite .context .codec_utils import (
3+ decode_acct_state ,
4+ decode_hex_compact ,
5+ encode_acct_state ,
6+ encode_hex_compact ,
7+ )
48import test_suite .txn_pb2 as txn_pb
59
610
You can’t perform that action at this time.
0 commit comments