From 6c96690a79f415f69e9bc4667d2e70eb1440a748 Mon Sep 17 00:00:00 2001 From: z80 Date: Fri, 9 Feb 2024 00:26:23 -0500 Subject: [PATCH] fix: tests should run under anchored evm version --- dasy/compiler.py | 2 +- examples/reference_types.dasy | 1 - tests/test_dasy.py | 45 +++++++++++++++++++---------------- 3 files changed, 25 insertions(+), 23 deletions(-) diff --git a/dasy/compiler.py b/dasy/compiler.py index 34dc2f7..27b9269 100644 --- a/dasy/compiler.py +++ b/dasy/compiler.py @@ -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, diff --git a/examples/reference_types.dasy b/examples/reference_types.dasy index a9cbf6b..4fcb65c 100644 --- a/examples/reference_types.dasy +++ b/examples/reference_types.dasy @@ -1,4 +1,3 @@ -(pragma :evm-version "cancun") (defstruct Person name (string 100) age :uint256) diff --git a/tests/test_dasy.py b/tests/test_dasy.py index 2a335af..f7e4530 100644 --- a/tests/test_dasy.py +++ b/tests/test_dasy.py @@ -1,3 +1,4 @@ +from vyper.evm.opcodes import anchor_evm_version import dasy from boa.vyper.contract import VyperContract import boa @@ -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(): @@ -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():