Skip to content

Commit a54b056

Browse files
authored
Merge pull request #17 from davxy/v0.6.6-rc0
V0.6.6 rc0
2 parents 4d2944d + 19f2152 commit a54b056

File tree

986 files changed

+128296
-70934
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

986 files changed

+128296
-70934
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ jobs:
1717
matrix:
1818
validator:
1919
- codec
20+
- traces
2021
- stf/accumulate
2122
- stf/assurances
2223
- stf/authorizations

README.md

Lines changed: 13 additions & 0 deletions

lib/bin_to_json.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,16 @@ def decode(self):
3131
return decoded
3232

3333

34-
def convert_to_json(filename, subsystem_type):
34+
def convert_to_json(filename, subsystem_type, spec_name = None):
35+
if spec_name in ("tiny", "full"):
36+
spec.set_spec(spec_name)
37+
print("* Converting:", filename)
3538
with open(filename, 'rb') as file:
3639
blob = file.read()
3740
scale_bytes = ScaleBytes(blob)
3841
dump = subsystem_type(data=scale_bytes)
3942
decoded = dump.decode()
40-
json_filename = filename.replace('.bin', '.json')
43+
json_filename = str(filename).replace('.bin', '.json')
4144
with open(json_filename, 'w') as json_file:
4245
json.dump(decoded, json_file, indent=4)
4346
json_file.write('\n')
@@ -47,5 +50,4 @@ def convert_group(group_name, spec_name, subsystem_type):
4750
spec.set_spec(spec_name)
4851
print(f"\n[Converting {group_name} ({spec_name})]")
4952
for file in glob.glob(f"{spec_name}/*.bin"):
50-
print("* Converting:", file)
5153
convert_to_json(file, subsystem_type)

lib/validate_asn1.py

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -76,24 +76,30 @@ def path_to_type_name(path):
7676
return name
7777

7878

79-
def validate(schema, json_file, json_tweaks_callback=None):
79+
def validate(schema, json_file, root_type = None, json_tweaks_callback = None):
8080
"""Validate a JSON file against an ASN.1 schema.
8181
82-
The root type for decoding is determined as follows:
83-
- If the schema contains "TestCase", use that type
84-
- Otherwise, derive the type from the filename (e.g., "my_type.json" → "MyType")
85-
8682
Args:
8783
schema: Compiled ASN.1 schema
8884
json_file: Path to JSON file to validate
85+
root_type_name: Optional schema type name to be used to parse the json_file
8986
json_tweaks_callback: Optional callback to modify JSON before validation
87+
88+
If the `root_type_name` arg is None or is not present in the schema, then the root
89+
type for decoding is determined as follows:
90+
- If the schema contains "TestCase", use that type
91+
- Otherwise, derive the type from the filename (e.g., "my_type.json" → "MyType")
92+
9093
"""
94+
print("* Validating:", json_file)
95+
9196
# Determine root type used for decoding
92-
if "TestCase" in schema.types:
93-
root_type = "TestCase"
94-
else:
95-
# Auto-detect root type from filename
96-
root_type = path_to_type_name(json_file)
97+
if root_type is None:
98+
if "TestCase" in schema.types:
99+
root_type = "TestCase"
100+
else:
101+
# Auto-detect root type from filename
102+
root_type = path_to_type_name(json_file)
97103

98104
# Read and prepare JSON
99105
with open(json_file, "rb") as f:
@@ -121,7 +127,7 @@ def validate_group(group_name, group_schema, spec_name, json_tweaks_callback=Non
121127
Args:
122128
group_name: Name of the validation group (for display)
123129
group_schema: ASN.1 schema file name (or None for base schema only)
124-
spec_name: Specification name ("tiny", "full", or "data")
130+
spec_name: Specification name ("tiny", "full")
125131
json_tweaks_callback: Optional callback to modify JSON before validation
126132
"""
127133
print(f"\n[Validating {group_name} ({spec_name})]")
@@ -134,5 +140,4 @@ def validate_group(group_name, group_schema, spec_name, json_tweaks_callback=Non
134140
# Compile schema and validate all JSON files
135141
schema = asn1tools.compile_files(schema_files, codec="jer")
136142
for json_file in glob.glob(f"{spec_name}/*.json"):
137-
print("* Validating:", json_file)
138-
validate(schema, json_file, json_tweaks_callback)
143+
validate(schema, json_file, None, json_tweaks_callback)

scripts/convert-all.sh

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/bin/bash
2+
3+
# Get the directory containing this script
4+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
5+
6+
# Get the parent directory
7+
PARENT_DIR="$(dirname "$SCRIPT_DIR")"
8+
9+
# Check if jam_types python library can be imported
10+
if ! python3 -c "import jam_types" 2>/dev/null; then
11+
echo "Error: We depend on jam-types. Please install the jam_types Python library." >&2
12+
exit 1
13+
fi
14+
15+
echo "Searching for convert.py scripts in: $PARENT_DIR"
16+
17+
# Find all convert.py files and execute them
18+
find "$PARENT_DIR" -name "convert.py" -type f | while read -r convert_script; do
19+
echo "Executing: $convert_script"
20+
cd "$(dirname "$convert_script")"
21+
python3 "$(basename "$convert_script")"
22+
done
23+
24+
echo "All convert.py scripts have been executed."

scripts/validate-all.sh

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/bin/bash
2+
3+
# Get the directory containing this script
4+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
5+
6+
# Get the parent directory
7+
PARENT_DIR="$(dirname "$SCRIPT_DIR")"
8+
9+
# Check if jam_types python library can be imported
10+
if ! python3 -c "import asn1tools" 2>/dev/null; then
11+
echo "Error: We depend on asn1tools. Please install the asn1tools Python library." >&2
12+
exit 1
13+
fi
14+
15+
echo "Searching for validate.py scripts in: $PARENT_DIR"
16+
17+
# Find all validate.py files and execute them
18+
find "$PARENT_DIR" -name "validate.py" -type f | while read -r validate_script; do
19+
echo "Executing: $validate_script"
20+
cd "$(dirname "$validate_script")"
21+
python3 "$(basename "$validate_script")"
22+
done
23+
24+
echo "All validate.py scripts have been executed."
11 KB
Binary file not shown.

stf/accumulate/full/accumulate_ready_queued_reports-1.json

Lines changed: 20 additions & 20 deletions
Large diffs are not rendered by default.
11 KB
Binary file not shown.

stf/accumulate/full/enqueue_and_unlock_chain-1.json

Lines changed: 14 additions & 14 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)