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

C2C Feature and Testing #268

Merged
merged 121 commits into from
Feb 9, 2022
Merged
Show file tree
Hide file tree
Changes from 92 commits
Commits
Show all changes
121 commits
Select commit Hold shift + click to select a range
4cab7a8
Start ABI JSON interaction
algochoi Oct 27, 2021
223b05e
Add static annoation
algochoi Oct 27, 2021
bad480d
Fix Method argument parsing
algochoi Oct 27, 2021
3b6f40c
Add ABI Typing to Method arguments
algochoi Oct 29, 2021
7b732a6
Merge remote-tracking branch 'origin/develop' into algochoi/abi-inter…
algochoi Oct 29, 2021
7cf0608
[WIP] Add AtomicTransactionComposer build functions
algochoi Oct 29, 2021
58cef31
[WIP] Sign and send atomic transaction groups
algochoi Nov 1, 2021
43874b2
Add unit tests for object parsing
algochoi Nov 1, 2021
d3fe73d
Clean up method calls
algochoi Nov 3, 2021
c7f4e14
Address PR comments on JSON objects
algochoi Nov 8, 2021
72d172d
Refactor ABI Type to ABIType so it can be exposed to outside world
algochoi Nov 10, 2021
e96b740
Add cucumber steps for ABI tests and update existing implementation s…
algochoi Nov 10, 2021
e052fa7
Refactor TransactionSigner to Abstract class and merge signatures whe…
algochoi Nov 12, 2021
d55f9a6
Update testing to reflect json unit tests and composer tests
algochoi Nov 16, 2021
a748f7b
Formatting and docstring fixes
algochoi Nov 16, 2021
982d519
Add foreign types for method arguments
algochoi Nov 16, 2021
23f63bb
Clean up imports
algochoi Nov 16, 2021
7daa605
Merge branch 'algochoi/abi-interaction' into algochoi/foreign-types
algochoi Nov 16, 2021
f21ec5d
Fix unit test for appId
algochoi Nov 17, 2021
5a6be1c
Merge branch 'algochoi/abi-interaction' into algochoi/foreign-types
algochoi Nov 17, 2021
cfef0a6
Add unit test for foreign array
algochoi Nov 17, 2021
d63b4d1
Refactor some names and add txn as an arg type
algochoi Nov 18, 2021
5c9d28e
Partially address PR comments
algochoi Nov 19, 2021
5e9ab5a
Merge branch 'algochoi/abi-interaction' into algochoi/foreign-types
algochoi Nov 19, 2021
c024249
Fix encoding args for foreign types
algochoi Nov 19, 2021
9fa591a
Add some additional checks for safety
algochoi Nov 19, 2021
351099a
Fix a step so we check for empty string instead of None
algochoi Nov 19, 2021
c5df38c
Correct foreign app and account indices accounting for the implicit a…
algochoi Nov 22, 2021
8f24033
Merge branch 'algochoi/abi-interaction' into algochoi/foreign-types
algochoi Nov 22, 2021
d664879
Merge branch 'develop' into algochoi/foreign-types
algochoi Nov 30, 2021
34c625c
Resolve formatting
algochoi Nov 30, 2021
b29bdaa
Fix unit tests
algochoi Nov 30, 2021
1239547
Fix foreign objects to compact duplicates and special values
algochoi Dec 13, 2021
c218fdf
Refactor foreign objects, transactions, and address some new ABI changes
algochoi Dec 15, 2021
2fbf11a
ABI composer modifications and test updates
algochoi Dec 18, 2021
2503554
Change Interface and Contract to newest ABI changes
algochoi Dec 21, 2021
eed9935
Fix some integration tests for composer
algochoi Dec 21, 2021
00f550b
Fix remaining composer tests
algochoi Dec 21, 2021
0428abe
Formatting changes
algochoi Dec 21, 2021
ad7a483
Fix method json tests
algochoi Dec 22, 2021
59d0a3a
add an empty __init__.py
Dec 23, 2021
89c7b27
add step to sanity check *.teal.tok against algod's compilation of *.…
Dec 26, 2021
d53ca05
Merge branch 'develop' of github.com:algorand/py-algorand-sdk into tz…
Dec 29, 2021
fc69812
Add the ability to create apps without the binary
Dec 29, 2021
e5867a3
step for asserting ABI return type of return values
Dec 31, 2021
56a4717
temporararily adding unfounded mandate z_steps.py
Dec 31, 2021
e43ffd5
unit test for array_static of byte
Dec 31, 2021
a40ad47
add context.app_ids - list of all app ids that have been added
Dec 31, 2021
cc9383e
refeactor add_abi_method_call* using abi_method_adder()
Dec 31, 2021
5a9c50d
don't pass in schemas, unless a component has been defined
Dec 31, 2021
567461f
With so many tags, let's create variables for easier selction of unit…
Dec 31, 2021
db7a6f8
Alphabetize tags and remove deprecated 'templates'
Dec 31, 2021
7fd692e
add method using a non-current app
Dec 31, 2021
a378baa
place it back
Dec 31, 2021
47f93b0
got to the point of a bug in randomByte
Jan 1, 2022
45d4c2d
wip
Jan 1, 2022
13a32e7
use pathlib
Jan 2, 2022
360328b
fix bad arg ordering in call
Jan 2, 2022
a6f9a8c
1. Return application's account address in app-info response
Jan 3, 2022
3db9d58
clean up unneeded step
Jan 3, 2022
5682652
close but no cigar
Jan 4, 2022
ab4c856
wip
Jan 4, 2022
f6450c6
tests are failing where they _should be_
Jan 4, 2022
029dc63
all necessary functionality... but too many tests
Jan 5, 2022
7a4c27e
assertion about inner group ids also
Jan 5, 2022
f531044
passing the megatest
Jan 5, 2022
fe1cd04
hash non-deterministic step for ABI method
Jan 5, 2022
67e1e3f
regex match step
Jan 5, 2022
b5e1948
test c2c on circle
Jan 5, 2022
2636698
grammar
Jan 5, 2022
3147ea8
remove unused step
Jan 5, 2022
06fd4fc
route get_application_address() to application_address()
Jan 6, 2022
2af6fbd
dangit... we already have logic.get_application_address
Jan 6, 2022
e5245ab
use logic.get_application_address()
Jan 6, 2022
609ee93
small import re-org (and msgpack not needed)
Jan 6, 2022
bd91048
alphabetize
Jan 6, 2022
2f97048
add type assertion to get_application_address()
Jan 6, 2022
f3bbfe9
refactor v2_steps.py into smaller chuncks
Jan 7, 2022
78382b9
per cr suggestion, split with : not #
Jan 7, 2022
d1fdd4a
per cr comments
Jan 7, 2022
c0e0ade
Per CR suggetions: remove from transactions_trace() from SDK, and mak…
Jan 7, 2022
46d3560
eval delta step - and adding glom to requirements
Jan 7, 2022
cf5f24e
'Did you mean == ?' - yes i certainly did
Jan 7, 2022
ec57685
for completeness, provide tx_info even for non-appl txns
Jan 7, 2022
49ed47b
steps more general than the indexer
Jan 7, 2022
12b7703
require the ability to calculate app addresses, but not from app_info
Jan 7, 2022
415d29a
revert algod changes (except for import re-org)
Jan 7, 2022
7bc9dcb
remove file inadvertently added
Jan 7, 2022
c96c7fc
spacing
Jan 7, 2022
d4737a5
formatting
Jan 7, 2022
a0a494f
explicit nonce instead of nonce hook
Jan 11, 2022
a72a57b
un-breakup v2_steps.py so it can be easier to see changes
Jan 11, 2022
7350194
remove implmentation of redundant step
Jan 12, 2022
595a0cb
as the Rolling Stones said "I want it painted black"
Jan 12, 2022
e5b5cfb
per review suggestion
Jan 12, 2022
05f4001
per CR suggestion: send the request inside of a try block
Jan 13, 2022
fb7c5c2
pytest for "with pytest.raises" context
Jan 13, 2022
c3a96d3
handle the void abi type
Jan 13, 2022
2a96d9e
per CR suggestions
Jan 13, 2022
3089855
Merge remote-tracking branch 'origin' into tzaffi/c2c
Jan 13, 2022
1c097e9
per CR comments. Call pending txn's at the top of the for-loop for me…
Jan 13, 2022
cef5808
remove unused import
Jan 13, 2022
192c9f9
spacing
Jan 13, 2022
82dde0b
don't overwrite confirmed_round in subsequent pending txn calls
Jan 13, 2022
3eac5ec
comment in test method
Jan 13, 2022
e323f0e
remove unused import
Jan 14, 2022
d1ea229
Alas, poor Yorick...
Jan 14, 2022
41bcdae
remove unused import
Jan 14, 2022
df71706
import reorg
Jan 14, 2022
399d2ac
re-kick off the tests
tzaffi Jan 18, 2022
b383a03
implement "I rest the array of application IDs to remember."
Jan 18, 2022
7639bcd
Merge branch 'tzaffi/c2c' of github.com:algorand/py-algorand-sdk into…
Jan 18, 2022
e1aa79c
markdownlint
Jan 19, 2022
160e47d
deprecating templates and removing associated tests
Jan 21, 2022
be09d1b
fix test
Jan 21, 2022
886923c
Update README.md
tzaffi Jan 31, 2022
7e16dcb
Update algosdk/future/template.py
tzaffi Jan 31, 2022
f040b58
Merge remote-tracking branch 'origin' into tzaffi/c2c
Feb 1, 2022
6e65206
Merge branch 'tzaffi/c2c' of github.com:algorand/py-algorand-sdk into…
Feb 1, 2022
f689f1b
Merge remote-tracking branch 'origin/develop' into tzaffi/c2c
Feb 9, 2022
0bcdcb8
todo about v2_steps being too big
Feb 9, 2022
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
6 changes: 4 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
UNITS = "@unit.abijson or @unit.algod or @unit.applications or @unit.atomic_transaction_composer or @unit.dryrun or @unit.feetest or @unit.indexer or @unit.indexer.logs or @unit.offline or @unit.rekey or @unit.responses or @unit.responses.231 or @unit.tealsign or @unit.transactions or @unit.transactions.payment"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Introduce variables for the cucumber test tags, and also alphabetize.

