Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

abi_roundtrip_test::test_abi_types_comprehensive() #355

Merged
merged 1 commit into from
May 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions tests/integration/abi_roundtrip_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,15 @@
abi.Tuple1[abi.Uint16],
abi.Tuple1[abi.Uint32],
abi.Tuple1[abi.Uint64],
abi.Tuple2[abi.Bool, abi.Byte],
abi.Tuple3[abi.Bool, abi.Uint64, abi.Uint32],
abi.Tuple3[abi.Byte, abi.Bool, abi.Uint64],
abi.Tuple3[abi.Uint8, abi.Byte, abi.Bool],
abi.Tuple3[abi.Uint16, abi.Uint8, abi.Byte],
abi.Tuple3[abi.Uint32, abi.Uint16, abi.Uint8],
abi.Tuple3[abi.Uint64, abi.Uint32, abi.Uint16],
abi.Tuple4[abi.Bool, abi.Byte, abi.Address, abi.String],
abi.Tuple5[abi.Bool, abi.Byte, abi.Address, abi.String, abi.Uint64],
abi.StaticArray[abi.Bool, Literal[1]],
abi.StaticArray[abi.Bool, Literal[42]],
abi.StaticArray[abi.Uint64, Literal[1]],
Expand Down Expand Up @@ -103,6 +106,35 @@ def roundtrip_setup(abi_type):
)


def test_abi_types_comprehensive():
top_level_names = {
tli.split("[")[0] if tli.startswith("pyteal") else tli.split("'")[1]
for tli in (
str(x) for x in (at[0] if isinstance(at, tuple) else at for at in ABI_TYPES)
)
}

def get_subclasses(cls):
for subclass in cls.__subclasses__():
yield from get_subclasses(subclass)
yield subclass

all_abi_names = {
str(at).split("'")[1]
for at in (
cls
for cls in abi.__dict__.values()
if isinstance(cls, type)
and issubclass(cls, abi.BaseType)
and not cls.__abstractmethods__
and cls is not abi.Tuple
)
}

missing_cases = all_abi_names - top_level_names
assert not missing_cases, f"missing round trip tests for {missing_cases}"


@pytest.mark.parametrize("abi_type", ABI_TYPES)
def test_pure_compilation(abi_type):
print(f"Pure Compilation Test for {abi_type=}")
Expand Down
87 changes: 87 additions & 0 deletions tests/integration/teal/roundtrip/app_roundtrip_(bool,byte).teal
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
#pragma version 6
txna ApplicationArgs 0
store 3
load 3
callsub roundtripper_1
store 2
byte 0x151F7C75
load 2
concat
log
int 1
return

// tuple_complement
tuplecomplement_0:
store 8
load 8
int 0
getbit
store 0
load 8
int 1
getbyte
store 1
load 0
callsub boolcomp_2
store 0
load 1
callsub numericalcomp_3
store 1
byte 0x00
int 0
load 0
setbit
byte 0x00
int 0
load 1
setbyte
concat
store 9
load 9
retsub

// round_tripper
roundtripper_1:
store 4
load 4
callsub tuplecomplement_0
store 6
load 6
callsub tuplecomplement_0
store 7
load 4
load 6
concat
load 7
concat
store 5
load 5
retsub

// bool_comp
boolcomp_2:
store 10
load 10
!
store 11
load 11
int 2
<
assert
load 11
retsub

// numerical_comp
numericalcomp_3:
store 12
int 255
load 12
-
store 13
load 13
int 256
<
assert
load 13
retsub
Loading