Skip to content

Commit

Permalink
fix: tests should run under anchored evm version
Browse files Browse the repository at this point in the history
  • Loading branch information
z80dev committed Feb 9, 2024
1 parent 909d1d3 commit 6c96690
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 23 deletions.
2 changes: 1 addition & 1 deletion dasy/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def generate_compiler_data(src: str, name="DasyContract") -> CompilerData:
(ast, settings) = parse_src(src)
settings = Settings(**settings)
version = settings.evm_version or "paris"
with anchor_evm_version(settings.evm_version):
with anchor_evm_version(version):
data = CompilerData(
"",
ast.name or name,
Expand Down
1 change: 0 additions & 1 deletion examples/reference_types.dasy
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
(pragma :evm-version "cancun")
(defstruct Person
name (string 100)
age :uint256)
Expand Down
45 changes: 24 additions & 21 deletions tests/test_dasy.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from vyper.evm.opcodes import anchor_evm_version
import dasy
from boa.vyper.contract import VyperContract
import boa
Expand Down Expand Up @@ -195,22 +196,23 @@ def test_map():


def test_reference_types():
c = compile_src(
with anchor_evm_version("cancun"):
c = compile_src(
"""
(defvar nums (array :uint256 10))
(defn memoryArrayVal [] '(:uint256 :uint256) :external
(defvar arr (array :uint256 10) self/nums)
(set-at arr 1 12)
'((get-at arr 0) (get-at arr 1)))
"""
(defvar nums (array :uint256 10))
(defn memoryArrayVal [] '(:uint256 :uint256) :external
(defvar arr (array :uint256 10) self/nums)
(set-at arr 1 12)
'((get-at arr 0) (get-at arr 1)))
"""
)
assert c.memoryArrayVal() == (0, 12)
)
assert c.memoryArrayVal() == (0, 12)

d = compile("examples/reference_types.dasy")
assert d.person() == ("Dasy", 11)
assert d.nums(0) == 123
assert d.nums(1) == 0
assert d.nums(9) == 456
d = compile("examples/reference_types.dasy")
assert d.person() == ("Dasy", 11)
assert d.nums(0) == 123
assert d.nums(1) == 0
assert d.nums(9) == 456


def test_dynarrays():
Expand Down Expand Up @@ -348,13 +350,14 @@ def testInterface():

def test_reentrancy():
# TODO: This test should fail!
c = compile("examples/nonreentrantenforcer.dasy") # noqa: F841
# v = boa.load("examples/nonreentrantenforcer.vy")
# print("vyper settings")
# print(v.compiler_data.settings)
helper = compile("examples/nonreentrant2.dasy", c.address) # noqa: F841
with boa.reverts():
helper.callback()
with anchor_evm_version("cancun"):
c = compile("examples/nonreentrantenforcer.dasy") # noqa: F841
# v = boa.load("examples/nonreentrantenforcer.vy")
# print("vyper settings")
# print(v.compiler_data.settings)
helper = compile("examples/nonreentrant2.dasy", c.address) # noqa: F841
with boa.reverts():
helper.callback()


def test_auction():
Expand Down

0 comments on commit 6c96690

Please # to comment.