This allows usage such as:

make unit UNITS="@unit.atomic_transaction_composer"

unit:
behave --tags="@unit.offline or @unit.algod or @unit.indexer or @unit.rekey or @unit.tealsign or @unit.dryrun or @unit.applications or @unit.responses or @unit.transactions or @unit.transactions.payment or @unit.responses.231 or @unit.feetest or @unit.indexer.logs or @unit.abijson or @unit.atomic_transaction_composer" test -f progress2
behave --tags=$(UNITS) test -f progress2

INTEGRATIONS = "@abi or @algod or @applications or @applications.verified or @assets or @auction or @c2c or @compile or @dryrun or @dryrun.testing or @indexer or @indexer.231 or @indexer.applications or @kmd or @rekey or @send"
integration:
behave --tags="@algod or @assets or @auction or @kmd or @send or @template or @indexer or @indexer.applications or @rekey or @compile or @dryrun or @dryrun.testing or @applications or @applications.verified or @indexer.231 or @abi" test -f progress2
behave --tags=$(INTEGRATIONS) test -f progress2

docker-test:
./run_integration.sh
9 changes: 7 additions & 2 deletions algosdk/atomic_transaction_composer.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
import base64
import copy
from enum import IntEnum
from typing import Any, List, TypeVar, Union
from typing import Any, Dict, List, TypeVar, Union

