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 scenario for simulate with populate-resources #319

Draft
wants to merge 7 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ TYPE="source" # OR "channel"
ALGOD_CHANNEL="nightly"

# Used when TYPE==source:
ALGOD_URL="https://github.com/algorand/go-algorand"
ALGOD_BRANCH="master"
ALGOD_URL="https://github.com/joe-p/go-algorand"
ALGOD_BRANCH="feat/populate_resources"
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO: remove this before merging

ALGOD_SHA=""

# Used regardless of TYPE:
Expand Down
31 changes: 28 additions & 3 deletions features/integration/simulate.feature
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ Feature: Simulating transactions

@simulate.exec_trace_with_stack_scratch
Scenario: Simulate app with response containing stack and scratch changes
Given a new AtomicTransactionComposer
Given a new AtomicTransactionComposer
When I build an application transaction with the transient account, the current application, suggested params, operation "create", approval-program "programs/stack-scratch.teal", clear-program "programs/eight.teal", global-bytes 0, global-ints 0, local-bytes 0, local-ints 0, app-args "", foreign-apps "", foreign-assets "", app-accounts "", extra-pages 0, boxes ""
And I sign and submit the transaction, saving the txid. If there is an error it is "".
And I wait for the transaction to be confirmed.
Expand Down Expand Up @@ -232,14 +232,14 @@ Feature: Simulating transactions

# Submit the group to the actual network
Then I execute the current transaction group with the composer.

# Simulate again so we can check the reported initial state.
Given a new AtomicTransactionComposer
When I make a new simulate request.
And I create the Method object from method signature "<method>"
And I create a new method arguments array.
And I add a method call with the transient account, the current application, suggested params, on complete "noop", current transaction signer, current method arguments, boxes "0,str:box-key-1,0,str:box-key-2,0,str:nonce-box".

Then I allow exec trace options "state" on that simulate request.
And I simulate the transaction group with the simulate request.
And the simulation should succeed without any failure message
Expand All @@ -252,3 +252,28 @@ Feature: Simulating transactions
| global()void | global | 14 | global-int-key | uint64:3735928559 | 17 | global-bytes-key | bytes:d2VsdCBhbSBkcmFodA== |
| local()void | local | 15 | local-int-key | uint64:3405689018 | 19 | local-bytes-key | bytes:eHFjTA== |
| box()void | box | 14 | box-key-1 | bytes:Ym94LXZhbHVlLTE= | 17 | box-key-2 | bytes: |

@simulate.populate_resources
Scenario: Simulate with populate-resources set to true returns populated resource arrays for transactions and group
# Create app
Given a new AtomicTransactionComposer
When I build an application transaction with the transient account, the current application, suggested params, operation "create", approval-program "programs/resources.teal", clear-program "programs/resources.teal", global-bytes 0, global-ints 0, local-bytes 0, local-ints 0, app-args "", foreign-apps "", foreign-assets "", app-accounts "", extra-pages 0, boxes ""
And I sign and submit the transaction, saving the txid. If there is an error it is "".
And I wait for the transaction to be confirmed.
Given I remember the new application ID.
And I fund the current application's address with 1000000 microalgos.

# Call with simulate
Given a new AtomicTransactionComposer
# The program doesn't actually route method selectors, but we want to reuse these steps
And I create the Method object from method signature "call()void"
And I create a new method arguments array.
And I add a method call with the transient account, the current application, suggested params, on complete "noop", current transaction signer, current method arguments.
When I make a new simulate request.
And I set unnamed-resources "true"
And I set populate-resources "true"
Then I simulate the transaction group with the simulate request.
And the simulation should succeed without any failure message
And the response should include populated-resource-arrays for the transaction
And the response should include extra-resource-arrays for the group

30 changes: 30 additions & 0 deletions features/resources/programs/resources.teal
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#pragma version 11
txn ApplicationID
bz end

// 1 box ref here and 1 empty ref later
byte "box_key"; int 1024; int 2; *; box_create

// 4 accounts to max this txns limit
addr AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAY5HFKQ; acct_params_get AcctBalance
addr AEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAKE3PRHE; acct_params_get AcctBalance
addr AIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAGFFWAF4; acct_params_get AcctBalance
addr AMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAANVWEXNA; acct_params_get AcctBalance

// 3 apps to hit this txns reference limit and force references in ExtraResourceArrays
int 10000; app_params_get AppCreator
int 20000; app_params_get AppCreator
int 30000; app_params_get AppCreator

// App in ExtraResourceArrays
int 40000; app_params_get AppCreator

// Account in ExtraResourceArrays
addr AQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAJVBPJXY; acct_params_get AcctBalance

// Asset in ExtraResourceArrays
int 10001; asset_params_get AssetTotal

end:
int 1; return