-
Notifications
You must be signed in to change notification settings - Fork 146
Testing: Modify cucumber steps to use dev mode network #360
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 25 commits
23cd772
d951d75
b4bba52
a30a72f
4959a47
1427eff
8cb4e89
3db1248
93e56c8
d62894d
c20a0e8
884473f
26772d0
f7d13e4
a0135b3
7ad3bf7
70c034b
1fc2047
7fa997b
f564238
49a8409
ac3ef79
c90aa85
8f252be
d6993ad
db8ac36
08d61a1
227bee1
0b9c6f1
3f11057
03582d3
6fd5fd9
e444168
f37d018
7b8e0ca
748084c
44c1662
485fdb4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,36 +1,37 @@ | ||
| import base64 | ||
| import json | ||
| import os | ||
| import urllib | ||
| import random | ||
| import unittest | ||
| import urllib | ||
| from datetime import datetime | ||
| from pathlib import Path | ||
| from urllib.request import Request, urlopen | ||
|
|
||
| from behave import ( | ||
| given, | ||
| when, | ||
| then, | ||
| register_type, | ||
| step, | ||
| ) # pylint: disable=no-name-in-module | ||
|
|
||
| from glom import glom | ||
| import parse | ||
|
|
||
| from algosdk import dryrun_results, encoding, error, mnemonic, source_map | ||
| from algosdk import ( | ||
| constants, | ||
| dryrun_results, | ||
| encoding, | ||
| error, | ||
| mnemonic, | ||
| source_map, | ||
| ) | ||
| 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 register_type # pylint: disable=no-name-in-module | ||
| from behave import given, 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".*") | ||
|
|
@@ -97,6 +98,31 @@ 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): | ||
| 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), | ||
|
tzaffi marked this conversation as resolved.
Outdated
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @algochoi Optionally, I propose configuring the upper bound proportional to the funding amount. Intent is to avoid generating a value that's too large if/when the funding amount changes. Here's the Java SDK analog: algorand/java-algorand-sdk@3390a6d. Feel welcomed to resolve as is.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good point - Added proportional funding amounts in latest commit 3f11057 |
||
| ) | ||
| 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( | ||
|
tzaffi marked this conversation as resolved.
Outdated
|
||
| context.app_acl, payment.get_txid(), 5 | ||
| ) | ||
|
|
||
|
|
||
| # 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): | ||
|
tzaffi marked this conversation as resolved.
Outdated
|
||
| burn_algo_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) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Related SDK Testing PR: algorand/algorand-sdk-testing#206