Skip to content

Commit

Permalink
Test for nested subcontracts
Browse files Browse the repository at this point in the history
  • Loading branch information
alexcere committed Jan 21, 2025
1 parent 5adbb0d commit 325fdde
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 0 deletions.
35 changes: 35 additions & 0 deletions tests/nested_subcontracts.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
contract C {
uint public x = msg.value - 10;
constructor() payable {}
}

contract E {
uint public x = msg.value - 10;
constructor() payable {
unchecked {
new C();
}
}
}

contract D {
function f() public {
unchecked {
new C();
}
}
}

contract F {
function f() public {
unchecked {
new E();
new D();
}
}
}
// ----
// f() -> FAILURE, hex"4e487b71", 0x11
// g(), 100 wei -> 1
// gas legacy: 76780
// gas legacy code: 23600
26 changes: 26 additions & 0 deletions tests/test_structure.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import pytest
import os
from argparse import Namespace
from execution.main_execution import main


class TestStructure:

def test_nested_subcontracts(self):
"""
21/01/2025: in the version of solc that was provided in 15/01/2024, the subObjects appear as part of the
keys of a CFG Object (with "blocks" and "functions"). We have adapted the structure to fit this str
Solution: We have adapted the structure to fit this structure.
"""
# Args
# -s tests/nested_subcontracts.sol -g -v -if sol -o prueba -solc ./solc-objects
current_path = os.path.abspath(os.curdir)
os.chdir("..")
args = Namespace(
source='tests/nested_subcontracts.sol',
input_format='sol', contract=None, solc_executable='./solc-objects', folder='falla',
visualize=True, greedy=True, builtin=False)
main(args)
os.chdir(current_path)
assert True, "Falla test"

0 comments on commit 325fdde

Please sign in to comment.