From a6e48f1aa404719775eb163505f7da731000a9d0 Mon Sep 17 00:00:00 2001 From: algochoi <86622919+algochoi@users.noreply.github.com> Date: Tue, 8 Nov 2022 17:32:21 -0500 Subject: [PATCH 1/4] Fix roundtrip encode/decode tests for transactions --- algosdk/box_reference.py | 8 +++++++- algosdk/future/transaction.py | 8 ++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/algosdk/box_reference.py b/algosdk/box_reference.py index e052071b..a03f34c0 100644 --- a/algosdk/box_reference.py +++ b/algosdk/box_reference.py @@ -23,10 +23,16 @@ def __init__(self, app_index: int, name: bytes): @staticmethod def translate_box_reference( - ref: Tuple[int, Union[bytes, bytearray, str, int]], + ref: Union[ + Tuple[int, Union[bytes, bytearray, str, int]], "BoxReference" + ], foreign_apps: List[int], this_app_id: int, ) -> "BoxReference": + # Check if references are already BoxReference typed + if isinstance(ref, BoxReference): + return ref + # Try checking reference id and name type. ref_id, ref_name = ref[0], encoding.encode_as_bytes(ref[1]) if not isinstance(ref_id, int): diff --git a/algosdk/future/transaction.py b/algosdk/future/transaction.py index 72677447..15eab421 100644 --- a/algosdk/future/transaction.py +++ b/algosdk/future/transaction.py @@ -1519,8 +1519,8 @@ def dictify(self): @staticmethod def undictify(d): return StateSchema( - num_uints=d["nui"] if "nui" in d else None, - num_byte_slices=d["nbs"] if "nbs" in d else None, + num_uints=d["nui"] if "nui" in d else 0, + num_byte_slices=d["nbs"] if "nbs" in d else 0, ) def __eq__(self, other): @@ -1628,13 +1628,13 @@ def __init__( self, sender, sp, note, lease, constants.appcall_txn, rekey_to ) self.index = self.creatable_index(index) - self.on_complete = on_complete + self.on_complete = on_complete if on_complete else 0 self.local_schema = self.state_schema(local_schema) self.global_schema = self.state_schema(global_schema) self.approval_program = self.teal_bytes(approval_program) self.clear_program = self.teal_bytes(clear_program) self.app_args = self.bytes_list(app_args) - self.accounts = accounts + self.accounts = accounts if accounts else None self.foreign_apps = self.int_list(foreign_apps) self.foreign_assets = self.int_list(foreign_assets) self.extra_pages = extra_pages From 1e0a1db83f47a47aba8abe3af67be052fa5c8d71 Mon Sep 17 00:00:00 2001 From: algochoi <86622919+algochoi@users.noreply.github.com> Date: Tue, 8 Nov 2022 17:34:16 -0500 Subject: [PATCH 2/4] Change test branch --- .test-env | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.test-env b/.test-env index df783a4f..d2e12d70 100644 --- a/.test-env +++ b/.test-env @@ -1,6 +1,6 @@ # Configs for testing repo download: SDK_TESTING_URL="https://github.com/algorand/algorand-sdk-testing" -SDK_TESTING_BRANCH="master" +SDK_TESTING_BRANCH="app-txn-decode" SDK_TESTING_HARNESS="test-harness" INSTALL_ONLY=0 From adc61c8dd01ac7c878730ebf426bbdd13662d8b8 Mon Sep 17 00:00:00 2001 From: algochoi <86622919+algochoi@users.noreply.github.com> Date: Tue, 8 Nov 2022 17:43:31 -0500 Subject: [PATCH 3/4] Update comment --- algosdk/box_reference.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/algosdk/box_reference.py b/algosdk/box_reference.py index a03f34c0..6de7765f 100644 --- a/algosdk/box_reference.py +++ b/algosdk/box_reference.py @@ -29,7 +29,7 @@ def translate_box_reference( foreign_apps: List[int], this_app_id: int, ) -> "BoxReference": - # Check if references are already BoxReference typed + # Do not need to translate the references if they are already BoxReference type. if isinstance(ref, BoxReference): return ref From 7bd5ae3b1722bcef4fe31f25c21c3bcb616184d6 Mon Sep 17 00:00:00 2001 From: Jason Paulos Date: Wed, 9 Nov 2022 07:52:05 -0800 Subject: [PATCH 4/4] Update .test-env Co-authored-by: algochoi <86622919+algochoi@users.noreply.github.com> --- .test-env | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.test-env b/.test-env index d2e12d70..df783a4f 100644 --- a/.test-env +++ b/.test-env @@ -1,6 +1,6 @@ # Configs for testing repo download: SDK_TESTING_URL="https://github.com/algorand/algorand-sdk-testing" -SDK_TESTING_BRANCH="app-txn-decode" +SDK_TESTING_BRANCH="master" SDK_TESTING_HARNESS="test-harness" INSTALL_ONLY=0