Skip to content

Commit

Permalink
cr
Browse files Browse the repository at this point in the history
  • Loading branch information
barnjamin committed Apr 15, 2022
1 parent af7967d commit 3e7fdfd
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
3 changes: 2 additions & 1 deletion pyteal/ast/abi/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from .string import String, StringTypeSpec
from .address import AddressTypeSpec, Address
from .address import AddressTypeSpec, Address, ADDRESS_LENGTH
from .type import TypeSpec, BaseType, ComputedValue
from .bool import BoolTypeSpec, Bool
from .uint import (
Expand Down Expand Up @@ -38,6 +38,7 @@
"StringTypeSpec",
"Address",
"AddressTypeSpec",
"ADDRESS_LENGTH",
"TypeSpec",
"BaseType",
"ComputedValue",
Expand Down
6 changes: 3 additions & 3 deletions pyteal/ast/abi/address.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
from .uint import ByteTypeSpec
from ..expr import Expr

address_length = 32
ADDRESS_LENGTH = 32


class AddressTypeSpec(StaticArrayTypeSpec):
def __init__(self) -> None:
super().__init__(ByteTypeSpec(), address_length)
super().__init__(ByteTypeSpec(), ADDRESS_LENGTH)

def new_instance(self) -> "Address":
return Address()
Expand All @@ -21,7 +21,7 @@ def __str__(self) -> str:

class Address(StaticArray):
def __init__(self) -> None:
super().__init__(AddressTypeSpec(), address_length)
super().__init__(AddressTypeSpec(), ADDRESS_LENGTH)

def type_spec(self) -> AddressTypeSpec:
return AddressTypeSpec()
Expand Down
6 changes: 2 additions & 4 deletions pyteal/ast/abi/address_test.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from .type_test import ContainerType

from ... import *

options = CompileOptions(version=5)
Expand All @@ -14,7 +12,7 @@ def test_AddressTypeSpec_is_dynamic():


def test_AddressTypeSpec_byte_length_static():
assert (abi.AddressTypeSpec()).byte_length_static() == 32
assert (abi.AddressTypeSpec()).byte_length_static() == abi.ADDRESS_LENGTH


def test_AddressTypeSpec_new_instance():
Expand Down Expand Up @@ -47,7 +45,7 @@ def test_Address_decode():
from os import urandom

value = abi.Address()
for value_to_set in [urandom(32) for x in range(10)]:
for value_to_set in [urandom(abi.ADDRESS_LENGTH) for x in range(10)]:
expr = value.decode(Bytes(value_to_set))

assert expr.type_of() == TealType.none
Expand Down

0 comments on commit 3e7fdfd

Please sign in to comment.