Skip to content

Commit

Permalink
test(output): compare python output to rust output (#9)
Browse files Browse the repository at this point in the history
* test(output): compare python output to rust output

* test(hints): add test where output is diff

* izldf,sqmdq
  • Loading branch information
0xLucqs authored Sep 21, 2023
1 parent ad32d93 commit 8d7b6fb
Show file tree
Hide file tree
Showing 12 changed files with 537 additions and 22 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ jobs:
run: rustup show
- uses: Swatinem/rust-cache@v2
- name: Run tests
run: cargo test
run: pip install cairo-lang; cargo test
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/target
build/test.zip
23 changes: 23 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ hex = "0.4.3"
starknet = { git = "https://github.com/xJonathanLEI/starknet-rs" }
uuid = { version = "1.4.0", features = ["v4", "serde"] }
reqwest = { version = "0.11.18", features = ["blocking", "json"] }
pretty_assertions = "1.4.0"

[dev-dependencies]
rstest = "0.18.2"
269 changes: 269 additions & 0 deletions build/different_output.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,269 @@
{
"attributes": [],
"builtins": [
"output"
],
"compiler_version": "0.12.2",
"data": [
"0x480680017fff8000",
"0x12",
"0x480280007ffd7fff",
"0x482680017ffd8000",
"0x1",
"0x208b7fff7fff7ffe"
],
"debug_info": {
"file_contents": {},
"instruction_locations": {
"0": {
"accessible_scopes": [
"__main__",
"__main__.main"
],
"flow_tracking_data": {
"ap_tracking": {
"group": 0,
"offset": 0
},
"reference_ids": {
"__main__.main.output_ptr": 0
}
},
"hints": [],
"inst": {
"end_col": 19,
"end_line": 4,
"input_file": {
"filename": "tests/contracts/different_output.cairo"
},
"start_col": 17,
"start_line": 4
}
},
"2": {
"accessible_scopes": [
"__main__",
"__main__.main"
],
"flow_tracking_data": {
"ap_tracking": {
"group": 0,
"offset": 1
},
"reference_ids": {
"__main__.main.a": 1,
"__main__.main.output_ptr": 0
}
},
"hints": [],
"inst": {
"end_col": 27,
"end_line": 5,
"input_file": {
"filename": "tests/contracts/different_output.cairo"
},
"start_col": 5,
"start_line": 5
}
},
"3": {
"accessible_scopes": [
"__main__",
"__main__.main"
],
"flow_tracking_data": {
"ap_tracking": {
"group": 0,
"offset": 2
},
"reference_ids": {
"__main__.main.a": 1,
"__main__.main.output_ptr": 2
}
},
"hints": [
{
"location": {
"end_col": 23,
"end_line": 8,
"input_file": {
"filename": "tests/contracts/different_output.cairo"
},
"start_col": 5,
"start_line": 8
},
"n_prefix_newlines": 0
}
],
"inst": {
"end_col": 36,
"end_line": 9,
"input_file": {
"filename": "tests/contracts/different_output.cairo"
},
"parent_location": [
{
"end_col": 35,
"end_line": 11,
"input_file": {
"filename": "tests/contracts/different_output.cairo"
},
"start_col": 25,
"start_line": 11
},
"While expanding the reference 'output_ptr' in:"
],
"start_col": 22,
"start_line": 9
}
},
"5": {
"accessible_scopes": [
"__main__",
"__main__.main"
],
"flow_tracking_data": {
"ap_tracking": {
"group": 0,
"offset": 3
},
"reference_ids": {
"__main__.main.a": 1,
"__main__.main.output_ptr": 2
}
},
"hints": [],
"inst": {
"end_col": 37,
"end_line": 11,
"input_file": {
"filename": "tests/contracts/different_output.cairo"
},
"start_col": 5,
"start_line": 11
}
}
}
},
"hints": {
"3": [
{
"accessible_scopes": [
"__main__",
"__main__.main"
],
"code": "print(ids.a)",
"flow_tracking_data": {
"ap_tracking": {
"group": 0,
"offset": 2
},
"reference_ids": {
"__main__.main.a": 1,
"__main__.main.output_ptr": 0
}
}
}
]
},
"identifiers": {
"__main__.main": {
"decorators": [],
"pc": 0,
"type": "function"
},
"__main__.main.Args": {
"full_name": "__main__.main.Args",
"members": {
"output_ptr": {
"cairo_type": "felt*",
"offset": 0
}
},
"size": 1,
"type": "struct"
},
"__main__.main.ImplicitArgs": {
"full_name": "__main__.main.ImplicitArgs",
"members": {},
"size": 0,
"type": "struct"
},
"__main__.main.Return": {
"cairo_type": "(output_ptr: felt*)",
"type": "type_definition"
},
"__main__.main.SIZEOF_LOCALS": {
"type": "const",
"value": 0
},
"__main__.main.a": {
"cairo_type": "felt",
"full_name": "__main__.main.a",
"references": [
{
"ap_tracking_data": {
"group": 0,
"offset": 1
},
"pc": 2,
"value": "[cast(ap + (-1), felt*)]"
}
],
"type": "reference"
},
"__main__.main.output_ptr": {
"cairo_type": "felt*",
"full_name": "__main__.main.output_ptr",
"references": [
{
"ap_tracking_data": {
"group": 0,
"offset": 0
},
"pc": 0,
"value": "[cast(fp + (-3), felt**)]"
},
{
"ap_tracking_data": {
"group": 0,
"offset": 2
},
"pc": 3,
"value": "cast([fp + (-3)] + 1, felt*)"
}
],
"type": "reference"
}
},
"main_scope": "__main__",
"prime": "0x800000000000011000000000000000000000000000000000000000000000001",
"reference_manager": {
"references": [
{
"ap_tracking_data": {
"group": 0,
"offset": 0
},
"pc": 0,
"value": "[cast(fp + (-3), felt**)]"
},
{
"ap_tracking_data": {
"group": 0,
"offset": 1
},
"pc": 2,
"value": "[cast(ap + (-1), felt*)]"
},
{
"ap_tracking_data": {
"group": 0,
"offset": 2
},
"pc": 3,
"value": "cast([fp + (-3)] + 1, felt*)"
}
]
}
}
Loading

0 comments on commit 8d7b6fb

Please sign in to comment.