-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Tests complete generation for pushimmutable error
- Loading branch information
Showing
4 changed files
with
66 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
#!/usr/bin/python3 | ||
|
||
import logging | ||
from execution.main_execution import main | ||
from execution.main_execution import main, parse_args | ||
|
||
if __name__ == "__main__": | ||
# logging.basicConfig(level=logging.DEBUG) | ||
main() | ||
main(parse_args()) |
34 changes: 34 additions & 0 deletions
34
tests/reconstruct_bytecode/pushimmutable_assignimmutable.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,34 @@ | ||
{ | ||
"language": "Solidity", | ||
"sources": { | ||
"struct_storage_ptr.sol": { | ||
"content": "library L {\n\tstruct S { uint x; uint y; }\n\tfunction f(uint[] storage r, S storage s) public returns (uint, uint, uint, uint) {\n\t\tr[2] = 8;\n\t\ts.x = 7;\n\t\treturn (r[0], r[1], s.x, s.y);\n\t}\n}\ncontract C {\n\tuint8 x = 3;\n\tL.S s;\n\tuint[] r;\n\tfunction f() public returns (uint, uint, uint, uint, uint, uint) {\n\t\tr = new uint[](6);\n\t\tr[0] = 1;\n\t\tr[1] = 2;\n\t\tr[2] = 3;\n\t\ts.x = 11;\n\t\ts.y = 12;\n\t\t(uint a, uint b, uint c, uint d) = L.f(r, s);\n\t\treturn (r[2], s.x, a, b, c, d);\n\t}\n}\n// ----\n// library: L\n// f() -> 8, 7, 1, 2, 7, 12\n// gas irOptimized: 166761\n// gas legacy: 169273\n// gas legacyOptimized: 167243\n" | ||
} | ||
}, | ||
"settings": { | ||
"optimizer": { | ||
"enabled": true, | ||
"runs": 200, | ||
"details": { | ||
"peephole": false, | ||
"inliner": false, | ||
"jumpdestRemover": false, | ||
"orderLiterals": false, | ||
"deduplicate": false, | ||
"cse": false, | ||
"constantOptimizer": false | ||
} | ||
}, | ||
"outputSelection": { | ||
"*": { | ||
"*": [ | ||
"abi", | ||
"metadata", | ||
"evm.bytecode", | ||
"evm.deployedBytecode", | ||
"evm.methodIdentifiers" | ||
] | ||
} | ||
} | ||
} | ||
} |
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,28 @@ | ||
import os | ||
from argparse import Namespace | ||
from execution.main_execution import main | ||
|
||
|
||
class TestReconstructBytecode: | ||
|
||
def test_pushimmutable_assignimmutable(self): | ||
""" | ||
20/01/2025: the code generation failed because PUSHIMMUTABLE can be followed by a string that is not | ||
a hexadecimal value and ASSIGNIMMUTABLE must assign only the first builtin args. | ||
Solution: for PUSHIMMUTABLE, define the function "to_hex_default" in solution_generation.utils, which returns | ||
the corresponding hexadecimal if the value a decimal value. Otherwise, it returns the original code. | ||
For ASSIGNIMMUTABLE, introduce the first builtin arg (if any) when reconstructing the split bytecode | ||
""" | ||
# Args | ||
# -s examples/test/semanticTests/abiEncoderV1_struct_struct_storage_ptr/struct_storage_ptr_standard_input.json -g -v -if standard-json -o falla -solc ./solc-latest | ||
current_path = os.path.abspath(os.curdir) | ||
os.chdir("..") | ||
args = Namespace( | ||
source='tests/reconstruct_bytecode/pushimmutable_assignimmutable.json', | ||
input_format='standard-json', contract=None, solc_executable='./solc-latest', folder='falla', | ||
visualize=True, greedy=True, builtin=False) | ||
main(args) | ||
os.chdir(current_path) | ||
assert True, "Falla test" |