Skip to content

Commit 671e136

Browse files
committed
Merge branch 'release/v1.19.0'
2 parents f030f09 + 61159ea commit 671e136

File tree

8 files changed

+102
-11
lines changed

8 files changed

+102
-11
lines changed

.test-env

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ SDK_TESTING_URL="https://github.com/algorand/algorand-sdk-testing"
33
SDK_TESTING_BRANCH="master"
44
SDK_TESTING_HARNESS="test-harness"
55

6+
INSTALL_ONLY=0
7+
68
VERBOSE_HARNESS=0
79

810
# WARNING: If set to 1, new features will be LOST when downloading the test harness.

Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@ display-all-python-steps:
1111
find tests/steps -name "*.py" | xargs grep "behave" 2>/dev/null | cut -d: -f1 | sort | uniq | xargs awk "/@(given|step|then|when)/,/[)]/" | grep -E "(\".+\"|\'.+\')"
1212

1313
harness:
14-
./test-harness.sh
14+
./test-harness.sh up
15+
16+
harness-down:
17+
./test-harness.sh down
1518

1619
PYTHON_VERSION ?= 3.8
1720
docker-pysdk-build:

algosdk/v2client/algod.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -440,6 +440,16 @@ def stateproofs(self, round_num, **kwargs):
440440
req = "/stateproofs/{}".format(round_num)
441441
return self.algod_request("GET", req, **kwargs)
442442

443+
def get_block_hash(self, round_num, **kwargs):
444+
"""
445+
Get the block hash for the block on the given round.
446+
447+
Args:
448+
round_num (int): The round in which the transaction appears.
449+
"""
450+
req = "/blocks/{}/hash".format(round_num)
451+
return self.algod_request("GET", req, **kwargs)
452+
443453

