-
Notifications
You must be signed in to change notification settings - Fork 35
/
abi.feature
240 lines (220 loc) · 16.9 KB
/
abi.feature
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
@abi
Feature: ABI Interaction
Background:
Given an algod v2 client
And a kmd client
And wallet information
And suggested transaction parameters from the algod v2 client
And I create a new transient account and fund it with 10000000 microalgos.
And I make a transaction signer for the transient account.
And I build an application transaction with the transient account, the current application, suggested params, operation "create", approval-program "programs/abi_method_call.teal.tok", clear-program "programs/one.teal.tok", global-bytes 0, global-ints 0, local-bytes 1, 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.
And I remember the new application ID.
Scenario Outline: Method call execution with other transactions
Given a new AtomicTransactionComposer
# Create a pay transaction, create a TransactionSigner, and add it to the composer
When I build a payment transaction with sender "transient", receiver "transient", amount 100001, close remainder to ""
And I make a transaction signer for the transient account.
And I create a transaction with signer with the current transaction.
And I add the current transaction with signer to the composer.
# Try signing and compare the golden with the signed transaction
Then I gather signatures with the composer.
And The composer should have a status of "SIGNED".
# Clone the composer and build with a method call
And I clone the composer.
# Create a payment method call with an address argument, and add it to the composer
When I create the Method object from method signature "<method-signature>"
And I create a new method arguments array.
And I append the encoded arguments "<app-args>" to the 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.
# Build the group in the composer
And I build the transaction group with the composer. If there is an error it is "".
Then The composer should have a status of "BUILT".
And I gather signatures with the composer.
Then The composer should have a status of "SIGNED".
# Execute the group and check that the log contains the correct return value
And I execute the current transaction group with the composer.
Then The composer should have a status of "COMMITTED".
# Check that the log contains the expected value.
# Note that the <returns> is the exact log output, which is the base64 encoding
# of the value, with the first four bytes being the hash of "return"
And The app should have returned "<returns>".
Examples:
| method-signature | app-args | returns |
| add(uint64,uint64)uint64 | AAAAAAAAAAE=,AAAAAAAAAAI= | AAAAAAAAAAM= |
| empty()void | | |
Scenario Outline: Method call noop execution
Given a new AtomicTransactionComposer
When I create the Method object from method signature "<method-signature>"
And I create a new method arguments array.
And I append the encoded arguments "<app-args>" to the 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.
And I build the transaction group with the composer. If there is an error it is "".
Then The composer should have a status of "BUILT".
And I gather signatures with the composer.
Then The composer should have a status of "SIGNED".
And I execute the current transaction group with the composer.
Then The composer should have a status of "COMMITTED".
And The app should have returned "<returns>".
Examples:
| method-signature | app-args | returns |
| empty()void | | |
| add(uint64,uint64)uint64 | AAAAAAAAAAE=,AAAAAAAAAAI= | AAAAAAAAAAM= |
| add(uint64,uint64)uint64 | //////////4=,AAAAAAAAAAE= | //////////8= |
| referenceTest(account,application,account,asset,account,asset,asset,application,application)uint8[9] | Uabo7LuH+JfxYes3JwpJ4Fz3Kzoz5LYtZhWxaN8pa3g=,AAAAAAAAAAo=,Uabo7LuH+JfxYes3JwpJ4Fz3Kzoz5LYtZhWxaN8pa3g=,AAAAAAAAABQ=,1Hq2PnhdWWwQ3IvRrz0gZ8EZmoH68yc2DzLpab3P8uA=,AAAAAAAAABQ=,AAAAAAAAABU=,AAAAAAAAAAo=,AAAAAAAAAAs= | AQECAQECAAAB |
Scenario: Method call optin and closeout execution
Given a new AtomicTransactionComposer
When I create the Method object from method signature "optIn(string)string"
And I create a new method arguments array.
# "Algorand Fan"
And I append the encoded arguments "AAxBbGdvcmFuZCBGYW4=" to the method arguments array.
And I add a method call with the transient account, the current application, suggested params, on complete "optin", current transaction signer, current method arguments.
And I build the transaction group with the composer. If there is an error it is "".
Then The composer should have a status of "BUILT".
And I gather signatures with the composer.
Then The composer should have a status of "SIGNED".
And I execute the current transaction group with the composer.
Then The composer should have a status of "COMMITTED".
# "hello Algorand Fan"
And The app should have returned "ABJoZWxsbyBBbGdvcmFuZCBGYW4=".
Given a new AtomicTransactionComposer
When I create the Method object from method signature "closeOut()string"
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 "closeout", current transaction signer, current method arguments.
And I build the transaction group with the composer. If there is an error it is "".
Then The composer should have a status of "BUILT".
And I gather signatures with the composer.
Then The composer should have a status of "SIGNED".
And I execute the current transaction group with the composer.
Then The composer should have a status of "COMMITTED".
# "goodbye Algorand Fan"
And The app should have returned "ABRnb29kYnllIEFsZ29yYW5kIEZhbg==".
Scenario: Method call delete execution
Given I create a new transient account and fund it with 10000000 microalgos.
And I make a transaction signer for the transient account.
And I build an application transaction with the transient account, the current application, suggested params, operation "create", approval-program "programs/abi_method_call.teal.tok", clear-program "programs/one.teal.tok", global-bytes 0, global-ints 0, local-bytes 1, 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.
And I remember the new application ID.
And a new AtomicTransactionComposer
When I create the Method object from method signature "delete()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 "delete", current transaction signer, current method arguments.
And I build the transaction group with the composer. If there is an error it is "".
Then The composer should have a status of "BUILT".
And I gather signatures with the composer.
Then The composer should have a status of "SIGNED".
And I execute the current transaction group with the composer.
Then The composer should have a status of "COMMITTED".
And The app should have returned "".
Scenario Outline: Method call create execution
Given I create a new transient account and fund it with 10000000 microalgos.
And I make a transaction signer for the transient account.
And a new AtomicTransactionComposer
And an application id 0
When I create the Method object from method signature "create(uint64)uint64"
And I create a new method arguments array.
And I append the encoded arguments "AAAAAAAAAAQ=" to the method arguments array.
And I add a method call with the transient account, the current application, suggested params, on complete "<on-complete>", current transaction signer, current method arguments, approval-program "programs/abi_method_call.teal.tok", clear-program "programs/one.teal.tok", global-bytes 0, global-ints 0, local-bytes 0, local-ints 0, extra-pages 0.
And I build the transaction group with the composer. If there is an error it is "".
Then The composer should have a status of "BUILT".
And I gather signatures with the composer.
Then The composer should have a status of "SIGNED".
And I execute the current transaction group with the composer.
Then The composer should have a status of "COMMITTED".
And The app should have returned "AAAAAAAAAAg=".
Examples:
| on-complete |
| noop |
| optin |
| delete |
| update |
Scenario: Method call create and delete execution
Given I create a new transient account and fund it with 10000000 microalgos.
And I make a transaction signer for the transient account.
And a new AtomicTransactionComposer
And an application id 0
When I create the Method object from method signature "referenceTest(account,application,account,asset,account,asset,asset,application,application)uint8[9]"
And I create a new method arguments array.
And I append the encoded arguments "Uabo7LuH+JfxYes3JwpJ4Fz3Kzoz5LYtZhWxaN8pa3g=,AAAAAAAAAAo=,Uabo7LuH+JfxYes3JwpJ4Fz3Kzoz5LYtZhWxaN8pa3g=,AAAAAAAAABQ=,1Hq2PnhdWWwQ3IvRrz0gZ8EZmoH68yc2DzLpab3P8uA=,AAAAAAAAABQ=,AAAAAAAAABU=,AAAAAAAAAAo=,AAAAAAAAAAs=" to the method arguments array.
And I add a method call with the transient account, the current application, suggested params, on complete "delete", current transaction signer, current method arguments, approval-program "programs/abi_method_call.teal.tok", clear-program "programs/one.teal.tok", global-bytes 0, global-ints 0, local-bytes 0, local-ints 0, extra-pages 0.
And I build the transaction group with the composer. If there is an error it is "".
Then The composer should have a status of "BUILT".
And I gather signatures with the composer.
Then The composer should have a status of "SIGNED".
And I execute the current transaction group with the composer.
Then The composer should have a status of "COMMITTED".
And The app should have returned "AQECAQECAAAB".
Scenario: Method call update execution
Given I create a new transient account and fund it with 10000000 microalgos.
And I make a transaction signer for the transient account.
And a new AtomicTransactionComposer
When I create the Method object from method signature "update()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 "update", current transaction signer, current method arguments, approval-program "programs/six.teal.tok", clear-program "programs/six.teal.tok".
And I build the transaction group with the composer. If there is an error it is "".
Then The composer should have a status of "BUILT".
And I gather signatures with the composer.
Then The composer should have a status of "SIGNED".
And I execute the current transaction group with the composer.
Then The composer should have a status of "COMMITTED".
And The app should have returned "".
Scenario Outline: Method call with pay txn execution
Given a new AtomicTransactionComposer
And I build a payment transaction with sender "transient", receiver "transient", amount 1000000, close remainder to ""
And I create a transaction with signer with the current transaction.
# Create a payment method call with an address argument, and add it to the composer
And I create the Method object from method signature "<method-signature>"
And I create a new method arguments array.
And I append the current transaction with signer to the method arguments array.
And I append the encoded arguments "<app-args>" to the 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.
# Build the group in the composer
And I build the transaction group with the composer. If there is an error it is "".
Then The composer should have a status of "BUILT".
And I gather signatures with the composer.
Then The composer should have a status of "SIGNED".
# Execute the group and check that the log contains the correct return value
And I execute the current transaction group with the composer.
Then The composer should have a status of "COMMITTED".
And The app should have returned "<returns>".
Examples:
| method-signature | app-args | returns |
| payment(pay,uint64)bool | AAAAAAAPQkA= | gA== |
| payment(pay,uint64)bool | AAAAAAAPQkE= | AA== |
Scenario: Multiple method calls in one atomic group
Given a new AtomicTransactionComposer
# optIn(string)string
When I create the Method object from method signature "optIn(string)string"
And I create a new method arguments array.
And I append the encoded arguments "AAxBbGdvcmFuZCBGYW4=" to the method arguments array.
And I add a method call with the transient account, the current application, suggested params, on complete "optin", current transaction signer, current method arguments.
# payment(pay,uint64)bool
And I create the Method object from method signature "payment(pay,uint64)bool"
And I create a new method arguments array.
And I build a payment transaction with sender "transient", receiver "transient", amount 1234567, close remainder to ""
And I create a transaction with signer with the current transaction.
And I append the current transaction with signer to the method arguments array.
And I append the encoded arguments "AAAAAAAS1oc=" to the 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.
# empty()void
When I create the Method object from method signature "empty()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.
# add(uint64,uint64)uint64
When I create the Method object from method signature "add(uint64,uint64)uint64"
And I create a new method arguments array.
And I append the encoded arguments "AAAAAAAAAAE=,AAAAAAAAAAI=" to the 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.
# closeOut()string
And I create the Method object from method signature "closeOut()string"
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 "closeout", current transaction signer, current method arguments.
And I build the transaction group with the composer. If there is an error it is "".
Then The composer should have a status of "BUILT".
And I gather signatures with the composer.
Then The composer should have a status of "SIGNED".
And I execute the current transaction group with the composer.
Then The composer should have a status of "COMMITTED".
And The app should have returned "ABJoZWxsbyBBbGdvcmFuZCBGYW4=,gA==,,AAAAAAAAAAM=,ABRnb29kYnllIEFsZ29yYW5kIEZhbg==".