@@ -6,7 +6,6 @@ The [coverage](coverage.md) file provides a comprehensive list of all opcodes an
6
6
7
7
``` {testsetup}
8
8
import algopy
9
- import algopy_testing
10
9
from algopy_testing import algopy_testing_context
11
10
12
11
# Create the context manager for snippets below
@@ -29,7 +28,7 @@ The following opcodes are demonstrated:
29
28
- ` op.ecdsa_verify `
30
29
31
30
``` {testcode}
32
- import algopy.op as op
31
+ from algopy import op
33
32
34
33
# SHA256 hash
35
34
data = algopy.Bytes(b"Hello, World!")
@@ -59,7 +58,7 @@ The following opcodes are demonstrated:
59
58
- ` op.setbit_uint64 `
60
59
61
60
``` {testcode}
62
- import algopy.op as op
61
+ from algopy import op
63
62
64
63
# Addition with carry
65
64
result, carry = op.addw(algopy.UInt64(2**63), algopy.UInt64(2**63))
@@ -80,7 +79,7 @@ These types necessitate interaction with the transaction context:
80
79
### algopy.op.Global
81
80
82
81
``` {testcode}
83
- import algopy.op as op
82
+ from algopy import op
84
83
85
84
class MyContract(algopy.ARC4Contract):
86
85
@algopy.arc4.abimethod
@@ -102,12 +101,12 @@ assert result == algopy.UInt64(101000)
102
101
### algopy.op.Txn
103
102
104
103
``` {testcode}
105
- import algopy.op as op
104
+ from algopy import op
106
105
107
106
class MyContract(algopy.ARC4Contract):
108
107
@algopy.arc4.abimethod
109
- def check_txn_fields(self) -> algopy.Bytes :
110
- return op.Txn.sender
108
+ def check_txn_fields(self) -> algopy.arc4.Address :
109
+ return algopy.arc4.Address( op.Txn.sender)
111
110
112
111
... # setup context (below assumes available under 'ctx' variable)
113
112
@@ -121,7 +120,7 @@ assert result == custom_sender
121
120
### algopy.op.AssetHoldingGet
122
121
123
122
``` {testcode}
124
- import algopy.op as op
123
+ from algopy import op
125
124
126
125
class AssetContract(algopy.ARC4Contract):
127
126
@algopy.arc4.abimethod
@@ -141,7 +140,7 @@ assert result == algopy.UInt64(5000)
141
140
### algopy.op.AppGlobal
142
141
143
142
``` {testcode}
144
- import algopy.op as op
143
+ from algopy import op
145
144
146
145
class StateContract(algopy.ARC4Contract):
147
146
@algopy.arc4.abimethod
@@ -162,7 +161,7 @@ assert stored_value == 42
162
161
### algopy.op.Block
163
162
164
163
``` {testcode}
165
- import algopy.op as op
164
+ from algopy import op
166
165
167
166
class BlockInfoContract(algopy.ARC4Contract):
168
167
@algopy.arc4.abimethod
@@ -180,7 +179,7 @@ assert seed == algopy.op.itob(123456)
180
179
### algopy.op.AcctParamsGet
181
180
182
181
``` {testcode}
183
- import algopy.op as op
182
+ from algopy import op
184
183
185
184
class AccountParamsContract(algopy.ARC4Contract):
186
185
@algopy.arc4.abimethod
@@ -205,7 +204,7 @@ class AppParamsContract(algopy.ARC4Contract):
205
204
def get_app_creator(self, app_id: algopy.Application) -> algopy.arc4.Address:
206
205
creator, exists = algopy.op.AppParamsGet.app_creator(app_id)
207
206
assert exists
208
- return creator
207
+ return algopy.arc4.Address( creator)
209
208
210
209
... # setup context (below assumes available under 'ctx' variable)
211
210
@@ -218,8 +217,7 @@ assert creator == context.default_sender
218
217
### algopy.op.AssetParamsGet
219
218
220
219
``` {testcode}
221
- from algopy_testing import algopy_testing_context
222
- import algopy.op as op
220
+ from algopy import op
223
221
224
222
class AssetParamsContract(algopy.ARC4Contract):
225
223
@algopy.arc4.abimethod
@@ -239,8 +237,7 @@ assert total == algopy.UInt64(1000000)
239
237
### algopy.op.Box
240
238
241
239
``` {testcode}
242
- from algopy_testing import algopy_testing_context
243
- import algopy.op as op
240
+ from algopy import op
244
241
245
242
class BoxStorageContract(algopy.ARC4Contract):
246
243
@algopy.arc4.abimethod
@@ -329,23 +326,22 @@ assert result == 11
329
326
``` {testcode}
330
327
from unittest.mock import patch, MagicMock
331
328
import algopy
332
- from algopy_testing.primitives import Bytes
333
329
334
330
def test_mock_vrf_verify():
335
- mock_result = (Bytes(b'mock_output'), True)
331
+ mock_result = (algopy. Bytes(b'mock_output'), True)
336
332
with patch('algopy.op.vrf_verify', return_value=mock_result) as mock_vrf_verify:
337
333
result = algopy.op.vrf_verify(
338
334
algopy.op.VrfVerify.VrfAlgorand,
339
- Bytes(b'proof'),
340
- Bytes(b'message'),
341
- Bytes(b'public_key')
335
+ algopy. Bytes(b'proof'),
336
+ algopy. Bytes(b'message'),
337
+ algopy. Bytes(b'public_key')
342
338
)
343
339
assert result == mock_result
344
340
mock_vrf_verify.assert_called_once_with(
345
341
algopy.op.VrfVerify.VrfAlgorand,
346
- Bytes(b'proof'),
347
- Bytes(b'message'),
348
- Bytes(b'public_key')
342
+ algopy. Bytes(b'proof'),
343
+ algopy. Bytes(b'message'),
344
+ algopy. Bytes(b'public_key')
349
345
)
350
346
351
347
test_mock_vrf_verify()
@@ -356,19 +352,18 @@ test_mock_vrf_verify()
356
352
``` {testcode}
357
353
from unittest.mock import patch, MagicMock
358
354
import algopy
359
- from algopy_testing.primitives import Bytes
360
355
361
356
def test_mock_elliptic_curve_decompress():
362
- mock_result = (Bytes(b'x_coord'), Bytes(b'y_coord'))
357
+ mock_result = (algopy. Bytes(b'x_coord'), algopy. Bytes(b'y_coord'))
363
358
with patch('algopy.op.EllipticCurve.decompress', return_value=mock_result) as mock_decompress:
364
359
result = algopy.op.EllipticCurve.decompress(
365
360
algopy.op.EC.BN254g1,
366
- Bytes(b'compressed_point')
361
+ algopy. Bytes(b'compressed_point')
367
362
)
368
363
assert result == mock_result
369
364
mock_decompress.assert_called_once_with(
370
365
algopy.op.EC.BN254g1,
371
- Bytes(b'compressed_point')
366
+ algopy. Bytes(b'compressed_point')
372
367
)
373
368
374
369
test_mock_elliptic_curve_decompress()
0 commit comments