Skip to content

Commit

Permalink
first set of test, add versioning in multi
Browse files Browse the repository at this point in the history
  • Loading branch information
ahangsu committed Jul 12, 2022
1 parent ff16945 commit 23580f9
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
25 changes: 24 additions & 1 deletion pyteal/ast/box_test.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,28 @@
# import pytest
import pytest
import pyteal as pt

teal6Options = pt.CompileOptions(version=6)
teal7Options = pt.CompileOptions(version=7)


def test_compile_version_correct():
with pytest.raises(pt.TealInputError):
pt.Box.create(pt.Bytes("box"), pt.Int(10)).__teal__(teal6Options)

with pytest.raises(pt.TealInputError):
pt.Box.delete(pt.Bytes("box")).__teal__(teal6Options)

with pytest.raises(pt.TealInputError):
pt.Box.extract(pt.Bytes("box"), pt.Int(2), pt.Int(4)).__teal__(teal6Options)

with pytest.raises(pt.TealInputError):
pt.Box.replace(pt.Bytes("box"), pt.Int(3), pt.Bytes("replace-str")).__teal__(teal6Options)

with pytest.raises(pt.TealInputError):
pt.Box.length(pt.Bytes("box")).__teal__(teal6Options)

with pytest.raises(pt.TealInputError):
pt.Box.get(pt.Bytes("box")).__teal__(teal6Options)

with pytest.raises(pt.TealInputError):
pt.Box.put(pt.Bytes("box"), pt.Bytes("goonery")).__teal__(teal6Options)
7 changes: 7 additions & 0 deletions pyteal/ast/multi.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
from pyteal.ast.scratch import ScratchSlot
from pyteal.ast.seq import Seq

from pyteal.errors import TealInputError

if TYPE_CHECKING:
from pyteal.compiler import CompileOptions

Expand Down Expand Up @@ -57,6 +59,11 @@ def __str__(self):
return ret_str

def __teal__(self, options: "CompileOptions"):
if options.version < self.op.min_version:
raise TealInputError(
f"{self.op} not available on teal version {options.version} (first available {self.op.min_version})"
)

tealOp = TealOp(self, self.op, *self.immediate_args)
callStart, callEnd = TealBlock.FromOp(options, tealOp, *self.args)

Expand Down

0 comments on commit 23580f9

Please sign in to comment.