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

Add Algod endpoint for GetApplicationBoxByName #346

Merged
merged 55 commits into from
Jun 30, 2022
Merged
Show file tree
Hide file tree
Changes from 53 commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
99a2850
starting to add box support
barnjamin May 19, 2022
4684025
Add boxes to atc
barnjamin May 20, 2022
c10cff1
Format files with black
algochoi May 20, 2022
c5fbd30
Add boxes docstring
algochoi May 20, 2022
d9381e3
Add boxes support for appl creation
algochoi May 20, 2022
bd0c41e
Update cucumber steps for appl txn encoding for boxes
algochoi May 20, 2022
8313c8e
Formatting
algochoi May 20, 2022
af73bbe
Point testing branch to box-reference (WIP)
algochoi May 20, 2022
5f39d5c
Sort imports on relevant files and format
algochoi May 23, 2022
f949e09
Add translation for foreign apps in box refs and some local unit tests
algochoi May 23, 2022
ce32d63
Add some invalid cases for box translation
algochoi May 23, 2022
3b20d42
Check for None when iterating box refs
algochoi May 23, 2022
af9f6b4
Add self app id references and tests
algochoi May 23, 2022
adbd4da
Minor changes for box support
algochoi May 23, 2022
b6f3653
Split boxref to separate file
algochoi May 24, 2022
6f15a91
Change box name type to bytes
algochoi May 24, 2022
7ddcd77
Change docs references from box string to bytes
algochoi May 24, 2022
ae3fba9
Refactor cucumber steps
algochoi May 24, 2022
1e1b5d7
Refactoring code and adding docstrings
algochoi Jun 1, 2022
afceed7
Add another comment
algochoi Jun 1, 2022
9c039f4
Change test steps to encode box args like app args
algochoi Jun 2, 2022
1dd96e9
Add safety checks for box references
algochoi Jun 2, 2022
919923c
Add some detailed errors and refactor
algochoi Jun 2, 2022
b861c44
Format unit test
algochoi Jun 2, 2022
ffe6b1c
Fix foreign index error and revise undictify method
algochoi Jun 3, 2022
ff5b7e1
Merge branch 'feature/box-storage' into box-support
algochoi Jun 3, 2022
8f48f6c
Finish merging cucumber steps
algochoi Jun 3, 2022
71bee9a
Formatting
algochoi Jun 3, 2022
935bd0a
Fix box tests again
algochoi Jun 3, 2022
a94cf7e
Encoded as bytes unit test (#344)
tzaffi Jun 3, 2022
1bc926b
Accept AttributeError for foreign apps array if it is referencing its…
algochoi Jun 6, 2022
f53f274
Add unit test for empty foreign app array
algochoi Jun 6, 2022
959ec1d
Change unit test to pass in None foreign array
algochoi Jun 6, 2022
d45c6c2
Change undictify method for boxes
algochoi Jun 6, 2022
05d5a49
Formatting
algochoi Jun 6, 2022
6960daa
Change test branch
algochoi Jun 7, 2022
485d2ad
Change type hints for atc boxes
algochoi Jun 7, 2022
9251041
Add algod endpoint for getting app box by name
algochoi Jun 7, 2022
bad0154
Add steps test for box application path
algochoi Jun 7, 2022
1635fb2
Escape forward slashes in uri
algochoi Jun 10, 2022
c48de1f
Formatting
algochoi Jun 10, 2022
3a6b583
Merge branch 'develop' into box-api-paths
algochoi Jun 21, 2022
770a215
Merge branch 'feature/box-storage' into box-api-paths
algochoi Jun 21, 2022
2b82f29
Finish merging
algochoi Jun 21, 2022
aea3e5e
Add box integration tests
algochoi Jun 21, 2022
d4e9609
Formatting
algochoi Jun 21, 2022
5e2bc7f
Add boxes integration test tag to makefile
algochoi Jun 23, 2022
f98a873
Change step prefix
algochoi Jun 23, 2022
07bf34e
Revert step prefix
algochoi Jun 23, 2022
5cfd23e
Change algod request for box search and test
algochoi Jun 29, 2022
bec03cb
Change makefile test
algochoi Jun 29, 2022
14a9184
Formatting
algochoi Jun 29, 2022
eeaec86
Remove unused line
algochoi Jun 29, 2022
a6af2c3
Change wording around box encoding steps
algochoi Jun 30, 2022
7f8787d
Try running feature branch tests
algochoi Jun 30, 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
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
UNITS = "@unit.abijson or @unit.abijson.byname or @unit.algod or @unit.algod.ledger_refactoring or @unit.applications or @unit.atc_method_args or @unit.atomic_transaction_composer or @unit.dryrun or @unit.dryrun.trace.application or @unit.feetest or @unit.indexer or @unit.indexer.ledger_refactoring or @unit.indexer.logs or @unit.offline or @unit.rekey or @unit.transactions.keyreg or @unit.responses or @unit.responses.231 or @unit.tealsign or @unit.transactions or @unit.transactions.payment or @unit.responses.unlimited_assets"
UNITS = "@unit.abijson or @unit.abijson.byname or @unit.algod or @unit.algod.ledger_refactoring or @unit.applications or @unit.applications.boxes or @unit.atc_method_args or @unit.atomic_transaction_composer or @unit.dryrun or @unit.dryrun.trace.application or @unit.feetest or @unit.indexer or @unit.indexer.ledger_refactoring or @unit.indexer.logs or @unit.offline or @unit.rekey or @unit.transactions.keyreg or @unit.responses or @unit.responses.231 or @unit.tealsign or @unit.transactions or @unit.transactions.payment or @unit.responses.unlimited_assets"
unit:
behave --tags=$(UNITS) tests -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.keyregtxn or @send"
INTEGRATIONS = "@abi or @algod or @applications or @applications.verified or @applications.boxes 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.keyregtxn or @send"
integration:
behave --tags=$(INTEGRATIONS) tests -f progress2

Expand Down
17 changes: 17 additions & 0 deletions algosdk/v2client/algod.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,23 @@ def application_info(self, application_id, **kwargs):
req = "/applications/" + str(application_id)
return self.algod_request("GET", req, **kwargs)

def application_box_by_name(
self, application_id: int, box_name: bytes, **kwargs
):
"""
Return the value of an application's box.

Args:
application_id (int): The ID of the application to look up.
box_name (bytes): The name or key of the box.
"""
encoded_box = base64.b64encode(box_name).decode()
box_name_encoded = "b64:" + encoded_box
req = "/applications/" + str(application_id) + "/box"
params = {"name": box_name_encoded}
print(req, params)
return self.algod_request("GET", req, params=params, **kwargs)

def account_asset_info(self, address, asset_id, **kwargs):
"""
Return asset information for a specific account.
Expand Down
2 changes: 1 addition & 1 deletion run_integration.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ pushd $rootdir
# Reset test harness
rm -rf test-harness
# TODO: Before merging, change branch back to master
git clone --single-branch --branch feature/box-storage https://github.com/algorand/algorand-sdk-testing.git test-harness
git clone --single-branch --branch box-path-tests https://github.com/algorand/algorand-sdk-testing.git test-harness

## Copy feature files into the project resources
mkdir -p tests/features
Expand Down
2 changes: 1 addition & 1 deletion tests/steps/account_v2_steps.py
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ def assert_app_account_is_the_hash(context):
), f"account-address: expected [{expected}], but got [{actual}]"


@given(
@step(
"I fund the current application's address with {fund_amount} microalgos."
)
def fund_app_account(context, fund_amount):
Expand Down
35 changes: 34 additions & 1 deletion tests/steps/application_v2_steps.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,14 @@ def application_info(context, app_id):
context.response = context.acl.application_info(int(app_id))


@when(
'we make a GetApplicationBoxByName call for applicationID {app_id} with box name "{box_name}"'
)
def application_box_by_name(context, app_id, box_name):
boxes = split_and_process_app_args(box_name)[0]
context.response = context.acl.application_box_by_name(app_id, boxes)


@when(
'we make a LookupApplicationLogsByID call with applicationID {app_id} limit {limit} minRound {min_round} maxRound {max_round} nextToken "{next_token:MaybeString}" sender "{sender:MaybeString}" and txID "{txid:MaybeString}"'
)
Expand Down Expand Up @@ -410,7 +418,7 @@ def build_app_txn_with_transient(
note=None,
lease=None,
rekey_to=None,
boxes=None,
boxes=boxes,
)


Expand Down Expand Up @@ -1143,3 +1151,28 @@ def check_found_method_or_error(context, methodsig, error: str = None):
assert error in context.error
else:
assert False, "Both retrieved method and error string are None"


@then(
'the contents of the box with name "{box_name}" should be "{box_value:MaybeString}". If there is an error it is "{error_string:MaybeString}".'
)
def check_box_contents(
context, box_name, box_value: str = None, error_string: str = None
):
try:
box_name = split_and_process_app_args(box_name)[0]
box_response = context.app_acl.application_box_by_name(
context.current_application_id, box_name
)
actual_name = box_response["name"]
actual_value = box_response["value"]
assert box_name == base64.b64decode(actual_name)
assert box_value == str(actual_value)
except Exception as e:
if not error_string or error_string not in str(e):
raise RuntimeError(
"error string "
+ error_string
+ " not in actual error "
+ str(e)
)