-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes assert_eq always passing for U256 (#5054)
## Description The issue was occurring because `get_items_for_type_and_trait_name` was comparing an absolute call path to an external relative call path, when the second should also be absolute. `compile_fn` now checks if method is trait dummy. These changes should avoid the silent failures where a dummy method is used, instead of the proper implementation. Closes #4989 ## Checklist - [x] I have linked to any relevant issues. - [x] I have commented my code, particularly in hard-to-understand areas. - [x] I have updated the documentation where relevant (API docs, the reference, and the Sway book). - [x] I have added tests that prove my fix is effective or that my feature works. - [x] I have added (or requested a maintainer to add) the necessary `Breaking*` or `New Feature` labels where relevant. - [x] I have done my best to ensure that my PR adheres to [the Fuel Labs Code Review Standards](https://github.com/FuelLabs/rfcs/blob/master/text/code-standards/external-contributors.md). - [x] I have requested a review from the relevant team or maintainers.
- Loading branch information
Showing
12 changed files
with
140 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
test/src/e2e_vm_tests/test_programs/should_pass/stdlib/assert_eq_u256_revert/.gitignore
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
out | ||
target |
13 changes: 13 additions & 0 deletions
13
test/src/e2e_vm_tests/test_programs/should_pass/stdlib/assert_eq_u256_revert/Forc.lock
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
[[package]] | ||
name = 'assert_eq_u256_revert' | ||
source = 'member' | ||
dependencies = ['std'] | ||
|
||
[[package]] | ||
name = 'core' | ||
source = 'path+from-root-F5B942D6B862CF72' | ||
|
||
[[package]] | ||
name = 'std' | ||
source = 'path+from-root-F5B942D6B862CF72' | ||
dependencies = ['core'] |
8 changes: 8 additions & 0 deletions
8
test/src/e2e_vm_tests/test_programs/should_pass/stdlib/assert_eq_u256_revert/Forc.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
[project] | ||
authors = ["Fuel Labs <[email protected]>"] | ||
entry = "main.sw" | ||
license = "Apache-2.0" | ||
name = "assert_eq_u256_revert" | ||
|
||
[dependencies] | ||
std = { path = "../../../../../../../sway-lib-std" } |
75 changes: 75 additions & 0 deletions
75
.../e2e_vm_tests/test_programs/should_pass/stdlib/assert_eq_u256_revert/json_abi_oracle.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
{ | ||
"configurables": [], | ||
"functions": [ | ||
{ | ||
"attributes": null, | ||
"inputs": [], | ||
"name": "main", | ||
"output": { | ||
"name": "", | ||
"type": 0, | ||
"typeArguments": null | ||
} | ||
} | ||
], | ||
"loggedTypes": [ | ||
{ | ||
"logId": 0, | ||
"loggedType": { | ||
"name": "", | ||
"type": 1, | ||
"typeArguments": [] | ||
} | ||
}, | ||
{ | ||
"logId": 1, | ||
"loggedType": { | ||
"name": "", | ||
"type": 1, | ||
"typeArguments": [] | ||
} | ||
} | ||
], | ||
"messagesTypes": [], | ||
"types": [ | ||
{ | ||
"components": [], | ||
"type": "()", | ||
"typeId": 0, | ||
"typeParameters": null | ||
}, | ||
{ | ||
"components": [ | ||
{ | ||
"name": "a", | ||
"type": 2, | ||
"typeArguments": null | ||
}, | ||
{ | ||
"name": "b", | ||
"type": 2, | ||
"typeArguments": null | ||
}, | ||
{ | ||
"name": "c", | ||
"type": 2, | ||
"typeArguments": null | ||
}, | ||
{ | ||
"name": "d", | ||
"type": 2, | ||
"typeArguments": null | ||
} | ||
], | ||
"type": "struct std::u256::U256", | ||
"typeId": 1, | ||
"typeParameters": null | ||
}, | ||
{ | ||
"components": null, | ||
"type": "u64", | ||
"typeId": 2, | ||
"typeParameters": null | ||
} | ||
] | ||
} |
9 changes: 9 additions & 0 deletions
9
test/src/e2e_vm_tests/test_programs/should_pass/stdlib/assert_eq_u256_revert/src/main.sw
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
script; | ||
|
||
use std::u256::*; | ||
|
||
fn main() { | ||
let five = U256::from((0, 0, 0, 5)); | ||
let two = U256::from((0, 0, 0, 2)); | ||
assert_eq(five, two); | ||
} |
3 changes: 3 additions & 0 deletions
3
test/src/e2e_vm_tests/test_programs/should_pass/stdlib/assert_eq_u256_revert/test.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
category = "run" | ||
expected_result = { action = "revert", value = -65533 } # 0xffffffffffff0003 as i64 | ||
validate_abi = true |