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 3 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
27 changes: 24 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,24 @@ 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
When I add a app call with the transient account, the current application, suggested params, on complete "noop", current transaction signer
And I make a new simulate request
And I set populate-resources "true"
And I simulate the transaction group with the transaction request
Then 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

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

// Box ref
byte "boxkey1"; int 1; box_create

// Account ref
addr DEPBW254YVMYJ5CCVQGGD4OFGRRCORIUPGC42QP6SQRE3UQNH23HI23OJA; acct_params_get AcctBalance

// Asset ref
int 100000; asset_params_get AssetTotal

// App ref
int 200000; app_params_get AppCreator

// Fill rest of this txn's references
byte "boxkey2"; int 1; box_create
byte "boxkey3"; int 1; box_create
byte "boxkey4"; int 1; box_create
byte "boxkey5"; int 1; box_create

// Now for extra resources

// Box ref
byte "boxkey6"; int 1; box_create

// Account ref
addr FLKXHGZRZUQEFB34LFGHKIEBE6YJ7VEFLQ5VH7PCANR4PFPGJKCIBMGDXM; acct_params_get AcctBalance

// Asset ref
int 300000; asset_params_get AssetTotal

// App ref
int 400000; app_params_get AppCreator

end:
int 1
return