from algosdk import abi, error
from algosdk.abi.address_type import AddressType

from algosdk.future import transaction
from algosdk.v2client import algod

Expand Down Expand Up @@ -506,6 +507,7 @@ def execute(
raw_value=raw_value,
return_value=return_value,
decode_error=decode_error,
tx_info=client.pending_transaction_info(tx_id),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For completenes, making requests to PendingTransactionInfo/{TXID} even for non-app transactions.

Copy link
Contributor

@jasonpaulos jasonpaulos Jan 11, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean even for methods that return void? Because that's what this change does.

Also, any functions that might raise errors (client.pending_transaction_info in this case) must be placed in the try block to catch the error, so I'd suggest moving this if statement into the body of the try block

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

)
)
continue
Expand Down Expand Up @@ -543,6 +545,7 @@ def execute(
raw_value=raw_value,
return_value=return_value,
decode_error=decode_error,
tx_info=resp,
)
method_results.append(abi_result)

Expand Down Expand Up @@ -689,16 +692,18 @@ def __init__(
raw_value: bytes,
return_value: Any,
decode_error: error,
tx_info: dict,
) -> None:
self.tx_id = tx_id
self.raw_value = raw_value
self.return_value = return_value
self.decode_error = decode_error
self.tx_info = tx_info


