Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for global_state in dryruns #54

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

iglosiggio
Copy link

These changes add a global_state field to DryRunTransactionPrams.

Example code showing a possible usage:

from graviton.blackbox import DryRunExecutor, ExecutionMode, DryRunTransactionParams
from tests.clients import get_algod
teal = """
#pragma version 8
byte "value"
app_global_get
btoi
return
"""
algod = get_algod()
executor = DryRunExecutor(algod, ExecutionMode.Application, teal)
txn_params = DryRunTransactionParams.for_app(global_state={"value": b"\xff"})
run = executor.run_one((), txn_params=txn_params)
print(run.tabulate(500))
print("Cost:", run.cost())

Output:

   step |   PC# |   L# | Teal                              | Scratch   | Stack
--------+-------+------+-----------------------------------+-----------+----------------
      1 |     1 |    1 | #pragma version 8                 |           | []
      2 |     8 |    2 | pushbytes 0x76616c7565 // "value" |           | [0x76616c7565]
      3 |     9 |    3 | app_global_get                    |           | [0xff]
      4 |    10 |    4 | btoi                              |           | [255]
      5 |    11 |    5 | return                            |           | [255]
Cost: 4

@CLAassistant
Copy link

CLAassistant commented Mar 23, 2023

CLA assistant check
All committers have signed the CLA.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants