diff --git a/examples/venom.dasy b/examples/venom.dasy index 727344d..eb1d1dc 100644 --- a/examples/venom.dasy +++ b/examples/venom.dasy @@ -1,2 +1,16 @@ -(defn absoluteValue [] :external - (venom "(seq (mstore (add 32 31) 5945936342127) (mstore 0 20) (return 0 0))")) +(defn storeInMem [] :external + (venom "(seq (mstore (add 32 31) 5945936342127) + (mstore 0 20) + (return 0 0))")) + +(defn retOne [] :uint256 :external + (defvar x :uint256 0) + (venom "(mstore 64 1)") + x) + + +;; 41 gas +(defn addTwoNums [:uint256 x y] :uint256 :external + (defvar z :uint256 0) ;; first variable is at offset 64 + (venom "(mstore 64 (add (calldataload 4) (calldataload 36)))") + z) diff --git a/examples/venom_comp.vy b/examples/venom_comp.vy new file mode 100644 index 0000000..d74c574 --- /dev/null +++ b/examples/venom_comp.vy @@ -0,0 +1,11 @@ +@external +def retOne() -> uint256: + x: uint256 = 0 + x = 1 + return x + + +# 71 gas +@external +def addTwoNums(a: uint256, b: uint256) -> uint256: + return a + b diff --git a/tests/test_dasy.py b/tests/test_dasy.py index e04260e..a49a704 100644 --- a/tests/test_dasy.py +++ b/tests/test_dasy.py @@ -6,8 +6,15 @@ def test_venom(): c = compile("examples/venom.dasy") - c.absoluteValue() + assert c.retOne() == 1 +def test_compare_venom_vyper(): + c = compile("examples/venom.dasy") + v = boa.load("examples/venom_comp.vy") + + for contract in [c, v]: + assert contract.retOne() == 1 + assert contract.addTwoNums(1, 2) == 3 def compile_src(src: str, *args) -> VyperContract: ast = dasy.compile(src, include_abi=True)