444454
def _specify_round_string(block, round_num):
445455
"""

algosdk/v2client/indexer.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -211,20 +211,26 @@ def asset_balances(
211211
query["include-all"] = include_all
212212
return self.indexer_request("GET", req, query, **kwargs)
213213

214-
def block_info(self, block=None, round_num=None, **kwargs):
214+
def block_info(
215+
self, block=None, round_num=None, header_only=None, **kwargs
216+
):
215217
"""
216218
Get the block for the given round.
217219
218220
Args:
219221
block (int, optional): block number
220222
round_num (int, optional): alias for block; specify one of these
223+
header_only (bool, optional):
221224
"""
222-
req = "/blocks/"
223225
if block is None and round_num is None:
224226
raise error.UnderspecifiedRoundError
225227
req = "/blocks/" + _specify_round_string(block, round_num)
226228

227-
return self.indexer_request("GET", req, **kwargs)
229+
query = dict()
230+
if header_only:
231+
query["header-only"] = "true"
232+
233+
return self.indexer_request("GET", req, query, **kwargs)
228234

229235
def account_info(
230236
self,

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
description="Algorand SDK in Python",
1010
author="Algorand",
1111
author_email="pypiservice@algorand.com",
12-
version="v1.18.0",
12+
version="v1.19.0",
1313
long_description=long_description,
1414
long_description_content_type="text/markdown",
1515
license="MIT",

test-harness.sh

Lines changed: 55 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,47 @@
11
#!/usr/bin/env bash
2-
32
set -euo pipefail
43

4+
# test-harness.sh setup/start cucumber test environment.
5+
#
6+
# Configuration is managed with environment variables, the ones you
7+
# are most likely to reconfigured are stored in '.test-env'.
8+
#
9+
# Variables:
10+
# SDK_TESTING_URL - URL to algorand-sdk-testing, useful for forks.
11+
# SDK_TESTING_BRANCH - branch to checkout, useful for new tests.
12+
# SDK_TESTING_HARNESS - local directory that the algorand-sdk-testing repo is cloned into.
13+
# VERBOSE_HARNESS - more output while the script runs.
14+
# INSTALL_ONLY - installs feature files only, useful for unit tests.
15+
#
16+
# WARNING: If set to 1, new features will be LOST when downloading the test harness.
17+
# REGARDLESS: modified features are ALWAYS overwritten.
18+
# REMOVE_LOCAL_FEATURES - delete all local cucumber feature files before downloading these from github.
19+
#
20+
# WARNING: Be careful when turning on the next variable.
21+
# In that case you'll need to provide all variables expected by `algorand-sdk-testing`'s `.env`
22+
# OVERWRITE_TESTING_ENVIRONMENT=0
23+
24+
SHUTDOWN=0
25+
if [ $# -ne 0 ]; then
26+
if [ $# -ne 1 ]; then
27+
echo "this script accepts a single argument, which must be 'up' or 'down'."
28+
exit 1
29+
fi
30+
31+
case $1 in
32+
'up')
33+
;; # default.
34+
'down')
35+
SHUTDOWN=1
36+
;;
37+
*)
38+
echo "unknown parameter '$1'."
39+
echo "this script accepts a single argument, which must be 'up' or 'down'."
40+
exit 1
41+
;;
42+
esac
43+
fi
44+
545
START=$(date "+%s")
646

747
THIS=$(basename "$0")
@@ -23,12 +63,20 @@ if [ -d "$SDK_TESTING_HARNESS" ]; then
2363
./scripts/down.sh
2464
popd
2565
rm -rf "$SDK_TESTING_HARNESS"
66+
if [[ $SHUTDOWN == 1 ]]; then
67+
echo "$THIS: network shutdown complete."
68+
exit 0
69+
fi
2670
else
2771
echo "$THIS: directory $SDK_TESTING_HARNESS does not exist - NOOP"
2872
fi
2973

30-
git clone --depth 1 --single-branch --branch "$SDK_TESTING_BRANCH" "$SDK_TESTING_URL" "$SDK_TESTING_HARNESS"
74+
if [[ $SHUTDOWN == 1 ]]; then
75+
echo "$THIS: unable to shutdown network."
76+
exit 1
77+
fi
3178

79+
git clone --depth 1 --single-branch --branch "$SDK_TESTING_BRANCH" "$SDK_TESTING_URL" "$SDK_TESTING_HARNESS"
3280

3381
echo "$THIS: OVERWRITE_TESTING_ENVIRONMENT=$OVERWRITE_TESTING_ENVIRONMENT"
3482
if [[ $OVERWRITE_TESTING_ENVIRONMENT == 1 ]]; then
@@ -53,6 +101,11 @@ if [[ $VERBOSE_HARNESS == 1 ]]; then
53101
fi
54102
echo "$THIS: seconds it took to get to end of cloning and copying: $(($(date "+%s") - START))s"
55103

104+
if [[ $INSTALL_ONLY == 1 ]]; then
105+
echo "$THIS: configured to install feature files only. Not starting test harness environment."
106+
exit 0
107+
fi
108+
56109
## Start test harness environment
57110
pushd "$SDK_TESTING_HARNESS"
58111

tests/steps/other_v2_steps.py

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ def parse_string(text):
3939
register_type(MaybeString=parse_string)
4040

4141

42-
@parse.with_pattern(r"true|false")
42+
@parse.with_pattern(r"true|false|")
4343
def parse_bool(value):
44-
if value not in ("true", "false"):
44+
if value not in ("true", "false", ""):
4545
raise ValueError("Unknown value for include_all: {}".format(value))
4646
return value == "true"
4747

@@ -623,9 +623,19 @@ def parse_txns_by_addr(context, roundNum, length, idx, sender):
623623
assert context.response["transactions"][int(idx)]["sender"] == sender
624624

625625

626-
@when("we make a Lookup Block call against round {block}")
626+
@when(
627+
'we make a Lookup Block call against round {block:d} and header "{headerOnly:MaybeBool}"'
628+
)
629+
def lookup_block(context, block, headerOnly):
630+
print("Header only = " + str(headerOnly))
631+
context.response = context.icl.block_info(
632+
block=block, header_only=headerOnly
633+
)
634+
635+
636+
@when("we make a Lookup Block call against round {block:d}")
627637
def lookup_block(context, block):
628-
context.response = context.icl.block_info(int(block))
638+
context.response = context.icl.block_info(block)
629639

630640

631641
@when("we make any LookupBlock call")
@@ -1392,3 +1402,8 @@ def transaction_proof(context, round, txid, hashtype):
13921402
context.response = context.acl.transaction_proof(
13931403
round, txid, hashtype, "msgpack"
13941404
)
1405+
1406+
1407+
@when("we make a Lookup Block Hash call against round {round}")
1408+
def get_block_hash(context, round):
1409+
context.response = context.acl.get_block_hash(round)

tests/unit.tags

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
@unit.applications
66
@unit.atc_method_args
77
@unit.atomic_transaction_composer
8+
@unit.blocksummary
89
@unit.dryrun
910
@unit.dryrun.trace.application
1011
@unit.feetest
@@ -16,6 +17,7 @@
1617
@unit.rekey
1718
@unit.responses
1819
@unit.responses.231
20+
@unit.responses.blocksummary
1921
@unit.responses.participationupdates
2022
@unit.responses.unlimited_assets
2123
@unit.sourcemap

0 commit comments

Comments
 (0)