From 23cd772528669ffe13e93102ecbebeaa9ff37410 Mon Sep 17 00:00:00 2001 From: algochoi <86622919+algochoi@users.noreply.github.com> Date: Mon, 27 Jun 2022 14:54:41 -0400 Subject: [PATCH 01/36] Revise tests --- tests/steps/account_v2_steps.py | 11 +++--- tests/steps/application_v2_steps.py | 17 +++++----- tests/steps/other_v2_steps.py | 32 ++++++++++++++---- tests/steps/steps.py | 52 +++++++++++++++++++++-------- 4 files changed, 77 insertions(+), 35 deletions(-) diff --git a/tests/steps/account_v2_steps.py b/tests/steps/account_v2_steps.py index d2284669..8290b32f 100644 --- a/tests/steps/account_v2_steps.py +++ b/tests/steps/account_v2_steps.py @@ -1,10 +1,9 @@ -from behave import given, then, when from typing import Union -from algosdk import account, encoding, logic +from algosdk import account, constants, encoding, logic from algosdk.future import transaction - -import tests.steps.other_v2_steps +from behave import given, then, when +from tests.steps.other_v2_steps import dev_mode_wait_for_confirmation def fund_account_address( @@ -19,7 +18,7 @@ def fund_account_address( ) signed_payment = context.wallet.sign_transaction(payment) context.app_acl.send_transaction(signed_payment) - transaction.wait_for_confirmation(context.app_acl, payment.get_txid(), 10) + dev_mode_wait_for_confirmation(context, payment.get_txid(), 10) @when( @@ -454,7 +453,7 @@ def create_transient_and_fund(context, transient_fund_amount): ) signed_payment = context.wallet.sign_transaction(payment) context.app_acl.send_transaction(signed_payment) - transaction.wait_for_confirmation(context.app_acl, payment.get_txid(), 10) + dev_mode_wait_for_confirmation(context, payment.get_txid(), 10) @then( diff --git a/tests/steps/application_v2_steps.py b/tests/steps/application_v2_steps.py index a3c09f5d..15158693 100644 --- a/tests/steps/application_v2_steps.py +++ b/tests/steps/application_v2_steps.py @@ -2,19 +2,21 @@ import json import re -from behave import given, step, then, when import pytest - from algosdk import abi, atomic_transaction_composer, encoding, mnemonic from algosdk.abi.contract import NetworkInfo from algosdk.error import ( ABITypeError, - IndexerHTTPError, AtomicTransactionComposerError, + IndexerHTTPError, ) from algosdk.future import transaction - -from tests.steps.other_v2_steps import read_program +from behave import given, step, then, when +from tests.steps.other_v2_steps import ( + dev_mode_wait_for_confirmation, + read_program, + send_zero_transactions, +) def operation_string_to_enum(operation): @@ -406,6 +408,7 @@ def remember_app_id(context): def wait_for_app_txn_confirm(context): sp = context.app_acl.suggested_params() last_round = sp.first + send_zero_transactions(context, 3) context.app_acl.status_after_block(last_round + 2) if hasattr(context, "acl"): assert "type" in context.acl.transaction_info( @@ -413,9 +416,7 @@ def wait_for_app_txn_confirm(context): ) assert "type" in context.acl.transaction_by_id(context.app_txid) else: - transaction.wait_for_confirmation( - context.app_acl, context.app_txid, 10 - ) + dev_mode_wait_for_confirmation(context, context.app_txid, 10) @given("an application id {app_id}") diff --git a/tests/steps/other_v2_steps.py b/tests/steps/other_v2_steps.py index 5cb23f26..9fe69a60 100644 --- a/tests/steps/other_v2_steps.py +++ b/tests/steps/other_v2_steps.py @@ -1,11 +1,13 @@ import base64 import json import os +import random import urllib import unittest from datetime import datetime from pathlib import Path from urllib.request import Request, urlopen +import time from behave import ( given, @@ -17,13 +19,7 @@ from glom import glom import parse - -from algosdk import ( - dryrun_results, - encoding, - error, - mnemonic, -) +from algosdk import constants, dryrun_results, encoding, error, mnemonic from algosdk.error import AlgodHTTPError from algosdk.future import transaction from algosdk.v2client import * @@ -102,6 +98,28 @@ def read_program(context, path): return read_program_binary(path) +# Send transactions to progress block numbers on dev mode. +def send_zero_transactions(context, txns=1): + sp = context.app_acl.suggested_params() + for _ in range(txns): + payment = transaction.PaymentTxn( + context.accounts[0], + sp, + constants.ZERO_ADDRESS, + 0, + note=random.randbytes(8) + ) + signed_payment = context.wallet.sign_transaction(payment) + context.app_acl.send_transaction(signed_payment) + + +# To prevent excess waiting, send a zero payment transaction before +# the wait_for_confirmation function in dev mode. +def dev_mode_wait_for_confirmation(context, txid, rounds): + send_zero_transactions(context) + transaction.wait_for_confirmation(context.app_acl, txid, rounds) + + @given("mock server recording request paths") def setup_mockserver(context): context.url = "http://127.0.0.1:" + str(context.path_server_port) diff --git a/tests/steps/steps.py b/tests/steps/steps.py index 99e8ea9a..1fc12359 100644 --- a/tests/steps/steps.py +++ b/tests/steps/steps.py @@ -1,21 +1,22 @@ -from behave import given, when, then import base64 -from algosdk import kmd -from algosdk.future import transaction -from algosdk import encoding -from algosdk import algod -from algosdk import account -from algosdk import mnemonic -from algosdk import wallet -from algosdk import auction -from algosdk import util -from algosdk import constants -from algosdk import logic -from algosdk.future import template import os +import random from datetime import datetime -import hashlib +from algosdk import ( + account, + algod, + auction, + constants, + encoding, + kmd, + logic, + mnemonic, + util, + wallet, +) +from algosdk.future import transaction +from behave import given, then, when from nacl.signing import SigningKey token = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" @@ -23,6 +24,21 @@ kmd_port = 60001 +# Send a zero payment transaction +def send_zero_transactions(context, txns=1): + sp = context.acl.suggested_params_as_object() + for _ in range(txns): + payment = transaction.PaymentTxn( + context.accounts[0], + sp, + constants.ZERO_ADDRESS, + 0, + note=random.randbytes(8), + ) + signed_payment = context.wallet.sign_transaction(payment) + context.acl.send_transaction(signed_payment) + + @when("I create a wallet") def create_wallet(context): context.wallet_name = "Walletpy" @@ -225,6 +241,7 @@ def status(context): @when("I get status after this block") def status_block(context): + send_zero_transactions(context) context.status_after = context.acl.status_after_block( context.status["lastRound"] ) @@ -232,6 +249,7 @@ def status_block(context): @then("I can get the block info") def block(context): + send_zero_transactions(context) context.block = context.acl.block_info(context.status["lastRound"] + 1) @@ -320,6 +338,7 @@ def algod_client(context): algod_address = "http://localhost:" + str(algod_port) context.acl = algod.AlgodClient(token, algod_address) if context.acl.status()["lastRound"] < 2: + send_zero_transactions(context, 2) context.acl.status_after_block(2) @@ -332,6 +351,7 @@ def wallet_info(context): ) context.wallet_id = context.wallet.id context.accounts = context.wallet.list_keys() + print("ASDF ", context.accounts) @given('default transaction with parameters {amt} "{note}"') @@ -408,6 +428,7 @@ def check_txn(context): assert "type" in context.acl.pending_transaction_info( context.txn.get_txid() ) + send_zero_transactions(context, 3) context.acl.status_after_block(last_round + 2) assert "type" in context.acl.transaction_info( context.txn.sender, context.txn.get_txid() @@ -417,6 +438,7 @@ def check_txn(context): @then("I can get the transaction by ID") def get_txn_by_id(context): + send_zero_transactions(context, 3) context.acl.status_after_block(context.last_round + 2) assert "type" in context.acl.transaction_by_id(context.txn.get_txid()) @@ -493,6 +515,7 @@ def check_save_txn(context): stx = transaction.retrieve_from_file(dir_path + "/temp/txn.tx")[0] txid = stx.transaction.get_txid() last_round = context.acl.status()["lastRound"] + send_zero_transactions(context, 3) context.acl.status_after_block(last_round + 2) assert context.acl.transaction_info(stx.transaction.sender, txid) @@ -775,6 +798,7 @@ def default_asset_creation_txn(context, total): "metadatahash": None, "url": "", } + print("GGGG ", context.pk) @given("default-frozen asset creation transaction with total issuance {total}") From d951d7530a0bdd580b0983a654a83df5df370a63 Mon Sep 17 00:00:00 2001 From: algochoi <86622919+algochoi@users.noreply.github.com> Date: Fri, 8 Jul 2022 01:26:00 -0400 Subject: [PATCH 02/36] Revise and delete v1 algod steps and add devmode helpers --- tests/steps/other_v2_steps.py | 2 +- tests/steps/steps.py | 877 ---------------------------------- 2 files changed, 1 insertion(+), 878 deletions(-) diff --git a/tests/steps/other_v2_steps.py b/tests/steps/other_v2_steps.py index 9fe69a60..31ac1e01 100644 --- a/tests/steps/other_v2_steps.py +++ b/tests/steps/other_v2_steps.py @@ -107,7 +107,7 @@ def send_zero_transactions(context, txns=1): sp, constants.ZERO_ADDRESS, 0, - note=random.randbytes(8) + note=random.randbytes(8), ) signed_payment = context.wallet.sign_transaction(payment) context.app_acl.send_transaction(signed_payment) diff --git a/tests/steps/steps.py b/tests/steps/steps.py index 1fc12359..7c4cede4 100644 --- a/tests/steps/steps.py +++ b/tests/steps/steps.py @@ -1,44 +1,20 @@ -import base64 -import os -import random from datetime import datetime from algosdk import ( account, - algod, auction, - constants, encoding, kmd, - logic, - mnemonic, - util, wallet, ) from algosdk.future import transaction from behave import given, then, when -from nacl.signing import SigningKey token = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" algod_port = 60000 kmd_port = 60001 -# Send a zero payment transaction -def send_zero_transactions(context, txns=1): - sp = context.acl.suggested_params_as_object() - for _ in range(txns): - payment = transaction.PaymentTxn( - context.accounts[0], - sp, - constants.ZERO_ADDRESS, - 0, - note=random.randbytes(8), - ) - signed_payment = context.wallet.sign_transaction(payment) - context.acl.send_transaction(signed_payment) - - @when("I create a wallet") def create_wallet(context): context.wallet_name = "Walletpy" @@ -108,122 +84,12 @@ def try_handle(context): assert context.error -@given( - 'payment transaction parameters {fee} {fv} {lv} "{gh}" "{to}" "{close}" {amt} "{gen}" "{note}"' -) -def txn_params(context, fee, fv, lv, gh, to, close, amt, gen, note): - context.fee = int(fee) - context.fv = int(fv) - context.lv = int(lv) - context.gh = gh - context.to = to - context.amt = int(amt) - if context.fee == 0: - context.params = transaction.SuggestedParams( - context.fee, context.fv, context.lv, context.gh, gen, flat_fee=True - ) - else: - context.params = transaction.SuggestedParams( - context.fee, context.fv, context.lv, context.gh, gen - ) - if close == "none": - context.close = None - else: - context.close = close - if note == "none": - context.note = None - else: - context.note = base64.b64decode(note) - if gen == "none": - context.gen = None - else: - context.gen = gen - - -@given('mnemonic for private key "{mn}"') -def mn_for_sk(context, mn): - context.mn = mn - context.sk = mnemonic.to_private_key(mn) - context.pk = account.address_from_private_key(context.sk) - - -@when("I create the payment transaction") -def create_paytxn(context): - context.txn = transaction.PaymentTxn( - context.pk, - context.params, - context.to, - context.amt, - context.close, - context.note, - ) - - @given('multisig addresses "{addresses}"') def msig_addresses(context, addresses): addresses = addresses.split(" ") context.msig = transaction.Multisig(1, 2, addresses) -@when("I create the multisig payment transaction") -def create_msigpaytxn(context): - context.txn = transaction.PaymentTxn( - context.msig.address(), - context.params, - context.to, - context.amt, - context.close, - context.note, - ) - context.mtx = transaction.MultisigTransaction(context.txn, context.msig) - - -@when("I create the multisig payment transaction with zero fee") -def create_msigpaytxn_zero_fee(context): - context.txn = transaction.PaymentTxn( - context.msig.address(), - context.params, - context.to, - context.amt, - context.close, - context.note, - ) - context.mtx = transaction.MultisigTransaction(context.txn, context.msig) - - -@when("I sign the multisig transaction with the private key") -def sign_msig(context): - context.mtx.sign(context.sk) - - -@when("I sign the transaction with the private key") -def sign_with_sk(context): - context.stx = context.txn.sign(context.sk) - - -@then('the signed transaction should equal the golden "{golden}"') -def equal_golden(context, golden): - assert encoding.msgpack_encode(context.stx) == golden - - -@then('the multisig address should equal the golden "{golden}"') -def equal_msigaddr_golden(context, golden): - assert context.msig.address() == golden - - -@then('the multisig transaction should equal the golden "{golden}"') -def equal_msig_golden(context, golden): - if not encoding.msgpack_encode(context.mtx) == golden: - print(encoding.msgpack_encode(context.mtx)) - print(golden) - assert encoding.msgpack_encode(context.mtx) == golden - - -@when("I get versions with algod") -def acl_v(context): - context.versions = context.acl.versions()["versions"] - - @then("v1 should be in the versions") def v1_in_versions(context): assert "v1" in context.versions @@ -234,25 +100,6 @@ def kcl_v(context): context.versions = context.kcl.versions() -@when("I get the status") -def status(context): - context.status = context.acl.status() - - -@when("I get status after this block") -def status_block(context): - send_zero_transactions(context) - context.status_after = context.acl.status_after_block( - context.status["lastRound"] - ) - - -@then("I can get the block info") -def block(context): - send_zero_transactions(context) - context.block = context.acl.block_info(context.status["lastRound"] + 1) - - @when("I import the multisig") def import_msig(context): context.wallet.import_multisig(context.msig) @@ -333,15 +180,6 @@ def kmd_client(context): context.kcl = kmd.KMDClient(token, kmd_address) -@given("an algod client") -def algod_client(context): - algod_address = "http://localhost:" + str(algod_port) - context.acl = algod.AlgodClient(token, algod_address) - if context.acl.status()["lastRound"] < 2: - send_zero_transactions(context, 2) - context.acl.status_after_block(2) - - @given("wallet information") def wallet_info(context): context.wallet_name = "unencrypted-default-wallet" @@ -351,198 +189,6 @@ def wallet_info(context): ) context.wallet_id = context.wallet.id context.accounts = context.wallet.list_keys() - print("ASDF ", context.accounts) - - -@given('default transaction with parameters {amt} "{note}"') -def default_txn(context, amt, note): - params = context.acl.suggested_params_as_object() - context.last_round = params.first - if note == "none": - note = None - else: - note = base64.b64decode(note) - context.txn = transaction.PaymentTxn( - context.accounts[0], params, context.accounts[1], int(amt), note=note - ) - context.pk = context.accounts[0] - - -@given('default multisig transaction with parameters {amt} "{note}"') -def default_msig_txn(context, amt, note): - params = context.acl.suggested_params_as_object() - context.last_round = params.first - if note == "none": - note = None - else: - note = base64.b64decode(note) - context.msig = transaction.Multisig(1, 1, context.accounts) - context.txn = transaction.PaymentTxn( - context.msig.address(), - params, - context.accounts[1], - int(amt), - note=note, - ) - context.mtx = transaction.MultisigTransaction(context.txn, context.msig) - context.pk = context.accounts[0] - - -@when("I get the private key") -def get_sk(context): - context.sk = context.wallet.export_key(context.pk) - - -@when("I send the transaction") -def send_txn(context): - try: - context.acl.send_transaction(context.stx) - except: - context.error = True - - -@when("I send the kmd-signed transaction") -def send_txn_kmd(context): - context.acl.send_transaction(context.stx_kmd) - - -@when("I send the bogus kmd-signed transaction") -def send_txn_kmd_bogus(context): - try: - context.acl.send_transaction(context.stx_kmd) - except: - context.error = True - - -@when("I send the multisig transaction") -def send_msig_txn(context): - try: - context.acl.send_transaction(context.mtx) - except: - context.error = True - - -@then("the transaction should go through") -def check_txn(context): - last_round = context.acl.status()["lastRound"] - assert "type" in context.acl.pending_transaction_info( - context.txn.get_txid() - ) - send_zero_transactions(context, 3) - context.acl.status_after_block(last_round + 2) - assert "type" in context.acl.transaction_info( - context.txn.sender, context.txn.get_txid() - ) - assert "type" in context.acl.transaction_by_id(context.txn.get_txid()) - - -@then("I can get the transaction by ID") -def get_txn_by_id(context): - send_zero_transactions(context, 3) - context.acl.status_after_block(context.last_round + 2) - assert "type" in context.acl.transaction_by_id(context.txn.get_txid()) - - -@then("the transaction should not go through") -def txn_fail(context): - assert context.error - - -@when("I sign the transaction with kmd") -def sign_kmd(context): - context.stx_kmd = context.wallet.sign_transaction(context.txn) - - -@then("the signed transaction should equal the kmd signed transaction") -def sign_both_equal(context): - assert encoding.msgpack_encode(context.stx) == encoding.msgpack_encode( - context.stx_kmd - ) - - -@when("I sign the multisig transaction with kmd") -def sign_msig_kmd(context): - context.mtx_kmd = context.wallet.sign_multisig_transaction( - context.accounts[0], context.mtx - ) - - -@then( - "the multisig transaction should equal the kmd signed multisig transaction" -) -def sign_msig_both_equal(context): - assert encoding.msgpack_encode(context.mtx) == encoding.msgpack_encode( - context.mtx_kmd - ) - - -@when('I read a transaction "{txn}" from file "{num}"') -def read_txn(context, txn, num): - dir_path = os.path.dirname(os.path.realpath(__file__)) - dir_path = os.path.dirname(os.path.dirname(dir_path)) - context.num = num - context.txn = transaction.retrieve_from_file( - dir_path + "/temp/raw" + num + ".tx" - )[0] - - -@when("I write the transaction to file") -def write_txn(context): - dir_path = os.path.dirname(os.path.realpath(__file__)) - dir_path = os.path.dirname(os.path.dirname(dir_path)) - transaction.write_to_file( - [context.txn], dir_path + "/temp/raw" + context.num + ".tx" - ) - - -@then("the transaction should still be the same") -def check_enc(context): - dir_path = os.path.dirname(os.path.realpath(__file__)) - dir_path = os.path.dirname(os.path.dirname(dir_path)) - new = transaction.retrieve_from_file( - dir_path + "/temp/raw" + context.num + ".tx" - ) - old = transaction.retrieve_from_file( - dir_path + "/temp/old" + context.num + ".tx" - ) - assert encoding.msgpack_encode(new[0]) == encoding.msgpack_encode(old[0]) - - -@then("I do my part") -def check_save_txn(context): - dir_path = os.path.dirname(os.path.realpath(__file__)) - dir_path = os.path.dirname(os.path.dirname(dir_path)) - stx = transaction.retrieve_from_file(dir_path + "/temp/txn.tx")[0] - txid = stx.transaction.get_txid() - last_round = context.acl.status()["lastRound"] - send_zero_transactions(context, 3) - context.acl.status_after_block(last_round + 2) - assert context.acl.transaction_info(stx.transaction.sender, txid) - - -@then("I get the ledger supply") -def get_ledger(context): - context.acl.ledger_supply() - - -@then("the node should be healthy") -def check_health(context): - assert context.acl.health() == None - - -@when("I get the suggested params") -def suggested_params(context): - context.params = context.acl.suggested_params_as_object() - - -@when("I get the suggested fee") -def suggested_fee(context): - context.fee = context.acl.suggested_fee()["fee"] - - -@then("the fee in the suggested params should equal the suggested fee") -def check_suggested(context): - assert context.params.fee == context.fee @when("I create a bid") @@ -565,526 +211,3 @@ def check_bid(context): def sign_bid(context): context.sbid = context.bid.sign(context.sk) context.old = context.bid.sign(context.sk) - - -@when("I decode the address") -def decode_addr(context): - context.pk = encoding.decode_address(context.pk) - - -@when("I encode the address") -def encode_addr(context): - context.pk = encoding.encode_address(context.pk) - - -@then("the address should still be the same") -def check_addr(context): - assert context.pk == context.old - - -@when("I convert the private key back to a mnemonic") -def sk_to_mn(context): - context.mn = mnemonic.from_private_key(context.sk) - - -@then('the mnemonic should still be the same as "{mn}"') -def check_mn(context, mn): - assert context.mn == mn - - -@given('mnemonic for master derivation key "{mn}"') -def mn_for_mdk(context, mn): - context.mn = mn - context.mdk = mnemonic.to_master_derivation_key(mn) - - -@when("I convert the master derivation key back to a mnemonic") -def mdk_to_mn(context): - context.mn = mnemonic.from_master_derivation_key(context.mdk) - - -@when("I create the flat fee payment transaction") -def create_paytxn_flat_fee(context): - context.params.flat_fee = True - context.txn = transaction.PaymentTxn( - context.pk, - context.params, - context.to, - context.amt, - context.close, - context.note, - ) - - -@given('encoded multisig transaction "{mtx}"') -def dec_mtx(context, mtx): - context.mtx = encoding.msgpack_decode(mtx) - - -@when("I append a signature to the multisig transaction") -def append_mtx(context): - context.mtx.sign(context.sk) - - -@given('encoded multisig transactions "{msigtxns}"') -def mtxs(context, msigtxns): - context.mtxs = msigtxns.split(" ") - context.mtxs = [encoding.msgpack_decode(m) for m in context.mtxs] - - -@when("I merge the multisig transactions") -def merge_mtxs(context): - context.mtx = transaction.MultisigTransaction.merge(context.mtxs) - - -@when("I convert {microalgos} microalgos to algos and back") -def convert_algos(context, microalgos): - context.microalgos = util.algos_to_microalgos( - util.microalgos_to_algos(int(microalgos)) - ) - - -@then("it should still be the same amount of microalgos {microalgos}") -def check_microalgos(context, microalgos): - assert int(microalgos) == context.microalgos - - -@then("I get transactions by address and round") -def txns_by_addr_round(context): - txns = context.acl.transactions_by_address( - context.accounts[0], first=1, last=context.acl.status()["lastRound"] - ) - assert txns == {} or "transactions" in txns - - -@then("I get transactions by address only") -def txns_by_addr_only(context): - txns = context.acl.transactions_by_address(context.accounts[0]) - assert txns == {} or "transactions" in txns - - -@then("I get transactions by address and date") -def txns_by_addr_date(context): - date = datetime.today().strftime("%Y-%m-%d") - txns = context.acl.transactions_by_address( - context.accounts[0], from_date=date, to_date=date - ) - assert txns == {} or "transactions" in txns - - -@then("I get pending transactions") -def txns_pending(context): - txns = context.acl.pending_transactions() - assert txns == {} or "truncatedTxns" in txns - - -@then("I get account information") -def acc_info(context): - context.acl.account_info(context.accounts[0]) - - -@then("I can get account information") -def new_acc_info(context): - context.acl.account_info(context.pk) - context.wallet.delete_key(context.pk) - - -@given( - 'key registration transaction parameters {fee} {fv} {lv} "{gh}" "{votekey}" "{selkey}" {votefst} {votelst} {votekd} "{gen}" "{note}"' -) -def keyreg_txn_params( - context, - fee, - fv, - lv, - gh, - votekey, - selkey, - votefst, - votelst, - votekd, - gen, - note, -): - context.fee = int(fee) - context.fv = int(fv) - context.lv = int(lv) - context.gh = gh - context.votekey = votekey - context.selkey = selkey - context.votefst = int(votefst) - context.votelst = int(votelst) - context.votekd = int(votekd) - if gen == "none": - context.gen = None - else: - context.gen = gen - context.params = transaction.SuggestedParams( - context.fee, context.fv, context.lv, context.gh, context.gen - ) - - if note == "none": - context.note = None - else: - context.note = base64.b64decode(note) - if gen == "none": - context.gen = None - else: - context.gen = gen - - -@when("I create the key registration transaction") -def create_keyreg_txn(context): - context.txn = transaction.KeyregOnlineTxn( - context.pk, - context.params, - context.votekey, - context.selkey, - context.votefst, - context.votelst, - context.votekd, - context.note, - ) - - -@given("default V2 key registration transaction {type}") -def default_v2_keyreg_txn(context, type): - context.params = context.acl.suggested_params_as_object() - context.pk = context.accounts[0] - context.txn = buildTxn(type, context.pk, context.params) - - -@when("I get recent transactions, limited by {cnt} transactions") -def step_impl(context, cnt): - txns = context.acl.transactions_by_address( - context.accounts[0], limit=int(cnt) - ) - assert txns == {} or "transactions" in txns - - -@given("default asset creation transaction with total issuance {total}") -def default_asset_creation_txn(context, total): - context.total = int(total) - params = context.acl.suggested_params_as_object() - context.last_round = params.first - context.pk = context.accounts[0] - asset_name = "asset" - unit_name = "unit" - params.fee = 1 - context.txn = transaction.AssetConfigTxn( - context.pk, - params, - total=context.total, - default_frozen=False, - unit_name=unit_name, - asset_name=asset_name, - manager=context.pk, - reserve=context.pk, - freeze=context.pk, - clawback=context.pk, - ) - - context.expected_asset_info = { - "defaultfrozen": False, - "unitname": "unit", - "assetname": "asset", - "managerkey": context.pk, - "reserveaddr": context.pk, - "freezeaddr": context.pk, - "clawbackaddr": context.pk, - "creator": context.pk, - "total": context.total, - "decimals": 0, - "metadatahash": None, - "url": "", - } - print("GGGG ", context.pk) - - -@given("default-frozen asset creation transaction with total issuance {total}") -def default_frozen_asset_creation_txn(context, total): - context.total = int(total) - params = context.acl.suggested_params_as_object() - context.last_round = params.first - context.pk = context.accounts[0] - asset_name = "asset" - unit_name = "unit" - params.fee = 1 - context.txn = transaction.AssetConfigTxn( - context.pk, - params, - total=context.total, - default_frozen=True, - unit_name=unit_name, - asset_name=asset_name, - manager=context.pk, - reserve=context.pk, - freeze=context.pk, - clawback=context.pk, - ) - - context.expected_asset_info = { - "defaultfrozen": False, - "unitname": "unit", - "assetname": "asset", - "managerkey": context.pk, - "reserveaddr": context.pk, - "freezeaddr": context.pk, - "clawbackaddr": context.pk, - "creator": context.pk, - "total": context.total, - "decimals": 0, - "metadatahash": None, - "url": "", - } - - -@given("asset test fixture") -def asset_fixture(context): - context.expected_asset_info = dict() - context.rcv = context.accounts[1] - - -@when("I update the asset index") -def update_asset_index(context): - assets = context.acl.list_assets()["assets"] - indices = [a["AssetIndex"] for a in assets] - context.asset_index = max(indices) - - -@when("I get the asset info") -def get_asset_info(context): - context.asset_info = context.acl.asset_info(context.asset_index) - - -@then("the asset info should match the expected asset info") -def asset_info_match(context): - for k in context.expected_asset_info: - assert ( - context.expected_asset_info[k] == context.asset_info.get(k) - ) or ( - (not context.expected_asset_info[k]) - and (not context.asset_info.get(k)) - ) - - -@when("I create an asset destroy transaction") -def create_asset_destroy_txn(context): - context.txn = transaction.AssetConfigTxn( - context.pk, - context.acl.suggested_params_as_object(), - index=context.asset_index, - strict_empty_address_check=False, - ) - - -@then("I should be unable to get the asset info") -def err_asset_info(context): - err = False - try: - context.acl.asset_info(context.pk, context.asset_index) - except: - err = True - assert err - - -@when("I create a no-managers asset reconfigure transaction") -def no_manager_txn(context): - context.txn = transaction.AssetConfigTxn( - context.pk, - context.acl.suggested_params_as_object(), - index=context.asset_index, - reserve=context.pk, - clawback=context.pk, - freeze=context.pk, - strict_empty_address_check=False, - ) - - context.expected_asset_info["managerkey"] = "" - - -@when( - "I create a transaction for a second account, signalling asset acceptance" -) -def accept_asset_txn(context): - params = context.acl.suggested_params_as_object() - context.txn = transaction.AssetTransferTxn( - context.rcv, params, context.rcv, 0, context.asset_index - ) - - -@when( - "I create a transaction transferring {amount} assets from creator to a second account" -) -def transfer_assets(context, amount): - params = context.acl.suggested_params_as_object() - context.txn = transaction.AssetTransferTxn( - context.pk, params, context.rcv, int(amount), context.asset_index - ) - - -@when( - "I create a transaction transferring {amount} assets from a second account to creator" -) -def transfer_assets_to_creator(context, amount): - params = context.acl.suggested_params_as_object() - context.txn = transaction.AssetTransferTxn( - context.rcv, params, context.pk, int(amount), context.asset_index - ) - - -@then("the creator should have {exp_balance} assets remaining") -def check_asset_balance(context, exp_balance): - asset_info = context.acl.account_info(context.pk)["assets"][ - str(context.asset_index) - ] - assert asset_info["amount"] == int(exp_balance) - - -@when("I create a freeze transaction targeting the second account") -def freeze_txn(context): - params = context.acl.suggested_params_as_object() - context.txn = transaction.AssetFreezeTxn( - context.pk, params, context.asset_index, context.rcv, True - ) - - -@when("I create an un-freeze transaction targeting the second account") -def unfreeze_txn(context): - params = context.acl.suggested_params_as_object() - context.txn = transaction.AssetFreezeTxn( - context.pk, params, context.asset_index, context.rcv, False - ) - - -@when( - "I create a transaction revoking {amount} assets from a second account to creator" -) -def revoke_txn(context, amount): - params = context.acl.suggested_params_as_object() - context.txn = transaction.AssetTransferTxn( - context.pk, - params, - context.pk, - int(amount), - context.asset_index, - revocation_target=context.rcv, - ) - - -@given("I sign the transaction with the private key") -def given_sign_with_sk(context): - # python cucumber considers "Given foo" and "When foo" to be distinct, - # but we don't want them to be. So, call the other function - sign_with_sk(context) - - -@given("I send the transaction") -def given_send_txn(context): - # python cucumber considers "Given foo" and "When foo" to be distinct, - # but we don't want them to be. So, call the other function - send_txn(context) - - -@when('mnemonic for private key "{mn}"') -def when_mn_for_sk(context, mn): - # python cucumber considers "Given foo" and "When foo" to be distinct, - # but we don't want them to be. So, call the other function - mn_for_sk(context, mn) - - -@when('I set the from address to "{from_addr}"') -def set_from_to(context, from_addr): - context.txn.sender = from_addr - - -@when("I add a rekeyTo field with the private key algorand address") -def add_rekey_to_sk(context): - context.txn.rekey_to = account.address_from_private_key(context.sk) - - -@when('I add a rekeyTo field with address "{rekey}"') -def add_rekey_to_address(context, rekey): - context.txn.rekey_to = rekey - - -@given('base64 encoded data to sign "{data_enc}"') -def set_base64_encoded_data(context, data_enc): - context.data = base64.b64decode(data_enc) - - -@given('program hash "{contract_addr}"') -def set_program_hash(context, contract_addr): - context.address = contract_addr - - -@when("I perform tealsign") -def perform_tealsign(context): - context.sig = logic.teal_sign(context.sk, context.data, context.address) - - -@then('the signature should be equal to "{sig_enc}"') -def check_tealsign(context, sig_enc): - expected = base64.b64decode(sig_enc) - assert expected == context.sig - - -@given('base64 encoded program "{program_enc}"') -def set_program_hash_from_program(context, program_enc): - program = base64.b64decode(program_enc) - context.address = logic.address(program) - - -@given('base64 encoded private key "{sk_enc}"') -def set_sk_from_encoded_seed(context, sk_enc): - seed = base64.b64decode(sk_enc) - key = SigningKey(seed) - private_key = base64.b64encode( - key.encode() + key.verify_key.encode() - ).decode() - context.sk = private_key - - -@then("fee field is in txn") -def fee_in_txn(context): - if "signed_transaction" in context: - stxn = context.signed_transaction.dictify() - else: - stxn = context.mtx.dictify() - - assert "fee" in stxn["txn"] - - -@then("fee field not in txn") -def fee_not_in_txn(context): - if "signed_transaction" in context: - stxn = context.signed_transaction.dictify() - else: - stxn = context.mtx.dictify() - assert "fee" not in stxn["txn"] - - -def buildTxn(t, sender, params): - txn = None - if "online" in t: - votekey = "9mr13Ri8rFepxN3ghIUrZNui6LqqM5hEzB45Rri5lkU=" - selkey = "dx717L3uOIIb/jr9OIyls1l5Ei00NFgRa380w7TnPr4=" - votefst = 0 - votelst = 2000 - votekd = 10 - sprf = "mYR0GVEObMTSNdsKM6RwYywHYPqVDqg3E4JFzxZOreH9NU8B+tKzUanyY8AQ144hETgSMX7fXWwjBdHz6AWk9w==" - txn = transaction.KeyregOnlineTxn( - sender, - params, - votekey, - selkey, - votefst, - votelst, - votekd, - sprfkey=sprf, - ) - elif "offline" in t: - txn = transaction.KeyregOfflineTxn(sender, params) - elif "nonparticipation" in t: - txn = transaction.KeyregNonparticipatingTxn(sender, params) - return txn From b4bba52e16b8096cff802a9657b80c712b4394f4 Mon Sep 17 00:00:00 2001 From: algochoi <86622919+algochoi@users.noreply.github.com> Date: Fri, 8 Jul 2022 01:29:40 -0400 Subject: [PATCH 03/36] Change testing branch --- run_integration.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/run_integration.sh b/run_integration.sh index 8e680e34..ee10792b 100755 --- a/run_integration.sh +++ b/run_integration.sh @@ -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 delete-v1-tests https://github.com/algorand/algorand-sdk-testing.git test-harness ## Copy feature files into the project resources mkdir -p tests/features From a30a72f4ef264ff073ab1318e3684eca5c8a1cc4 Mon Sep 17 00:00:00 2001 From: algochoi <86622919+algochoi@users.noreply.github.com> Date: Fri, 8 Jul 2022 01:46:10 -0400 Subject: [PATCH 04/36] Formatting --- tests/steps/other_v2_steps.py | 30 ++++++++++++++---------------- tests/steps/steps.py | 10 +--------- 2 files changed, 15 insertions(+), 25 deletions(-) diff --git a/tests/steps/other_v2_steps.py b/tests/steps/other_v2_steps.py index 31ac1e01..c1c9c1c0 100644 --- a/tests/steps/other_v2_steps.py +++ b/tests/steps/other_v2_steps.py @@ -2,36 +2,34 @@ import json import os import random -import urllib import unittest +import urllib from datetime import datetime from pathlib import Path from urllib.request import Request, urlopen -import time - -from behave import ( - given, - when, - then, - register_type, - step, -) # pylint: disable=no-name-in-module -from glom import glom import parse from algosdk import constants, dryrun_results, encoding, error, mnemonic from algosdk.error import AlgodHTTPError from algosdk.future import transaction +from algosdk.testing.dryrun import DryrunTestCaseMixin from algosdk.v2client import * from algosdk.v2client.models import ( - DryrunRequest, - DryrunSource, Account, ApplicationLocalState, + DryrunRequest, + DryrunSource, ) -from algosdk.testing.dryrun import DryrunTestCaseMixin - -from tests.steps.steps import algod_port, token as daemon_token +from behave import ( + given, + register_type, # pylint: disable=no-name-in-module + step, + then, + when, +) +from glom import glom +from tests.steps.steps import algod_port +from tests.steps.steps import token as daemon_token @parse.with_pattern(r".*") diff --git a/tests/steps/steps.py b/tests/steps/steps.py index 7c4cede4..d4c6f75e 100644 --- a/tests/steps/steps.py +++ b/tests/steps/steps.py @@ -1,12 +1,4 @@ -from datetime import datetime - -from algosdk import ( - account, - auction, - encoding, - kmd, - wallet, -) +from algosdk import account, auction, encoding, kmd, wallet from algosdk.future import transaction from behave import given, then, when From 4959a47d152a20935b74487650ea6796fd49f1b0 Mon Sep 17 00:00:00 2001 From: algochoi <86622919+algochoi@users.noreply.github.com> Date: Fri, 8 Jul 2022 18:04:06 -0400 Subject: [PATCH 05/36] Use randint instead of randbytes due to 3.8 support --- tests/steps/other_v2_steps.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/steps/other_v2_steps.py b/tests/steps/other_v2_steps.py index c1c9c1c0..2d83a0de 100644 --- a/tests/steps/other_v2_steps.py +++ b/tests/steps/other_v2_steps.py @@ -105,7 +105,7 @@ def send_zero_transactions(context, txns=1): sp, constants.ZERO_ADDRESS, 0, - note=random.randbytes(8), + note=random.randint(0, 256).to_bytes(8, "big"), ) signed_payment = context.wallet.sign_transaction(payment) context.app_acl.send_transaction(signed_payment) From 1427eff82ab4637d1e74ef99f6ae0825c7542216 Mon Sep 17 00:00:00 2001 From: algochoi <86622919+algochoi@users.noreply.github.com> Date: Wed, 13 Jul 2022 16:00:56 -0400 Subject: [PATCH 06/36] Revert "Revise and delete v1 algod steps and add devmode helpers" This reverts commit d951d7530a0bdd580b0983a654a83df5df370a63. --- tests/steps/steps.py | 869 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 869 insertions(+) diff --git a/tests/steps/steps.py b/tests/steps/steps.py index d4c6f75e..82ab2030 100644 --- a/tests/steps/steps.py +++ b/tests/steps/steps.py @@ -1,12 +1,28 @@ from algosdk import account, auction, encoding, kmd, wallet from algosdk.future import transaction from behave import given, then, when +from nacl.signing import SigningKey token = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" algod_port = 60000 kmd_port = 60001 +# Send a zero payment transaction +def send_zero_transactions(context, txns=1): + sp = context.acl.suggested_params_as_object() + for _ in range(txns): + payment = transaction.PaymentTxn( + context.accounts[0], + sp, + constants.ZERO_ADDRESS, + 0, + note=random.randbytes(8), + ) + signed_payment = context.wallet.sign_transaction(payment) + context.acl.send_transaction(signed_payment) + + @when("I create a wallet") def create_wallet(context): context.wallet_name = "Walletpy" @@ -76,12 +92,122 @@ def try_handle(context): assert context.error +@given( + 'payment transaction parameters {fee} {fv} {lv} "{gh}" "{to}" "{close}" {amt} "{gen}" "{note}"' +) +def txn_params(context, fee, fv, lv, gh, to, close, amt, gen, note): + context.fee = int(fee) + context.fv = int(fv) + context.lv = int(lv) + context.gh = gh + context.to = to + context.amt = int(amt) + if context.fee == 0: + context.params = transaction.SuggestedParams( + context.fee, context.fv, context.lv, context.gh, gen, flat_fee=True + ) + else: + context.params = transaction.SuggestedParams( + context.fee, context.fv, context.lv, context.gh, gen + ) + if close == "none": + context.close = None + else: + context.close = close + if note == "none": + context.note = None + else: + context.note = base64.b64decode(note) + if gen == "none": + context.gen = None + else: + context.gen = gen + + +@given('mnemonic for private key "{mn}"') +def mn_for_sk(context, mn): + context.mn = mn + context.sk = mnemonic.to_private_key(mn) + context.pk = account.address_from_private_key(context.sk) + + +@when("I create the payment transaction") +def create_paytxn(context): + context.txn = transaction.PaymentTxn( + context.pk, + context.params, + context.to, + context.amt, + context.close, + context.note, + ) + + @given('multisig addresses "{addresses}"') def msig_addresses(context, addresses): addresses = addresses.split(" ") context.msig = transaction.Multisig(1, 2, addresses) +@when("I create the multisig payment transaction") +def create_msigpaytxn(context): + context.txn = transaction.PaymentTxn( + context.msig.address(), + context.params, + context.to, + context.amt, + context.close, + context.note, + ) + context.mtx = transaction.MultisigTransaction(context.txn, context.msig) + + +@when("I create the multisig payment transaction with zero fee") +def create_msigpaytxn_zero_fee(context): + context.txn = transaction.PaymentTxn( + context.msig.address(), + context.params, + context.to, + context.amt, + context.close, + context.note, + ) + context.mtx = transaction.MultisigTransaction(context.txn, context.msig) + + +@when("I sign the multisig transaction with the private key") +def sign_msig(context): + context.mtx.sign(context.sk) + + +@when("I sign the transaction with the private key") +def sign_with_sk(context): + context.stx = context.txn.sign(context.sk) + + +@then('the signed transaction should equal the golden "{golden}"') +def equal_golden(context, golden): + assert encoding.msgpack_encode(context.stx) == golden + + +@then('the multisig address should equal the golden "{golden}"') +def equal_msigaddr_golden(context, golden): + assert context.msig.address() == golden + + +@then('the multisig transaction should equal the golden "{golden}"') +def equal_msig_golden(context, golden): + if not encoding.msgpack_encode(context.mtx) == golden: + print(encoding.msgpack_encode(context.mtx)) + print(golden) + assert encoding.msgpack_encode(context.mtx) == golden + + +@when("I get versions with algod") +def acl_v(context): + context.versions = context.acl.versions()["versions"] + + @then("v1 should be in the versions") def v1_in_versions(context): assert "v1" in context.versions @@ -92,6 +218,25 @@ def kcl_v(context): context.versions = context.kcl.versions() +@when("I get the status") +def status(context): + context.status = context.acl.status() + + +@when("I get status after this block") +def status_block(context): + send_zero_transactions(context) + context.status_after = context.acl.status_after_block( + context.status["lastRound"] + ) + + +@then("I can get the block info") +def block(context): + send_zero_transactions(context) + context.block = context.acl.block_info(context.status["lastRound"] + 1) + + @when("I import the multisig") def import_msig(context): context.wallet.import_multisig(context.msig) @@ -172,6 +317,15 @@ def kmd_client(context): context.kcl = kmd.KMDClient(token, kmd_address) +@given("an algod client") +def algod_client(context): + algod_address = "http://localhost:" + str(algod_port) + context.acl = algod.AlgodClient(token, algod_address) + if context.acl.status()["lastRound"] < 2: + send_zero_transactions(context, 2) + context.acl.status_after_block(2) + + @given("wallet information") def wallet_info(context): context.wallet_name = "unencrypted-default-wallet" @@ -181,6 +335,198 @@ def wallet_info(context): ) context.wallet_id = context.wallet.id context.accounts = context.wallet.list_keys() + print("ASDF ", context.accounts) + + +@given('default transaction with parameters {amt} "{note}"') +def default_txn(context, amt, note): + params = context.acl.suggested_params_as_object() + context.last_round = params.first + if note == "none": + note = None + else: + note = base64.b64decode(note) + context.txn = transaction.PaymentTxn( + context.accounts[0], params, context.accounts[1], int(amt), note=note + ) + context.pk = context.accounts[0] + + +@given('default multisig transaction with parameters {amt} "{note}"') +def default_msig_txn(context, amt, note): + params = context.acl.suggested_params_as_object() + context.last_round = params.first + if note == "none": + note = None + else: + note = base64.b64decode(note) + context.msig = transaction.Multisig(1, 1, context.accounts) + context.txn = transaction.PaymentTxn( + context.msig.address(), + params, + context.accounts[1], + int(amt), + note=note, + ) + context.mtx = transaction.MultisigTransaction(context.txn, context.msig) + context.pk = context.accounts[0] + + +@when("I get the private key") +def get_sk(context): + context.sk = context.wallet.export_key(context.pk) + + +@when("I send the transaction") +def send_txn(context): + try: + context.acl.send_transaction(context.stx) + except: + context.error = True + + +@when("I send the kmd-signed transaction") +def send_txn_kmd(context): + context.acl.send_transaction(context.stx_kmd) + + +@when("I send the bogus kmd-signed transaction") +def send_txn_kmd_bogus(context): + try: + context.acl.send_transaction(context.stx_kmd) + except: + context.error = True + + +@when("I send the multisig transaction") +def send_msig_txn(context): + try: + context.acl.send_transaction(context.mtx) + except: + context.error = True + + +@then("the transaction should go through") +def check_txn(context): + last_round = context.acl.status()["lastRound"] + assert "type" in context.acl.pending_transaction_info( + context.txn.get_txid() + ) + send_zero_transactions(context, 3) + context.acl.status_after_block(last_round + 2) + assert "type" in context.acl.transaction_info( + context.txn.sender, context.txn.get_txid() + ) + assert "type" in context.acl.transaction_by_id(context.txn.get_txid()) + + +@then("I can get the transaction by ID") +def get_txn_by_id(context): + send_zero_transactions(context, 3) + context.acl.status_after_block(context.last_round + 2) + assert "type" in context.acl.transaction_by_id(context.txn.get_txid()) + + +@then("the transaction should not go through") +def txn_fail(context): + assert context.error + + +@when("I sign the transaction with kmd") +def sign_kmd(context): + context.stx_kmd = context.wallet.sign_transaction(context.txn) + + +@then("the signed transaction should equal the kmd signed transaction") +def sign_both_equal(context): + assert encoding.msgpack_encode(context.stx) == encoding.msgpack_encode( + context.stx_kmd + ) + + +@when("I sign the multisig transaction with kmd") +def sign_msig_kmd(context): + context.mtx_kmd = context.wallet.sign_multisig_transaction( + context.accounts[0], context.mtx + ) + + +@then( + "the multisig transaction should equal the kmd signed multisig transaction" +) +def sign_msig_both_equal(context): + assert encoding.msgpack_encode(context.mtx) == encoding.msgpack_encode( + context.mtx_kmd + ) + + +@when('I read a transaction "{txn}" from file "{num}"') +def read_txn(context, txn, num): + dir_path = os.path.dirname(os.path.realpath(__file__)) + dir_path = os.path.dirname(os.path.dirname(dir_path)) + context.num = num + context.txn = transaction.retrieve_from_file( + dir_path + "/temp/raw" + num + ".tx" + )[0] + + +@when("I write the transaction to file") +def write_txn(context): + dir_path = os.path.dirname(os.path.realpath(__file__)) + dir_path = os.path.dirname(os.path.dirname(dir_path)) + transaction.write_to_file( + [context.txn], dir_path + "/temp/raw" + context.num + ".tx" + ) + + +@then("the transaction should still be the same") +def check_enc(context): + dir_path = os.path.dirname(os.path.realpath(__file__)) + dir_path = os.path.dirname(os.path.dirname(dir_path)) + new = transaction.retrieve_from_file( + dir_path + "/temp/raw" + context.num + ".tx" + ) + old = transaction.retrieve_from_file( + dir_path + "/temp/old" + context.num + ".tx" + ) + assert encoding.msgpack_encode(new[0]) == encoding.msgpack_encode(old[0]) + + +@then("I do my part") +def check_save_txn(context): + dir_path = os.path.dirname(os.path.realpath(__file__)) + dir_path = os.path.dirname(os.path.dirname(dir_path)) + stx = transaction.retrieve_from_file(dir_path + "/temp/txn.tx")[0] + txid = stx.transaction.get_txid() + last_round = context.acl.status()["lastRound"] + send_zero_transactions(context, 3) + context.acl.status_after_block(last_round + 2) + assert context.acl.transaction_info(stx.transaction.sender, txid) + + +@then("I get the ledger supply") +def get_ledger(context): + context.acl.ledger_supply() + + +@then("the node should be healthy") +def check_health(context): + assert context.acl.health() == None + + +@when("I get the suggested params") +def suggested_params(context): + context.params = context.acl.suggested_params_as_object() + + +@when("I get the suggested fee") +def suggested_fee(context): + context.fee = context.acl.suggested_fee()["fee"] + + +@then("the fee in the suggested params should equal the suggested fee") +def check_suggested(context): + assert context.params.fee == context.fee @when("I create a bid") @@ -203,3 +549,526 @@ def check_bid(context): def sign_bid(context): context.sbid = context.bid.sign(context.sk) context.old = context.bid.sign(context.sk) + + +@when("I decode the address") +def decode_addr(context): + context.pk = encoding.decode_address(context.pk) + + +@when("I encode the address") +def encode_addr(context): + context.pk = encoding.encode_address(context.pk) + + +@then("the address should still be the same") +def check_addr(context): + assert context.pk == context.old + + +@when("I convert the private key back to a mnemonic") +def sk_to_mn(context): + context.mn = mnemonic.from_private_key(context.sk) + + +@then('the mnemonic should still be the same as "{mn}"') +def check_mn(context, mn): + assert context.mn == mn + + +@given('mnemonic for master derivation key "{mn}"') +def mn_for_mdk(context, mn): + context.mn = mn + context.mdk = mnemonic.to_master_derivation_key(mn) + + +@when("I convert the master derivation key back to a mnemonic") +def mdk_to_mn(context): + context.mn = mnemonic.from_master_derivation_key(context.mdk) + + +@when("I create the flat fee payment transaction") +def create_paytxn_flat_fee(context): + context.params.flat_fee = True + context.txn = transaction.PaymentTxn( + context.pk, + context.params, + context.to, + context.amt, + context.close, + context.note, + ) + + +@given('encoded multisig transaction "{mtx}"') +def dec_mtx(context, mtx): + context.mtx = encoding.msgpack_decode(mtx) + + +@when("I append a signature to the multisig transaction") +def append_mtx(context): + context.mtx.sign(context.sk) + + +@given('encoded multisig transactions "{msigtxns}"') +def mtxs(context, msigtxns): + context.mtxs = msigtxns.split(" ") + context.mtxs = [encoding.msgpack_decode(m) for m in context.mtxs] + + +@when("I merge the multisig transactions") +def merge_mtxs(context): + context.mtx = transaction.MultisigTransaction.merge(context.mtxs) + + +@when("I convert {microalgos} microalgos to algos and back") +def convert_algos(context, microalgos): + context.microalgos = util.algos_to_microalgos( + util.microalgos_to_algos(int(microalgos)) + ) + + +@then("it should still be the same amount of microalgos {microalgos}") +def check_microalgos(context, microalgos): + assert int(microalgos) == context.microalgos + + +@then("I get transactions by address and round") +def txns_by_addr_round(context): + txns = context.acl.transactions_by_address( + context.accounts[0], first=1, last=context.acl.status()["lastRound"] + ) + assert txns == {} or "transactions" in txns + + +@then("I get transactions by address only") +def txns_by_addr_only(context): + txns = context.acl.transactions_by_address(context.accounts[0]) + assert txns == {} or "transactions" in txns + + +@then("I get transactions by address and date") +def txns_by_addr_date(context): + date = datetime.today().strftime("%Y-%m-%d") + txns = context.acl.transactions_by_address( + context.accounts[0], from_date=date, to_date=date + ) + assert txns == {} or "transactions" in txns + + +@then("I get pending transactions") +def txns_pending(context): + txns = context.acl.pending_transactions() + assert txns == {} or "truncatedTxns" in txns + + +@then("I get account information") +def acc_info(context): + context.acl.account_info(context.accounts[0]) + + +@then("I can get account information") +def new_acc_info(context): + context.acl.account_info(context.pk) + context.wallet.delete_key(context.pk) + + +@given( + 'key registration transaction parameters {fee} {fv} {lv} "{gh}" "{votekey}" "{selkey}" {votefst} {votelst} {votekd} "{gen}" "{note}"' +) +def keyreg_txn_params( + context, + fee, + fv, + lv, + gh, + votekey, + selkey, + votefst, + votelst, + votekd, + gen, + note, +): + context.fee = int(fee) + context.fv = int(fv) + context.lv = int(lv) + context.gh = gh + context.votekey = votekey + context.selkey = selkey + context.votefst = int(votefst) + context.votelst = int(votelst) + context.votekd = int(votekd) + if gen == "none": + context.gen = None + else: + context.gen = gen + context.params = transaction.SuggestedParams( + context.fee, context.fv, context.lv, context.gh, context.gen + ) + + if note == "none": + context.note = None + else: + context.note = base64.b64decode(note) + if gen == "none": + context.gen = None + else: + context.gen = gen + + +@when("I create the key registration transaction") +def create_keyreg_txn(context): + context.txn = transaction.KeyregOnlineTxn( + context.pk, + context.params, + context.votekey, + context.selkey, + context.votefst, + context.votelst, + context.votekd, + context.note, + ) + + +@given("default V2 key registration transaction {type}") +def default_v2_keyreg_txn(context, type): + context.params = context.acl.suggested_params_as_object() + context.pk = context.accounts[0] + context.txn = buildTxn(type, context.pk, context.params) + + +@when("I get recent transactions, limited by {cnt} transactions") +def step_impl(context, cnt): + txns = context.acl.transactions_by_address( + context.accounts[0], limit=int(cnt) + ) + assert txns == {} or "transactions" in txns + + +@given("default asset creation transaction with total issuance {total}") +def default_asset_creation_txn(context, total): + context.total = int(total) + params = context.acl.suggested_params_as_object() + context.last_round = params.first + context.pk = context.accounts[0] + asset_name = "asset" + unit_name = "unit" + params.fee = 1 + context.txn = transaction.AssetConfigTxn( + context.pk, + params, + total=context.total, + default_frozen=False, + unit_name=unit_name, + asset_name=asset_name, + manager=context.pk, + reserve=context.pk, + freeze=context.pk, + clawback=context.pk, + ) + + context.expected_asset_info = { + "defaultfrozen": False, + "unitname": "unit", + "assetname": "asset", + "managerkey": context.pk, + "reserveaddr": context.pk, + "freezeaddr": context.pk, + "clawbackaddr": context.pk, + "creator": context.pk, + "total": context.total, + "decimals": 0, + "metadatahash": None, + "url": "", + } + print("GGGG ", context.pk) + + +@given("default-frozen asset creation transaction with total issuance {total}") +def default_frozen_asset_creation_txn(context, total): + context.total = int(total) + params = context.acl.suggested_params_as_object() + context.last_round = params.first + context.pk = context.accounts[0] + asset_name = "asset" + unit_name = "unit" + params.fee = 1 + context.txn = transaction.AssetConfigTxn( + context.pk, + params, + total=context.total, + default_frozen=True, + unit_name=unit_name, + asset_name=asset_name, + manager=context.pk, + reserve=context.pk, + freeze=context.pk, + clawback=context.pk, + ) + + context.expected_asset_info = { + "defaultfrozen": False, + "unitname": "unit", + "assetname": "asset", + "managerkey": context.pk, + "reserveaddr": context.pk, + "freezeaddr": context.pk, + "clawbackaddr": context.pk, + "creator": context.pk, + "total": context.total, + "decimals": 0, + "metadatahash": None, + "url": "", + } + + +@given("asset test fixture") +def asset_fixture(context): + context.expected_asset_info = dict() + context.rcv = context.accounts[1] + + +@when("I update the asset index") +def update_asset_index(context): + assets = context.acl.list_assets()["assets"] + indices = [a["AssetIndex"] for a in assets] + context.asset_index = max(indices) + + +@when("I get the asset info") +def get_asset_info(context): + context.asset_info = context.acl.asset_info(context.asset_index) + + +@then("the asset info should match the expected asset info") +def asset_info_match(context): + for k in context.expected_asset_info: + assert ( + context.expected_asset_info[k] == context.asset_info.get(k) + ) or ( + (not context.expected_asset_info[k]) + and (not context.asset_info.get(k)) + ) + + +@when("I create an asset destroy transaction") +def create_asset_destroy_txn(context): + context.txn = transaction.AssetConfigTxn( + context.pk, + context.acl.suggested_params_as_object(), + index=context.asset_index, + strict_empty_address_check=False, + ) + + +@then("I should be unable to get the asset info") +def err_asset_info(context): + err = False + try: + context.acl.asset_info(context.pk, context.asset_index) + except: + err = True + assert err + + +@when("I create a no-managers asset reconfigure transaction") +def no_manager_txn(context): + context.txn = transaction.AssetConfigTxn( + context.pk, + context.acl.suggested_params_as_object(), + index=context.asset_index, + reserve=context.pk, + clawback=context.pk, + freeze=context.pk, + strict_empty_address_check=False, + ) + + context.expected_asset_info["managerkey"] = "" + + +@when( + "I create a transaction for a second account, signalling asset acceptance" +) +def accept_asset_txn(context): + params = context.acl.suggested_params_as_object() + context.txn = transaction.AssetTransferTxn( + context.rcv, params, context.rcv, 0, context.asset_index + ) + + +@when( + "I create a transaction transferring {amount} assets from creator to a second account" +) +def transfer_assets(context, amount): + params = context.acl.suggested_params_as_object() + context.txn = transaction.AssetTransferTxn( + context.pk, params, context.rcv, int(amount), context.asset_index + ) + + +@when( + "I create a transaction transferring {amount} assets from a second account to creator" +) +def transfer_assets_to_creator(context, amount): + params = context.acl.suggested_params_as_object() + context.txn = transaction.AssetTransferTxn( + context.rcv, params, context.pk, int(amount), context.asset_index + ) + + +@then("the creator should have {exp_balance} assets remaining") +def check_asset_balance(context, exp_balance): + asset_info = context.acl.account_info(context.pk)["assets"][ + str(context.asset_index) + ] + assert asset_info["amount"] == int(exp_balance) + + +@when("I create a freeze transaction targeting the second account") +def freeze_txn(context): + params = context.acl.suggested_params_as_object() + context.txn = transaction.AssetFreezeTxn( + context.pk, params, context.asset_index, context.rcv, True + ) + + +@when("I create an un-freeze transaction targeting the second account") +def unfreeze_txn(context): + params = context.acl.suggested_params_as_object() + context.txn = transaction.AssetFreezeTxn( + context.pk, params, context.asset_index, context.rcv, False + ) + + +@when( + "I create a transaction revoking {amount} assets from a second account to creator" +) +def revoke_txn(context, amount): + params = context.acl.suggested_params_as_object() + context.txn = transaction.AssetTransferTxn( + context.pk, + params, + context.pk, + int(amount), + context.asset_index, + revocation_target=context.rcv, + ) + + +@given("I sign the transaction with the private key") +def given_sign_with_sk(context): + # python cucumber considers "Given foo" and "When foo" to be distinct, + # but we don't want them to be. So, call the other function + sign_with_sk(context) + + +@given("I send the transaction") +def given_send_txn(context): + # python cucumber considers "Given foo" and "When foo" to be distinct, + # but we don't want them to be. So, call the other function + send_txn(context) + + +@when('mnemonic for private key "{mn}"') +def when_mn_for_sk(context, mn): + # python cucumber considers "Given foo" and "When foo" to be distinct, + # but we don't want them to be. So, call the other function + mn_for_sk(context, mn) + + +@when('I set the from address to "{from_addr}"') +def set_from_to(context, from_addr): + context.txn.sender = from_addr + + +@when("I add a rekeyTo field with the private key algorand address") +def add_rekey_to_sk(context): + context.txn.rekey_to = account.address_from_private_key(context.sk) + + +@when('I add a rekeyTo field with address "{rekey}"') +def add_rekey_to_address(context, rekey): + context.txn.rekey_to = rekey + + +@given('base64 encoded data to sign "{data_enc}"') +def set_base64_encoded_data(context, data_enc): + context.data = base64.b64decode(data_enc) + + +@given('program hash "{contract_addr}"') +def set_program_hash(context, contract_addr): + context.address = contract_addr + + +@when("I perform tealsign") +def perform_tealsign(context): + context.sig = logic.teal_sign(context.sk, context.data, context.address) + + +@then('the signature should be equal to "{sig_enc}"') +def check_tealsign(context, sig_enc): + expected = base64.b64decode(sig_enc) + assert expected == context.sig + + +@given('base64 encoded program "{program_enc}"') +def set_program_hash_from_program(context, program_enc): + program = base64.b64decode(program_enc) + context.address = logic.address(program) + + +@given('base64 encoded private key "{sk_enc}"') +def set_sk_from_encoded_seed(context, sk_enc): + seed = base64.b64decode(sk_enc) + key = SigningKey(seed) + private_key = base64.b64encode( + key.encode() + key.verify_key.encode() + ).decode() + context.sk = private_key + + +@then("fee field is in txn") +def fee_in_txn(context): + if "signed_transaction" in context: + stxn = context.signed_transaction.dictify() + else: + stxn = context.mtx.dictify() + + assert "fee" in stxn["txn"] + + +@then("fee field not in txn") +def fee_not_in_txn(context): + if "signed_transaction" in context: + stxn = context.signed_transaction.dictify() + else: + stxn = context.mtx.dictify() + assert "fee" not in stxn["txn"] + + +def buildTxn(t, sender, params): + txn = None + if "online" in t: + votekey = "9mr13Ri8rFepxN3ghIUrZNui6LqqM5hEzB45Rri5lkU=" + selkey = "dx717L3uOIIb/jr9OIyls1l5Ei00NFgRa380w7TnPr4=" + votefst = 0 + votelst = 2000 + votekd = 10 + sprf = "mYR0GVEObMTSNdsKM6RwYywHYPqVDqg3E4JFzxZOreH9NU8B+tKzUanyY8AQ144hETgSMX7fXWwjBdHz6AWk9w==" + txn = transaction.KeyregOnlineTxn( + sender, + params, + votekey, + selkey, + votefst, + votelst, + votekd, + sprfkey=sprf, + ) + elif "offline" in t: + txn = transaction.KeyregOfflineTxn(sender, params) + elif "nonparticipation" in t: + txn = transaction.KeyregNonparticipatingTxn(sender, params) + return txn From 8cb4e89778c1e76680d6aa3d89d5068dc3ea3b51 Mon Sep 17 00:00:00 2001 From: algochoi <86622919+algochoi@users.noreply.github.com> Date: Wed, 13 Jul 2022 16:19:32 -0400 Subject: [PATCH 07/36] Make v1 tests work again --- tests/steps/steps.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/steps/steps.py b/tests/steps/steps.py index 82ab2030..a3f271c4 100644 --- a/tests/steps/steps.py +++ b/tests/steps/steps.py @@ -1,4 +1,6 @@ -from algosdk import account, auction, encoding, kmd, wallet +import random + +from algosdk import account, algod, auction, constants, encoding, kmd, wallet from algosdk.future import transaction from behave import given, then, when from nacl.signing import SigningKey @@ -17,7 +19,7 @@ def send_zero_transactions(context, txns=1): sp, constants.ZERO_ADDRESS, 0, - note=random.randbytes(8), + note=random.randint(0, 256).to_bytes(8, "big"), ) signed_payment = context.wallet.sign_transaction(payment) context.acl.send_transaction(signed_payment) From 93e56c844bafb24bf5fbaf90b42c06add6afcaab Mon Sep 17 00:00:00 2001 From: algochoi <86622919+algochoi@users.noreply.github.com> Date: Wed, 13 Jul 2022 16:34:50 -0400 Subject: [PATCH 08/36] Change testing branch --- run_integration.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/run_integration.sh b/run_integration.sh index ee10792b..3eef8827 100755 --- a/run_integration.sh +++ b/run_integration.sh @@ -7,7 +7,7 @@ pushd $rootdir # Reset test harness rm -rf test-harness -git clone --single-branch --branch delete-v1-tests https://github.com/algorand/algorand-sdk-testing.git test-harness +git clone --single-branch --branch devmodenet https://github.com/algorand/algorand-sdk-testing.git test-harness ## Copy feature files into the project resources mkdir -p tests/features From c20a0e8f52e40cff85883edfa38926dd6e4bd62d Mon Sep 17 00:00:00 2001 From: algochoi <86622919+algochoi@users.noreply.github.com> Date: Fri, 15 Jul 2022 15:35:27 -0400 Subject: [PATCH 09/36] Delete debug print statements --- tests/steps/steps.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/steps/steps.py b/tests/steps/steps.py index a3f271c4..fcbf5ae8 100644 --- a/tests/steps/steps.py +++ b/tests/steps/steps.py @@ -337,7 +337,6 @@ def wallet_info(context): ) context.wallet_id = context.wallet.id context.accounts = context.wallet.list_keys() - print("ASDF ", context.accounts) @given('default transaction with parameters {amt} "{note}"') @@ -784,7 +783,6 @@ def default_asset_creation_txn(context, total): "metadatahash": None, "url": "", } - print("GGGG ", context.pk) @given("default-frozen asset creation transaction with total issuance {total}") From 884473fcef8837f21ed95e785f3b4b391a76cc25 Mon Sep 17 00:00:00 2001 From: algochoi <86622919+algochoi@users.noreply.github.com> Date: Fri, 15 Jul 2022 17:45:16 -0400 Subject: [PATCH 10/36] Increase timeout and add back imports --- .circleci/config.yml | 1 + tests/steps/steps.py | 18 ++++++++++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index e0e2bfdb..9ab4ef1b 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -42,6 +42,7 @@ jobs: steps: - checkout - run: + no_output_timeout: 30m # NOTE: We might add caching at `pip` level here. command: | pip install -r requirements.txt diff --git a/tests/steps/steps.py b/tests/steps/steps.py index fcbf5ae8..27124014 100644 --- a/tests/steps/steps.py +++ b/tests/steps/steps.py @@ -1,6 +1,20 @@ +import base64 +import os import random - -from algosdk import account, algod, auction, constants, encoding, kmd, wallet +from datetime import datetime + +from algosdk import ( + account, + algod, + auction, + constants, + encoding, + kmd, + logic, + mnemonic, + util, + wallet, +) from algosdk.future import transaction from behave import given, then, when from nacl.signing import SigningKey From 26772d008f467d96cc9862381805a7f52d815248 Mon Sep 17 00:00:00 2001 From: algochoi <86622919+algochoi@users.noreply.github.com> Date: Mon, 18 Jul 2022 09:17:41 -0400 Subject: [PATCH 11/36] Change circle configs to increase timeout --- .circleci/config.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 9ab4ef1b..1699e5a2 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -34,7 +34,9 @@ jobs: image: "ubuntu-2004:202104-01" steps: - checkout - - run: PYTHON_VERSION=<< parameters.python-version >> make docker-test + - run: + no_output_timeout: 30m + command: PYTHON_VERSION=<< parameters.python-version >> make docker-test docset: docker: # NOTE: We might eventually need Docker authentication here. @@ -42,7 +44,6 @@ jobs: steps: - checkout - run: - no_output_timeout: 30m # NOTE: We might add caching at `pip` level here. command: | pip install -r requirements.txt From f7d13e46f3d69d710c0c332ad17f506c4ca2c448 Mon Sep 17 00:00:00 2001 From: algochoi <86622919+algochoi@users.noreply.github.com> Date: Mon, 18 Jul 2022 09:56:11 -0400 Subject: [PATCH 12/36] Delete v1 integration tests just to see passing CI --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index ebb44f15..6f873c09 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ UNITS = "@unit.abijson or @unit.abijson.byname or @unit.algod or @unit.algod.led 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 or @compile.sourcemap" +INTEGRATIONS = "@abi or @applications or @applications.verified or @auction or @c2c or @compile or @dryrun or @dryrun.testing or @indexer or @indexer.231 or @indexer.applications or @kmd or @send.keyregtxn or @compile.sourcemap" integration: behave --tags=$(INTEGRATIONS) tests -f progress2 From a0135b3086be53109628b3691d1ae3352a9dc60c Mon Sep 17 00:00:00 2001 From: algochoi <86622919+algochoi@users.noreply.github.com> Date: Mon, 18 Jul 2022 11:53:27 -0400 Subject: [PATCH 13/36] Revert v1 tests and add wait times --- Makefile | 2 +- tests/steps/other_v2_steps.py | 2 ++ tests/steps/steps.py | 3 ++- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 6f873c09..ebb44f15 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ UNITS = "@unit.abijson or @unit.abijson.byname or @unit.algod or @unit.algod.led unit: behave --tags=$(UNITS) tests -f progress2 -INTEGRATIONS = "@abi or @applications or @applications.verified or @auction or @c2c or @compile or @dryrun or @dryrun.testing or @indexer or @indexer.231 or @indexer.applications or @kmd or @send.keyregtxn or @compile.sourcemap" +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 or @compile.sourcemap" integration: behave --tags=$(INTEGRATIONS) tests -f progress2 diff --git a/tests/steps/other_v2_steps.py b/tests/steps/other_v2_steps.py index ab15987f..16a7c136 100644 --- a/tests/steps/other_v2_steps.py +++ b/tests/steps/other_v2_steps.py @@ -111,6 +111,8 @@ def send_zero_transactions(context, txns=1): ) signed_payment = context.wallet.sign_transaction(payment) context.app_acl.send_transaction(signed_payment) + # Wait and confirm that the zero payment succeeded. + transaction.wait_for_confirmation(context.app_acl, signed_payment, 5) # To prevent excess waiting, send a zero payment transaction before diff --git a/tests/steps/steps.py b/tests/steps/steps.py index 27124014..af37ac57 100644 --- a/tests/steps/steps.py +++ b/tests/steps/steps.py @@ -32,11 +32,12 @@ def send_zero_transactions(context, txns=1): context.accounts[0], sp, constants.ZERO_ADDRESS, - 0, + random.randint(0, 100000), note=random.randint(0, 256).to_bytes(8, "big"), ) signed_payment = context.wallet.sign_transaction(payment) context.acl.send_transaction(signed_payment) + transaction.wait_for_confirmation(context.app_acl, signed_payment, 5) @when("I create a wallet") From 7ad3bf728e7d398a7a3c2f2aed4b7eeb1030736b Mon Sep 17 00:00:00 2001 From: algochoi <86622919+algochoi@users.noreply.github.com> Date: Mon, 18 Jul 2022 12:11:31 -0400 Subject: [PATCH 14/36] Change how txids are retrieved --- tests/steps/other_v2_steps.py | 4 +++- tests/steps/steps.py | 6 ++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/tests/steps/other_v2_steps.py b/tests/steps/other_v2_steps.py index 16a7c136..0fe031e9 100644 --- a/tests/steps/other_v2_steps.py +++ b/tests/steps/other_v2_steps.py @@ -112,7 +112,9 @@ def send_zero_transactions(context, txns=1): signed_payment = context.wallet.sign_transaction(payment) context.app_acl.send_transaction(signed_payment) # Wait and confirm that the zero payment succeeded. - transaction.wait_for_confirmation(context.app_acl, signed_payment, 5) + transaction.wait_for_confirmation( + context.app_acl, payment.get_txid(), 5 + ) # To prevent excess waiting, send a zero payment transaction before diff --git a/tests/steps/steps.py b/tests/steps/steps.py index af37ac57..7e047a68 100644 --- a/tests/steps/steps.py +++ b/tests/steps/steps.py @@ -32,12 +32,14 @@ def send_zero_transactions(context, txns=1): context.accounts[0], sp, constants.ZERO_ADDRESS, - random.randint(0, 100000), + random.randint(100000, 900000), note=random.randint(0, 256).to_bytes(8, "big"), ) signed_payment = context.wallet.sign_transaction(payment) context.acl.send_transaction(signed_payment) - transaction.wait_for_confirmation(context.app_acl, signed_payment, 5) + transaction.wait_for_confirmation( + context.app_acl, payment.get_txid(), 5 + ) @when("I create a wallet") From 70c034b6405da73ac368ed36e7b77b8b2294652c Mon Sep 17 00:00:00 2001 From: algochoi <86622919+algochoi@users.noreply.github.com> Date: Mon, 18 Jul 2022 12:43:56 -0400 Subject: [PATCH 15/36] Fix v1 steps again --- tests/steps/other_v2_steps.py | 2 +- tests/steps/steps.py | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/tests/steps/other_v2_steps.py b/tests/steps/other_v2_steps.py index 0fe031e9..c913eb4e 100644 --- a/tests/steps/other_v2_steps.py +++ b/tests/steps/other_v2_steps.py @@ -106,7 +106,7 @@ def send_zero_transactions(context, txns=1): context.accounts[0], sp, constants.ZERO_ADDRESS, - 0, + random.randint(100000, 900000), note=random.randint(0, 256).to_bytes(8, "big"), ) signed_payment = context.wallet.sign_transaction(payment) diff --git a/tests/steps/steps.py b/tests/steps/steps.py index 7e047a68..0282296f 100644 --- a/tests/steps/steps.py +++ b/tests/steps/steps.py @@ -37,9 +37,7 @@ def send_zero_transactions(context, txns=1): ) signed_payment = context.wallet.sign_transaction(payment) context.acl.send_transaction(signed_payment) - transaction.wait_for_confirmation( - context.app_acl, payment.get_txid(), 5 - ) + transaction.wait_for_confirmation(context.acl, payment.get_txid(), 5) @when("I create a wallet") @@ -426,11 +424,11 @@ def send_msig_txn(context): @then("the transaction should go through") def check_txn(context): + send_zero_transactions(context, 3) last_round = context.acl.status()["lastRound"] assert "type" in context.acl.pending_transaction_info( context.txn.get_txid() ) - send_zero_transactions(context, 3) context.acl.status_after_block(last_round + 2) assert "type" in context.acl.transaction_info( context.txn.sender, context.txn.get_txid() From 1fc20474cfe004c369cd1097bfb13487d0edc619 Mon Sep 17 00:00:00 2001 From: algochoi <86622919+algochoi@users.noreply.github.com> Date: Mon, 18 Jul 2022 13:38:48 -0400 Subject: [PATCH 16/36] Use v1 functions --- tests/steps/steps.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tests/steps/steps.py b/tests/steps/steps.py index 0282296f..0b8c2483 100644 --- a/tests/steps/steps.py +++ b/tests/steps/steps.py @@ -1,6 +1,7 @@ import base64 import os import random +import time from datetime import datetime from algosdk import ( @@ -37,7 +38,7 @@ def send_zero_transactions(context, txns=1): ) signed_payment = context.wallet.sign_transaction(payment) context.acl.send_transaction(signed_payment) - transaction.wait_for_confirmation(context.acl, payment.get_txid(), 5) + time.sleep(0.1) @when("I create a wallet") @@ -426,9 +427,9 @@ def send_msig_txn(context): def check_txn(context): send_zero_transactions(context, 3) last_round = context.acl.status()["lastRound"] - assert "type" in context.acl.pending_transaction_info( - context.txn.get_txid() - ) + # assert "type" in context.acl.pending_transaction_info( + # context.txn.get_txid() + # ) context.acl.status_after_block(last_round + 2) assert "type" in context.acl.transaction_info( context.txn.sender, context.txn.get_txid() From 7fa997bdf29aac4d7d2fc2f39348532df849bf69 Mon Sep 17 00:00:00 2001 From: algochoi <86622919+algochoi@users.noreply.github.com> Date: Mon, 18 Jul 2022 15:59:15 -0400 Subject: [PATCH 17/36] Try fixing v1 tests --- tests/steps/steps.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/tests/steps/steps.py b/tests/steps/steps.py index 0b8c2483..0a0e25d5 100644 --- a/tests/steps/steps.py +++ b/tests/steps/steps.py @@ -28,17 +28,17 @@ # Send a zero payment transaction def send_zero_transactions(context, txns=1): sp = context.acl.suggested_params_as_object() + if not hasattr(context, "pk"): + context.pk = context.accounts[0] for _ in range(txns): payment = transaction.PaymentTxn( - context.accounts[0], - sp, - constants.ZERO_ADDRESS, - random.randint(100000, 900000), - note=random.randint(0, 256).to_bytes(8, "big"), + sender=context.pk, + sp=sp, + receiver=constants.ZERO_ADDRESS, + amt=random.randint(100000, 900000), ) signed_payment = context.wallet.sign_transaction(payment) context.acl.send_transaction(signed_payment) - time.sleep(0.1) @when("I create a wallet") @@ -425,12 +425,12 @@ def send_msig_txn(context): @then("the transaction should go through") def check_txn(context): - send_zero_transactions(context, 3) - last_round = context.acl.status()["lastRound"] - # assert "type" in context.acl.pending_transaction_info( - # context.txn.get_txid() - # ) - context.acl.status_after_block(last_round + 2) + send_zero_transactions(context) + # last_round = context.acl.status()["lastRound"] + assert "type" in context.acl.pending_transaction_info( + context.txn.get_txid() + ) + # context.acl.status_after_block(last_round + 2) assert "type" in context.acl.transaction_info( context.txn.sender, context.txn.get_txid() ) From f56423855d1d93889dfc3a51b613a136ab22dce4 Mon Sep 17 00:00:00 2001 From: algochoi <86622919+algochoi@users.noreply.github.com> Date: Mon, 18 Jul 2022 21:15:38 -0400 Subject: [PATCH 18/36] Skip v1 step when waiting for certain transactions to go through --- tests/steps/other_v2_steps.py | 1 - tests/steps/steps.py | 25 +++++++++++-------------- 2 files changed, 11 insertions(+), 15 deletions(-) diff --git a/tests/steps/other_v2_steps.py b/tests/steps/other_v2_steps.py index c913eb4e..a804b052 100644 --- a/tests/steps/other_v2_steps.py +++ b/tests/steps/other_v2_steps.py @@ -107,7 +107,6 @@ def send_zero_transactions(context, txns=1): sp, constants.ZERO_ADDRESS, random.randint(100000, 900000), - note=random.randint(0, 256).to_bytes(8, "big"), ) signed_payment = context.wallet.sign_transaction(payment) context.app_acl.send_transaction(signed_payment) diff --git a/tests/steps/steps.py b/tests/steps/steps.py index 0a0e25d5..ce4b5f54 100644 --- a/tests/steps/steps.py +++ b/tests/steps/steps.py @@ -1,7 +1,6 @@ import base64 import os import random -import time from datetime import datetime from algosdk import ( @@ -27,13 +26,10 @@ # Send a zero payment transaction def send_zero_transactions(context, txns=1): - sp = context.acl.suggested_params_as_object() - if not hasattr(context, "pk"): - context.pk = context.accounts[0] for _ in range(txns): payment = transaction.PaymentTxn( - sender=context.pk, - sp=sp, + sender=context.accounts[0], + sp=context.acl.suggested_params_as_object(), receiver=constants.ZERO_ADDRESS, amt=random.randint(100000, 900000), ) @@ -425,16 +421,17 @@ def send_msig_txn(context): @then("the transaction should go through") def check_txn(context): - send_zero_transactions(context) + # send_zero_transactions(context) # last_round = context.acl.status()["lastRound"] - assert "type" in context.acl.pending_transaction_info( - context.txn.get_txid() - ) + # assert "type" in context.acl.pending_transaction_info( + # context.txn.get_txid() + # ) # context.acl.status_after_block(last_round + 2) - assert "type" in context.acl.transaction_info( - context.txn.sender, context.txn.get_txid() - ) - assert "type" in context.acl.transaction_by_id(context.txn.get_txid()) + # assert "type" in context.acl.transaction_info( + # context.txn.sender, context.txn.get_txid() + # ) + # assert "type" in context.acl.transaction_by_id(context.txn.get_txid()) + assert 1 @then("I can get the transaction by ID") From 49a8409d7950fd87554ab43bb8117acb794d5fa2 Mon Sep 17 00:00:00 2001 From: algochoi <86622919+algochoi@users.noreply.github.com> Date: Mon, 18 Jul 2022 21:38:21 -0400 Subject: [PATCH 19/36] Revert no output in CI --- .circleci/config.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 1699e5a2..e0e2bfdb 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -34,9 +34,7 @@ jobs: image: "ubuntu-2004:202104-01" steps: - checkout - - run: - no_output_timeout: 30m - command: PYTHON_VERSION=<< parameters.python-version >> make docker-test + - run: PYTHON_VERSION=<< parameters.python-version >> make docker-test docset: docker: # NOTE: We might eventually need Docker authentication here. From ac3ef79b2e1013f43aa924d742aafdc5d654dc75 Mon Sep 17 00:00:00 2001 From: algochoi <86622919+algochoi@users.noreply.github.com> Date: Tue, 19 Jul 2022 14:56:18 -0400 Subject: [PATCH 20/36] Disable v1 rekey test and some flaky v1 algod functions on dev mode --- Makefile | 2 +- tests/steps/steps.py | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index ebb44f15..45c9cf19 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ UNITS = "@unit.abijson or @unit.abijson.byname or @unit.algod or @unit.algod.led 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 or @compile.sourcemap" +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 @send.keyregtxn or @send or @compile.sourcemap" integration: behave --tags=$(INTEGRATIONS) tests -f progress2 diff --git a/tests/steps/steps.py b/tests/steps/steps.py index ce4b5f54..7f96856b 100644 --- a/tests/steps/steps.py +++ b/tests/steps/steps.py @@ -421,15 +421,15 @@ def send_msig_txn(context): @then("the transaction should go through") def check_txn(context): - # send_zero_transactions(context) + send_zero_transactions(context) # last_round = context.acl.status()["lastRound"] - # assert "type" in context.acl.pending_transaction_info( - # context.txn.get_txid() - # ) + assert "type" in context.acl.pending_transaction_info( + context.txn.get_txid() + ) # context.acl.status_after_block(last_round + 2) - # assert "type" in context.acl.transaction_info( - # context.txn.sender, context.txn.get_txid() - # ) + assert "type" in context.acl.transaction_info( + context.txn.sender, context.txn.get_txid() + ) # assert "type" in context.acl.transaction_by_id(context.txn.get_txid()) assert 1 From c90aa856c29cd008a4b753fa7318d03a5e1a3087 Mon Sep 17 00:00:00 2001 From: algochoi <86622919+algochoi@users.noreply.github.com> Date: Tue, 19 Jul 2022 14:56:34 -0400 Subject: [PATCH 21/36] Delete redundant assert --- tests/steps/steps.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/steps/steps.py b/tests/steps/steps.py index 7f96856b..02a6c40d 100644 --- a/tests/steps/steps.py +++ b/tests/steps/steps.py @@ -431,7 +431,6 @@ def check_txn(context): context.txn.sender, context.txn.get_txid() ) # assert "type" in context.acl.transaction_by_id(context.txn.get_txid()) - assert 1 @then("I can get the transaction by ID") From 8f252be504ce07e005ace274f5875a0bd5fd5875 Mon Sep 17 00:00:00 2001 From: algochoi <86622919+algochoi@users.noreply.github.com> Date: Wed, 20 Jul 2022 17:59:51 -0400 Subject: [PATCH 22/36] Initialize dev mode accounts to prevent rekeying woes --- Makefile | 2 +- tests/steps/steps.py | 25 +++++++++++++++++++++++-- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 45c9cf19..ebb44f15 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ UNITS = "@unit.abijson or @unit.abijson.byname or @unit.algod or @unit.algod.led 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 @send.keyregtxn or @send or @compile.sourcemap" +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 or @compile.sourcemap" integration: behave --tags=$(INTEGRATIONS) tests -f progress2 diff --git a/tests/steps/steps.py b/tests/steps/steps.py index 02a6c40d..53758c55 100644 --- a/tests/steps/steps.py +++ b/tests/steps/steps.py @@ -24,16 +24,33 @@ kmd_port = 60001 +# Initialize dev mode accounts. +def initialize_dev_mode_account(context): + context.dev_sk, context.dev_pk = account.generate_account() + payment = transaction.PaymentTxn( + sender=context.accounts[0], + sp=context.acl.suggested_params_as_object(), + receiver=context.dev_pk, + amt=10_000_000, + ) + signed_payment = context.wallet.sign_transaction(payment) + context.acl.send_transaction(signed_payment) + + # Send a zero payment transaction def send_zero_transactions(context, txns=1): + if not hasattr(context, "dev_pk"): + initialize_dev_mode_account(context) for _ in range(txns): payment = transaction.PaymentTxn( - sender=context.accounts[0], + sender=context.dev_pk, sp=context.acl.suggested_params_as_object(), receiver=constants.ZERO_ADDRESS, amt=random.randint(100000, 900000), ) - signed_payment = context.wallet.sign_transaction(payment) + # signed_payment = context.wallet.sign_transaction(payment) + # context.sk = context.wallet.export_key(context.accounts[0]) + signed_payment = payment.sign(context.dev_sk) context.acl.send_transaction(signed_payment) @@ -364,6 +381,10 @@ def default_txn(context, amt, note): ) context.pk = context.accounts[0] + # Initialize dev mode accounts + if not hasattr(context, "dev_pk"): + initialize_dev_mode_account(context) + @given('default multisig transaction with parameters {amt} "{note}"') def default_msig_txn(context, amt, note): From d6993ad38f3c3df5e40a8372b74e4f03bb0605fa Mon Sep 17 00:00:00 2001 From: algochoi <86622919+algochoi@users.noreply.github.com> Date: Thu, 21 Jul 2022 09:21:33 -0400 Subject: [PATCH 23/36] Refactor some names and delete extra unused lines --- tests/steps/application_v2_steps.py | 6 ++++-- tests/steps/other_v2_steps.py | 6 +++--- tests/steps/steps.py | 21 ++++++++------------- 3 files changed, 15 insertions(+), 18 deletions(-) diff --git a/tests/steps/application_v2_steps.py b/tests/steps/application_v2_steps.py index 15158693..12dc2710 100644 --- a/tests/steps/application_v2_steps.py +++ b/tests/steps/application_v2_steps.py @@ -15,7 +15,7 @@ from tests.steps.other_v2_steps import ( dev_mode_wait_for_confirmation, read_program, - send_zero_transactions, + burn_algo_transactions, ) @@ -408,7 +408,9 @@ def remember_app_id(context): def wait_for_app_txn_confirm(context): sp = context.app_acl.suggested_params() last_round = sp.first - send_zero_transactions(context, 3) + # Send some transactions to advance block state in dev mode so we can + # check the status after block `last_round + 2`. + burn_algo_transactions(context, 3) context.app_acl.status_after_block(last_round + 2) if hasattr(context, "acl"): assert "type" in context.acl.transaction_info( diff --git a/tests/steps/other_v2_steps.py b/tests/steps/other_v2_steps.py index a804b052..ea604744 100644 --- a/tests/steps/other_v2_steps.py +++ b/tests/steps/other_v2_steps.py @@ -99,9 +99,9 @@ def read_program(context, path): # Send transactions to progress block numbers on dev mode. -def send_zero_transactions(context, txns=1): +def burn_algo_transactions(context, num_txns=1): sp = context.app_acl.suggested_params() - for _ in range(txns): + for _ in range(num_txns): payment = transaction.PaymentTxn( context.accounts[0], sp, @@ -119,7 +119,7 @@ def send_zero_transactions(context, txns=1): # To prevent excess waiting, send a zero payment transaction before # the wait_for_confirmation function in dev mode. def dev_mode_wait_for_confirmation(context, txid, rounds): - send_zero_transactions(context) + burn_algo_transactions(context) transaction.wait_for_confirmation(context.app_acl, txid, rounds) diff --git a/tests/steps/steps.py b/tests/steps/steps.py index 53758c55..122f4441 100644 --- a/tests/steps/steps.py +++ b/tests/steps/steps.py @@ -38,18 +38,16 @@ def initialize_dev_mode_account(context): # Send a zero payment transaction -def send_zero_transactions(context, txns=1): +def burn_algo_transactions(context, num_txns=1): if not hasattr(context, "dev_pk"): initialize_dev_mode_account(context) - for _ in range(txns): + for _ in range(num_txns): payment = transaction.PaymentTxn( sender=context.dev_pk, sp=context.acl.suggested_params_as_object(), receiver=constants.ZERO_ADDRESS, amt=random.randint(100000, 900000), ) - # signed_payment = context.wallet.sign_transaction(payment) - # context.sk = context.wallet.export_key(context.accounts[0]) signed_payment = payment.sign(context.dev_sk) context.acl.send_transaction(signed_payment) @@ -256,7 +254,7 @@ def status(context): @when("I get status after this block") def status_block(context): - send_zero_transactions(context) + burn_algo_transactions(context) context.status_after = context.acl.status_after_block( context.status["lastRound"] ) @@ -264,7 +262,7 @@ def status_block(context): @then("I can get the block info") def block(context): - send_zero_transactions(context) + burn_algo_transactions(context) context.block = context.acl.block_info(context.status["lastRound"] + 1) @@ -353,7 +351,7 @@ def algod_client(context): algod_address = "http://localhost:" + str(algod_port) context.acl = algod.AlgodClient(token, algod_address) if context.acl.status()["lastRound"] < 2: - send_zero_transactions(context, 2) + burn_algo_transactions(context, 2) context.acl.status_after_block(2) @@ -442,21 +440,18 @@ def send_msig_txn(context): @then("the transaction should go through") def check_txn(context): - send_zero_transactions(context) - # last_round = context.acl.status()["lastRound"] + burn_algo_transactions(context) assert "type" in context.acl.pending_transaction_info( context.txn.get_txid() ) - # context.acl.status_after_block(last_round + 2) assert "type" in context.acl.transaction_info( context.txn.sender, context.txn.get_txid() ) - # assert "type" in context.acl.transaction_by_id(context.txn.get_txid()) @then("I can get the transaction by ID") def get_txn_by_id(context): - send_zero_transactions(context, 3) + burn_algo_transactions(context, 3) context.acl.status_after_block(context.last_round + 2) assert "type" in context.acl.transaction_by_id(context.txn.get_txid()) @@ -533,7 +528,7 @@ def check_save_txn(context): stx = transaction.retrieve_from_file(dir_path + "/temp/txn.tx")[0] txid = stx.transaction.get_txid() last_round = context.acl.status()["lastRound"] - send_zero_transactions(context, 3) + burn_algo_transactions(context, 3) context.acl.status_after_block(last_round + 2) assert context.acl.transaction_info(stx.transaction.sender, txid) From db8ac368a60a583adb24d8d7289c05847f6b3c88 Mon Sep 17 00:00:00 2001 From: algochoi <86622919+algochoi@users.noreply.github.com> Date: Thu, 21 Jul 2022 13:52:32 -0400 Subject: [PATCH 24/36] Add some comments, refactor some variables, and change wait rounds to 1 in dev mode --- tests/steps/other_v2_steps.py | 5 +++-- tests/steps/steps.py | 10 +++++----- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/tests/steps/other_v2_steps.py b/tests/steps/other_v2_steps.py index ea604744..d8b1a10e 100644 --- a/tests/steps/other_v2_steps.py +++ b/tests/steps/other_v2_steps.py @@ -111,14 +111,15 @@ def burn_algo_transactions(context, num_txns=1): signed_payment = context.wallet.sign_transaction(payment) context.app_acl.send_transaction(signed_payment) # Wait and confirm that the zero payment succeeded. + # In dev mode, the transaction should be instantly confirmed in the block. transaction.wait_for_confirmation( - context.app_acl, payment.get_txid(), 5 + context.app_acl, payment.get_txid(), 1 ) # To prevent excess waiting, send a zero payment transaction before # the wait_for_confirmation function in dev mode. -def dev_mode_wait_for_confirmation(context, txid, rounds): +def dev_mode_wait_for_confirmation(context, txid, rounds=1): burn_algo_transactions(context) transaction.wait_for_confirmation(context.app_acl, txid, rounds) diff --git a/tests/steps/steps.py b/tests/steps/steps.py index 122f4441..7ddbee52 100644 --- a/tests/steps/steps.py +++ b/tests/steps/steps.py @@ -23,21 +23,21 @@ algod_port = 60000 kmd_port = 60001 - -# Initialize dev mode accounts. +DEV_ACCOUNT_INITIAL_MICROALGOS: int = 100_000_000 +# Initialize a transient account in dev mode to make payment transactions. def initialize_dev_mode_account(context): context.dev_sk, context.dev_pk = account.generate_account() payment = transaction.PaymentTxn( sender=context.accounts[0], sp=context.acl.suggested_params_as_object(), receiver=context.dev_pk, - amt=10_000_000, + amt=DEV_ACCOUNT_INITIAL_MICROALGOS, ) signed_payment = context.wallet.sign_transaction(payment) context.acl.send_transaction(signed_payment) -# Send a zero payment transaction +# Send a payment transaction to itself to advance blocks in dev mode. def burn_algo_transactions(context, num_txns=1): if not hasattr(context, "dev_pk"): initialize_dev_mode_account(context) @@ -45,7 +45,7 @@ def burn_algo_transactions(context, num_txns=1): payment = transaction.PaymentTxn( sender=context.dev_pk, sp=context.acl.suggested_params_as_object(), - receiver=constants.ZERO_ADDRESS, + receiver=context.dev_pk, amt=random.randint(100000, 900000), ) signed_payment = payment.sign(context.dev_sk) From 08d61a1dd9934eb341335be0d91d034000ab4dd2 Mon Sep 17 00:00:00 2001 From: algochoi <86622919+algochoi@users.noreply.github.com> Date: Tue, 26 Jul 2022 10:27:43 -0400 Subject: [PATCH 25/36] Add env variable to use dev mode network --- run_integration.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/run_integration.sh b/run_integration.sh index 3eef8827..82cbe5b3 100755 --- a/run_integration.sh +++ b/run_integration.sh @@ -9,6 +9,9 @@ pushd $rootdir rm -rf test-harness git clone --single-branch --branch devmodenet https://github.com/algorand/algorand-sdk-testing.git test-harness +# Export env variable so network is set to dev mode +export NETWORK_TEMPLATE="DevModeNetwork.json" + ## Copy feature files into the project resources mkdir -p tests/features cp -r test-harness/features/* tests/features From 227bee1db97fe9fd6b1896924ba79e6c7ff6c348 Mon Sep 17 00:00:00 2001 From: algochoi <86622919+algochoi@users.noreply.github.com> Date: Tue, 26 Jul 2022 15:54:35 -0400 Subject: [PATCH 26/36] Rekey in separate account --- tests/steps/steps.py | 35 +++++++++++++++++++++++------------ 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/tests/steps/steps.py b/tests/steps/steps.py index 7ddbee52..6c757008 100644 --- a/tests/steps/steps.py +++ b/tests/steps/steps.py @@ -25,12 +25,11 @@ DEV_ACCOUNT_INITIAL_MICROALGOS: int = 100_000_000 # Initialize a transient account in dev mode to make payment transactions. -def initialize_dev_mode_account(context): - context.dev_sk, context.dev_pk = account.generate_account() +def initialize_account(context, account): payment = transaction.PaymentTxn( sender=context.accounts[0], sp=context.acl.suggested_params_as_object(), - receiver=context.dev_pk, + receiver=account, amt=DEV_ACCOUNT_INITIAL_MICROALGOS, ) signed_payment = context.wallet.sign_transaction(payment) @@ -40,13 +39,14 @@ def initialize_dev_mode_account(context): # Send a payment transaction to itself to advance blocks in dev mode. def burn_algo_transactions(context, num_txns=1): if not hasattr(context, "dev_pk"): - initialize_dev_mode_account(context) + context.dev_sk, context.dev_pk = account.generate_account() + initialize_account(context, context.dev_pk) for _ in range(num_txns): payment = transaction.PaymentTxn( sender=context.dev_pk, sp=context.acl.suggested_params_as_object(), receiver=context.dev_pk, - amt=random.randint(100000, 900000), + amt=random.randint(1, 100_000), ) signed_payment = payment.sign(context.dev_sk) context.acl.send_transaction(signed_payment) @@ -305,6 +305,12 @@ def gen_key_kmd(context): context.pk = context.wallet.generate_key() +@when("I generate a key using kmd for rekeying") +def gen_rekey_kmd(context): + context.rekey = context.wallet.generate_key() + initialize_account(context, context.rekey) + + @then("the key should be in the wallet") def key_in_wallet(context): keys = context.wallet.list_keys() @@ -366,8 +372,7 @@ def wallet_info(context): context.accounts = context.wallet.list_keys() -@given('default transaction with parameters {amt} "{note}"') -def default_txn(context, amt, note): +def default_txn_with_addr(context, amt, note, sender_addr): params = context.acl.suggested_params_as_object() context.last_round = params.first if note == "none": @@ -375,13 +380,19 @@ def default_txn(context, amt, note): else: note = base64.b64decode(note) context.txn = transaction.PaymentTxn( - context.accounts[0], params, context.accounts[1], int(amt), note=note + sender_addr, params, context.accounts[1], int(amt), note=note ) - context.pk = context.accounts[0] + context.pk = sender_addr - # Initialize dev mode accounts - if not hasattr(context, "dev_pk"): - initialize_dev_mode_account(context) + +@given('default transaction with parameters {amt} "{note}"') +def default_txn(context, amt, note): + default_txn_with_addr(context, amt, note, context.accounts[0]) + + +@given("default transaction with parameters {amt} {note} and rekeying key") +def default_txn_rekey(context, amt, note): + default_txn_with_addr(context, amt, note, context.rekey) @given('default multisig transaction with parameters {amt} "{note}"') From 0b9c6f17fa48a84e75ac45059bd90470e3db9a52 Mon Sep 17 00:00:00 2001 From: algochoi <86622919+algochoi@users.noreply.github.com> Date: Wed, 27 Jul 2022 09:09:03 -0400 Subject: [PATCH 27/36] Fix amounts to proportional amount and rename burn txns --- tests/steps/application_v2_steps.py | 4 ++-- tests/steps/other_v2_steps.py | 12 ++++++------ tests/steps/steps.py | 21 ++++++++++----------- 3 files changed, 18 insertions(+), 19 deletions(-) diff --git a/tests/steps/application_v2_steps.py b/tests/steps/application_v2_steps.py index 12dc2710..21740521 100644 --- a/tests/steps/application_v2_steps.py +++ b/tests/steps/application_v2_steps.py @@ -15,7 +15,7 @@ from tests.steps.other_v2_steps import ( dev_mode_wait_for_confirmation, read_program, - burn_algo_transactions, + self_pay_transactions, ) @@ -410,7 +410,7 @@ def wait_for_app_txn_confirm(context): last_round = sp.first # Send some transactions to advance block state in dev mode so we can # check the status after block `last_round + 2`. - burn_algo_transactions(context, 3) + self_pay_transactions(context, 3) context.app_acl.status_after_block(last_round + 2) if hasattr(context, "acl"): assert "type" in context.acl.transaction_info( diff --git a/tests/steps/other_v2_steps.py b/tests/steps/other_v2_steps.py index d8b1a10e..6f7e7acf 100644 --- a/tests/steps/other_v2_steps.py +++ b/tests/steps/other_v2_steps.py @@ -10,7 +10,7 @@ import parse from algosdk import ( - constants, + account, dryrun_results, encoding, error, @@ -98,15 +98,15 @@ def read_program(context, path): return read_program_binary(path) -# Send transactions to progress block numbers on dev mode. -def burn_algo_transactions(context, num_txns=1): +# Send a self-payment transaction to itself to advance blocks in dev mode. +def self_pay_transactions(context, num_txns=1): sp = context.app_acl.suggested_params() for _ in range(num_txns): payment = transaction.PaymentTxn( context.accounts[0], sp, - constants.ZERO_ADDRESS, - random.randint(100000, 900000), + context.accounts[0], + random.randint(1, 100_000), ) signed_payment = context.wallet.sign_transaction(payment) context.app_acl.send_transaction(signed_payment) @@ -120,7 +120,7 @@ def burn_algo_transactions(context, num_txns=1): # To prevent excess waiting, send a zero payment transaction before # the wait_for_confirmation function in dev mode. def dev_mode_wait_for_confirmation(context, txid, rounds=1): - burn_algo_transactions(context) + self_pay_transactions(context) transaction.wait_for_confirmation(context.app_acl, txid, rounds) diff --git a/tests/steps/steps.py b/tests/steps/steps.py index 6c757008..07d7bad7 100644 --- a/tests/steps/steps.py +++ b/tests/steps/steps.py @@ -7,7 +7,6 @@ account, algod, auction, - constants, encoding, kmd, logic, @@ -36,8 +35,8 @@ def initialize_account(context, account): context.acl.send_transaction(signed_payment) -# Send a payment transaction to itself to advance blocks in dev mode. -def burn_algo_transactions(context, num_txns=1): +# Send a self-payment transaction to itself to advance blocks in dev mode. +def self_pay_transactions(context, num_txns=1): if not hasattr(context, "dev_pk"): context.dev_sk, context.dev_pk = account.generate_account() initialize_account(context, context.dev_pk) @@ -46,7 +45,7 @@ def burn_algo_transactions(context, num_txns=1): sender=context.dev_pk, sp=context.acl.suggested_params_as_object(), receiver=context.dev_pk, - amt=random.randint(1, 100_000), + amt=random.randint(1, int(DEV_ACCOUNT_INITIAL_MICROALGOS * 0.01)), ) signed_payment = payment.sign(context.dev_sk) context.acl.send_transaction(signed_payment) @@ -254,7 +253,7 @@ def status(context): @when("I get status after this block") def status_block(context): - burn_algo_transactions(context) + self_pay_transactions(context) context.status_after = context.acl.status_after_block( context.status["lastRound"] ) @@ -262,7 +261,7 @@ def status_block(context): @then("I can get the block info") def block(context): - burn_algo_transactions(context) + self_pay_transactions(context) context.block = context.acl.block_info(context.status["lastRound"] + 1) @@ -357,7 +356,7 @@ def algod_client(context): algod_address = "http://localhost:" + str(algod_port) context.acl = algod.AlgodClient(token, algod_address) if context.acl.status()["lastRound"] < 2: - burn_algo_transactions(context, 2) + self_pay_transactions(context, 2) context.acl.status_after_block(2) @@ -390,7 +389,7 @@ def default_txn(context, amt, note): default_txn_with_addr(context, amt, note, context.accounts[0]) -@given("default transaction with parameters {amt} {note} and rekeying key") +@given('default transaction with parameters {amt} "{note}" and rekeying key') def default_txn_rekey(context, amt, note): default_txn_with_addr(context, amt, note, context.rekey) @@ -451,7 +450,7 @@ def send_msig_txn(context): @then("the transaction should go through") def check_txn(context): - burn_algo_transactions(context) + self_pay_transactions(context) assert "type" in context.acl.pending_transaction_info( context.txn.get_txid() ) @@ -462,7 +461,7 @@ def check_txn(context): @then("I can get the transaction by ID") def get_txn_by_id(context): - burn_algo_transactions(context, 3) + self_pay_transactions(context, 3) context.acl.status_after_block(context.last_round + 2) assert "type" in context.acl.transaction_by_id(context.txn.get_txid()) @@ -539,7 +538,7 @@ def check_save_txn(context): stx = transaction.retrieve_from_file(dir_path + "/temp/txn.tx")[0] txid = stx.transaction.get_txid() last_round = context.acl.status()["lastRound"] - burn_algo_transactions(context, 3) + self_pay_transactions(context, 3) context.acl.status_after_block(last_round + 2) assert context.acl.transaction_info(stx.transaction.sender, txid) From 3f110572a023ddadaffd0988b02a48a16721c77c Mon Sep 17 00:00:00 2001 From: algochoi <86622919+algochoi@users.noreply.github.com> Date: Wed, 27 Jul 2022 09:37:51 -0400 Subject: [PATCH 28/36] Isolate dev account in v2 tests --- tests/steps/other_v2_steps.py | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/tests/steps/other_v2_steps.py b/tests/steps/other_v2_steps.py index 6f7e7acf..4f901d93 100644 --- a/tests/steps/other_v2_steps.py +++ b/tests/steps/other_v2_steps.py @@ -98,17 +98,33 @@ def read_program(context, path): return read_program_binary(path) +DEV_ACCOUNT_INITIAL_MICROALGOS: int = 100_000_000 +# Initialize a transient account in dev mode to make payment transactions. +def initialize_account(context, account): + payment = transaction.PaymentTxn( + sender=context.accounts[0], + sp=context.app_acl.suggested_params(), + receiver=account, + amt=DEV_ACCOUNT_INITIAL_MICROALGOS, + ) + signed_payment = context.wallet.sign_transaction(payment) + context.app_acl.send_transaction(signed_payment) + + # Send a self-payment transaction to itself to advance blocks in dev mode. def self_pay_transactions(context, num_txns=1): + if not hasattr(context, "dev_pk"): + context.dev_sk, context.dev_pk = account.generate_account() + initialize_account(context, context.dev_pk) sp = context.app_acl.suggested_params() for _ in range(num_txns): payment = transaction.PaymentTxn( - context.accounts[0], + context.dev_pk, sp, - context.accounts[0], - random.randint(1, 100_000), + context.dev_pk, + random.randint(1, int(DEV_ACCOUNT_INITIAL_MICROALGOS * 0.01)), ) - signed_payment = context.wallet.sign_transaction(payment) + signed_payment = payment.sign(context.dev_sk) context.app_acl.send_transaction(signed_payment) # Wait and confirm that the zero payment succeeded. # In dev mode, the transaction should be instantly confirmed in the block. From 03582d364c54eff8eb9357c06a19b58fffd3c8b7 Mon Sep 17 00:00:00 2001 From: algochoi <86622919+algochoi@users.noreply.github.com> Date: Wed, 27 Jul 2022 10:23:16 -0400 Subject: [PATCH 29/36] Lower initial dev mode algo limit to avoid overspending --- tests/steps/other_v2_steps.py | 6 ++++-- tests/steps/steps.py | 7 ++++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/tests/steps/other_v2_steps.py b/tests/steps/other_v2_steps.py index 4f901d93..fa716544 100644 --- a/tests/steps/other_v2_steps.py +++ b/tests/steps/other_v2_steps.py @@ -98,7 +98,7 @@ def read_program(context, path): return read_program_binary(path) -DEV_ACCOUNT_INITIAL_MICROALGOS: int = 100_000_000 +DEV_ACCOUNT_INITIAL_MICROALGOS: int = 10_000_000 # Initialize a transient account in dev mode to make payment transactions. def initialize_account(context, account): payment = transaction.PaymentTxn( @@ -109,6 +109,8 @@ def initialize_account(context, account): ) signed_payment = context.wallet.sign_transaction(payment) context.app_acl.send_transaction(signed_payment) + # Wait and confirm that the payment succeeded. + transaction.wait_for_confirmation(context.app_acl, payment.get_txid(), 1) # Send a self-payment transaction to itself to advance blocks in dev mode. @@ -126,7 +128,7 @@ def self_pay_transactions(context, num_txns=1): ) signed_payment = payment.sign(context.dev_sk) context.app_acl.send_transaction(signed_payment) - # Wait and confirm that the zero payment succeeded. + # Wait and confirm that the payment succeeded. # In dev mode, the transaction should be instantly confirmed in the block. transaction.wait_for_confirmation( context.app_acl, payment.get_txid(), 1 diff --git a/tests/steps/steps.py b/tests/steps/steps.py index 07d7bad7..d203173a 100644 --- a/tests/steps/steps.py +++ b/tests/steps/steps.py @@ -1,6 +1,7 @@ import base64 import os import random +import time from datetime import datetime from algosdk import ( @@ -22,7 +23,7 @@ algod_port = 60000 kmd_port = 60001 -DEV_ACCOUNT_INITIAL_MICROALGOS: int = 100_000_000 +DEV_ACCOUNT_INITIAL_MICROALGOS: int = 10_000_000 # Initialize a transient account in dev mode to make payment transactions. def initialize_account(context, account): payment = transaction.PaymentTxn( @@ -33,6 +34,8 @@ def initialize_account(context, account): ) signed_payment = context.wallet.sign_transaction(payment) context.acl.send_transaction(signed_payment) + # Wait to let transaction get confirmed in dev mode in v1. + time.sleep(0.1) # Send a self-payment transaction to itself to advance blocks in dev mode. @@ -49,6 +52,8 @@ def self_pay_transactions(context, num_txns=1): ) signed_payment = payment.sign(context.dev_sk) context.acl.send_transaction(signed_payment) + # Wait to let transaction get confirmed in dev mode in v1. + time.sleep(0.1) @when("I create a wallet") From 6fd5fd917bdc56eae9754114bcac4029a6e5882b Mon Sep 17 00:00:00 2001 From: Michael Diamant Date: Thu, 28 Jul 2022 13:08:15 -0400 Subject: [PATCH 30/36] Minimize use of transactions to advance rounds in #360 (#365) --- tests/steps/account_v2_steps.py | 6 ++-- tests/steps/application_v2_steps.py | 22 ++++++++------ tests/steps/other_v2_steps.py | 46 ----------------------------- tests/steps/steps.py | 2 +- 4 files changed, 17 insertions(+), 59 deletions(-) diff --git a/tests/steps/account_v2_steps.py b/tests/steps/account_v2_steps.py index 8290b32f..5778f4aa 100644 --- a/tests/steps/account_v2_steps.py +++ b/tests/steps/account_v2_steps.py @@ -3,7 +3,7 @@ from algosdk import account, constants, encoding, logic from algosdk.future import transaction from behave import given, then, when -from tests.steps.other_v2_steps import dev_mode_wait_for_confirmation +import tests.steps.other_v2_steps # Imports MaybeString def fund_account_address( @@ -18,7 +18,7 @@ def fund_account_address( ) signed_payment = context.wallet.sign_transaction(payment) context.app_acl.send_transaction(signed_payment) - dev_mode_wait_for_confirmation(context, payment.get_txid(), 10) + transaction.wait_for_confirmation(context.app_acl, payment.get_txid(), 1) @when( @@ -453,7 +453,7 @@ def create_transient_and_fund(context, transient_fund_amount): ) signed_payment = context.wallet.sign_transaction(payment) context.app_acl.send_transaction(signed_payment) - dev_mode_wait_for_confirmation(context, payment.get_txid(), 10) + transaction.wait_for_confirmation(context.app_acl, payment.get_txid(), 1) @then( diff --git a/tests/steps/application_v2_steps.py b/tests/steps/application_v2_steps.py index 21740521..e480ff1a 100644 --- a/tests/steps/application_v2_steps.py +++ b/tests/steps/application_v2_steps.py @@ -1,6 +1,7 @@ import base64 import json import re +import time import pytest from algosdk import abi, atomic_transaction_composer, encoding, mnemonic @@ -13,9 +14,7 @@ from algosdk.future import transaction from behave import given, step, then, when from tests.steps.other_v2_steps import ( - dev_mode_wait_for_confirmation, read_program, - self_pay_transactions, ) @@ -404,21 +403,26 @@ def remember_app_id(context): context.app_ids.append(app_id) +def wait_for_algod_transaction_processing_to_complete(): + """ + wait_for_algod_transaction_processing_to_complete is a Dev mode helper method that's a rough analog to `context.app_acl.status_after_block(last_round + 2)`. + *

+ * Since Dev mode produces blocks on a per transaction basis, it's possible algod generates a block _before_ the corresponding SDK call to wait for a block. Without _any_ wait, it's possible the SDK looks for the transaction before algod completes processing. So, the method performs a local sleep to simulate waiting for a block. + + """ + time.sleep(0.5) + + @step("I wait for the transaction to be confirmed.") def wait_for_app_txn_confirm(context): - sp = context.app_acl.suggested_params() - last_round = sp.first - # Send some transactions to advance block state in dev mode so we can - # check the status after block `last_round + 2`. - self_pay_transactions(context, 3) - context.app_acl.status_after_block(last_round + 2) + wait_for_algod_transaction_processing_to_complete() if hasattr(context, "acl"): assert "type" in context.acl.transaction_info( context.transient_pk, context.app_txid ) assert "type" in context.acl.transaction_by_id(context.app_txid) else: - dev_mode_wait_for_confirmation(context, context.app_txid, 10) + transaction.wait_for_confirmation(context.app_acl, context.app_txid, 1) @given("an application id {app_id}") diff --git a/tests/steps/other_v2_steps.py b/tests/steps/other_v2_steps.py index fa716544..a5367755 100644 --- a/tests/steps/other_v2_steps.py +++ b/tests/steps/other_v2_steps.py @@ -1,7 +1,6 @@ import base64 import json import os -import random import unittest import urllib from datetime import datetime @@ -10,7 +9,6 @@ import parse from algosdk import ( - account, dryrun_results, encoding, error, @@ -98,50 +96,6 @@ def read_program(context, path): return read_program_binary(path) -DEV_ACCOUNT_INITIAL_MICROALGOS: int = 10_000_000 -# Initialize a transient account in dev mode to make payment transactions. -def initialize_account(context, account): - payment = transaction.PaymentTxn( - sender=context.accounts[0], - sp=context.app_acl.suggested_params(), - receiver=account, - amt=DEV_ACCOUNT_INITIAL_MICROALGOS, - ) - signed_payment = context.wallet.sign_transaction(payment) - context.app_acl.send_transaction(signed_payment) - # Wait and confirm that the payment succeeded. - transaction.wait_for_confirmation(context.app_acl, payment.get_txid(), 1) - - -# Send a self-payment transaction to itself to advance blocks in dev mode. -def self_pay_transactions(context, num_txns=1): - if not hasattr(context, "dev_pk"): - context.dev_sk, context.dev_pk = account.generate_account() - initialize_account(context, context.dev_pk) - sp = context.app_acl.suggested_params() - for _ in range(num_txns): - payment = transaction.PaymentTxn( - context.dev_pk, - sp, - context.dev_pk, - random.randint(1, int(DEV_ACCOUNT_INITIAL_MICROALGOS * 0.01)), - ) - signed_payment = payment.sign(context.dev_sk) - context.app_acl.send_transaction(signed_payment) - # Wait and confirm that the payment succeeded. - # In dev mode, the transaction should be instantly confirmed in the block. - transaction.wait_for_confirmation( - context.app_acl, payment.get_txid(), 1 - ) - - -# To prevent excess waiting, send a zero payment transaction before -# the wait_for_confirmation function in dev mode. -def dev_mode_wait_for_confirmation(context, txid, rounds=1): - self_pay_transactions(context) - transaction.wait_for_confirmation(context.app_acl, txid, rounds) - - @given("mock server recording request paths") def setup_mockserver(context): context.url = "http://127.0.0.1:" + str(context.path_server_port) diff --git a/tests/steps/steps.py b/tests/steps/steps.py index d203173a..87391643 100644 --- a/tests/steps/steps.py +++ b/tests/steps/steps.py @@ -309,7 +309,7 @@ def gen_key_kmd(context): context.pk = context.wallet.generate_key() -@when("I generate a key using kmd for rekeying") +@when("I generate a key using kmd for rekeying and fund it") def gen_rekey_kmd(context): context.rekey = context.wallet.generate_key() initialize_account(context, context.rekey) From e444168b845b3b63540bb9bb1889a6f482fe3c00 Mon Sep 17 00:00:00 2001 From: algochoi <86622919+algochoi@users.noreply.github.com> Date: Thu, 28 Jul 2022 14:16:57 -0400 Subject: [PATCH 31/36] Wait for blocks using sleep instead of relying on status_after v1 api --- tests/steps/steps.py | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/tests/steps/steps.py b/tests/steps/steps.py index 87391643..84fbceeb 100644 --- a/tests/steps/steps.py +++ b/tests/steps/steps.py @@ -24,6 +24,17 @@ kmd_port = 60001 DEV_ACCOUNT_INITIAL_MICROALGOS: int = 10_000_000 + +def wait_for_algod_transaction_processing_to_complete(): + """ + wait_for_algod_transaction_processing_to_complete is a Dev mode helper method that's a rough analog to `context.app_acl.status_after_block(last_round + 2)`. + *

+ * Since Dev mode produces blocks on a per transaction basis, it's possible algod generates a block _before_ the corresponding SDK call to wait for a block. + * Without _any_ wait, it's possible the SDK looks for the transaction before algod completes processing. + * So, the method performs a local sleep to simulate waiting for a block. + """ + time.sleep(0.5) + # Initialize a transient account in dev mode to make payment transactions. def initialize_account(context, account): payment = transaction.PaymentTxn( @@ -35,7 +46,7 @@ def initialize_account(context, account): signed_payment = context.wallet.sign_transaction(payment) context.acl.send_transaction(signed_payment) # Wait to let transaction get confirmed in dev mode in v1. - time.sleep(0.1) + wait_for_algod_transaction_processing_to_complete() # Send a self-payment transaction to itself to advance blocks in dev mode. @@ -53,7 +64,7 @@ def self_pay_transactions(context, num_txns=1): signed_payment = payment.sign(context.dev_sk) context.acl.send_transaction(signed_payment) # Wait to let transaction get confirmed in dev mode in v1. - time.sleep(0.1) + wait_for_algod_transaction_processing_to_complete() @when("I create a wallet") @@ -455,7 +466,7 @@ def send_msig_txn(context): @then("the transaction should go through") def check_txn(context): - self_pay_transactions(context) + wait_for_algod_transaction_processing_to_complete() assert "type" in context.acl.pending_transaction_info( context.txn.get_txid() ) @@ -466,8 +477,7 @@ def check_txn(context): @then("I can get the transaction by ID") def get_txn_by_id(context): - self_pay_transactions(context, 3) - context.acl.status_after_block(context.last_round + 2) + wait_for_algod_transaction_processing_to_complete() assert "type" in context.acl.transaction_by_id(context.txn.get_txid()) @@ -542,9 +552,7 @@ def check_save_txn(context): dir_path = os.path.dirname(os.path.dirname(dir_path)) stx = transaction.retrieve_from_file(dir_path + "/temp/txn.tx")[0] txid = stx.transaction.get_txid() - last_round = context.acl.status()["lastRound"] - self_pay_transactions(context, 3) - context.acl.status_after_block(last_round + 2) + wait_for_algod_transaction_processing_to_complete() assert context.acl.transaction_info(stx.transaction.sender, txid) From f37d01808fb957e78b7d4d44f9acdafbc6d78f2c Mon Sep 17 00:00:00 2001 From: algochoi <86622919+algochoi@users.noreply.github.com> Date: Thu, 28 Jul 2022 14:23:28 -0400 Subject: [PATCH 32/36] Lets do some formatting --- tests/steps/steps.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/steps/steps.py b/tests/steps/steps.py index 84fbceeb..b9095184 100644 --- a/tests/steps/steps.py +++ b/tests/steps/steps.py @@ -25,16 +25,18 @@ DEV_ACCOUNT_INITIAL_MICROALGOS: int = 10_000_000 + def wait_for_algod_transaction_processing_to_complete(): """ wait_for_algod_transaction_processing_to_complete is a Dev mode helper method that's a rough analog to `context.app_acl.status_after_block(last_round + 2)`. *

- * Since Dev mode produces blocks on a per transaction basis, it's possible algod generates a block _before_ the corresponding SDK call to wait for a block. - * Without _any_ wait, it's possible the SDK looks for the transaction before algod completes processing. + * Since Dev mode produces blocks on a per transaction basis, it's possible algod generates a block _before_ the corresponding SDK call to wait for a block. + * Without _any_ wait, it's possible the SDK looks for the transaction before algod completes processing. * So, the method performs a local sleep to simulate waiting for a block. """ time.sleep(0.5) + # Initialize a transient account in dev mode to make payment transactions. def initialize_account(context, account): payment = transaction.PaymentTxn( From 7b8e0cab752bb9407c5bd9e7dda0ef8657a40c14 Mon Sep 17 00:00:00 2001 From: algochoi <86622919+algochoi@users.noreply.github.com> Date: Thu, 28 Jul 2022 15:01:40 -0400 Subject: [PATCH 33/36] Bring back transaction check in v1 step --- tests/steps/steps.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/steps/steps.py b/tests/steps/steps.py index b9095184..59102280 100644 --- a/tests/steps/steps.py +++ b/tests/steps/steps.py @@ -475,6 +475,7 @@ def check_txn(context): assert "type" in context.acl.transaction_info( context.txn.sender, context.txn.get_txid() ) + assert "type" in context.acl.transaction_by_id(context.txn.get_txid()) @then("I can get the transaction by ID") From 748084cf09b738fb0dc6e3379447f98eb0de3696 Mon Sep 17 00:00:00 2001 From: algochoi <86622919+algochoi@users.noreply.github.com> Date: Fri, 29 Jul 2022 13:03:56 -0400 Subject: [PATCH 34/36] Revert setting network in run_integration script --- run_integration.sh | 3 --- 1 file changed, 3 deletions(-) diff --git a/run_integration.sh b/run_integration.sh index 82cbe5b3..3eef8827 100755 --- a/run_integration.sh +++ b/run_integration.sh @@ -9,9 +9,6 @@ pushd $rootdir rm -rf test-harness git clone --single-branch --branch devmodenet https://github.com/algorand/algorand-sdk-testing.git test-harness -# Export env variable so network is set to dev mode -export NETWORK_TEMPLATE="DevModeNetwork.json" - ## Copy feature files into the project resources mkdir -p tests/features cp -r test-harness/features/* tests/features From 44c16624f951a8c981e572181759c47a3d3ebc38 Mon Sep 17 00:00:00 2001 From: algochoi <86622919+algochoi@users.noreply.github.com> Date: Mon, 1 Aug 2022 15:41:07 -0400 Subject: [PATCH 35/36] Rename rekeying integ test --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index ebb44f15..ba7b6363 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ UNITS = "@unit.abijson or @unit.abijson.byname or @unit.algod or @unit.algod.led 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 or @compile.sourcemap" +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_v1 or @send.keyregtxn or @send or @compile.sourcemap" integration: behave --tags=$(INTEGRATIONS) tests -f progress2 From 485fdb4b30d3e736ab92e246e240e368057c4050 Mon Sep 17 00:00:00 2001 From: algochoi <86622919+algochoi@users.noreply.github.com> Date: Mon, 1 Aug 2022 16:47:55 -0400 Subject: [PATCH 36/36] Revert branch back to master --- run_integration.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/run_integration.sh b/run_integration.sh index 3eef8827..8e680e34 100755 --- a/run_integration.sh +++ b/run_integration.sh @@ -7,7 +7,7 @@ pushd $rootdir # Reset test harness rm -rf test-harness -git clone --single-branch --branch devmodenet https://github.com/algorand/algorand-sdk-testing.git test-harness +git clone --single-branch --branch master https://github.com/algorand/algorand-sdk-testing.git test-harness ## Copy feature files into the project resources mkdir -p tests/features