class AtomicTransactionResponse:
def __init__(
self, confirmed_round: int, tx_ids: List[str], results: ABIResult
self, confirmed_round: int, tx_ids: List[str], results: List[ABIResult]
) -> None:
self.confirmed_round = confirmed_round
self.tx_ids = tx_ids
Expand Down
6 changes: 6 additions & 0 deletions algosdk/logic.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,12 @@ def get_application_address(appID: int) -> str:
Returns:
str: The address corresponding to that application's escrow account.
"""
assert isinstance(
appID, int
), "(Expected an int for appID but got [{}] which has type [{}])".format(
appID, type(appID)
)

to_sign = constants.APPID_PREFIX + appID.to_bytes(8, "big")
tzaffi marked this conversation as resolved.
Show resolved Hide resolved
checksum = encoding.checksum(to_sign)
return encoding.encode_address(checksum)
14 changes: 5 additions & 9 deletions algosdk/v2client/algod.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
from urllib.request import Request, urlopen
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I re-org'ed the imports when I touched this file to add functionality to app_info. That functionality was reverted but I'm asking to keep the import cleanup.

import base64
import json
from urllib import parse
import urllib.error
import json
import base64
from .. import error
from .. import encoding
from .. import constants
from .. import future
import msgpack
from .. import util
from urllib.request import Request, urlopen

from .. import constants, encoding, error, future, logic, util

api_version_path_prefix = "/v2"

Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.
black==21.9b0
glom==20.11.0
tzaffi marked this conversation as resolved.
Show resolved Hide resolved
git+https://github.com/behave/behave
2 changes: 1 addition & 1 deletion run_integration.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ pushd $rootdir

# Reset test harness
rm -rf test-harness
git clone --single-branch --branch master https://github.com/algorand/algorand-sdk-testing.git test-harness
git clone --single-branch --branch zc2c https://github.com/algorand/algorand-sdk-testing.git test-harness
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to point back to main branch once algorand/algorand-sdk-testing#156 is merged.


## Copy feature files into the project resources
mkdir -p test/features
Expand Down
1 change: 1 addition & 0 deletions test/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ def encode_bytes(d):
encode_bytes(d[i])
else:
if isinstance(d[i], bytes):
assert False, "Zeph thinks this code is unreachable"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pylance was complaining that v isn't defined... and I agree

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The next line should likely be d[i] = base64.b64encode(d[i]).decode(). Can you replace it with that?

d[i] = base64.b64encode(v).decode()
return d

Expand Down
Empty file added test/steps/__init__.py
Empty file.
Loading