Skip to content

Commit 09a58fd

Browse files
authored
chore: utils-v3 migration (#18)
## Proposed Changes - Updating tests to rely on utils-v3 ## TODO - Update to production release after prod utils v3 is available on pypi - @lempira no major bumps in semantic version needed, as it doesn't affect production code, only the testing stack itself. However note, that I also removed semantic releases dependency as well as dependency on algokit_utils from the prod dependencies list -> i assume they were added there by accident. Algokit utils isn't utilized within the src codebase, only the testing stack.
2 parents 3185f6e + 7e70bf1 commit 09a58fd

22 files changed

+276
-277
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ from algokit_subscriber import AlgorandSubscriber
168168
from algokit_subscriber.types import SubscribedTransaction
169169
from algokit_utils import AlgorandClient
170170

171-
algorand = AlgorandClient.main_net()
171+
algorand = AlgorandClient.mainnet()
172172

173173
# The watermark is used to track how far the subscriber has processed transactions
174174
watermark = 0

examples/payments/payments.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
from algokit_subscriber.subscriber import AlgorandSubscriber
22
from algokit_subscriber.types.subscription import SubscribedTransaction
3-
from algokit_utils.beta.algorand_client import AlgorandClient
3+
from algokit_utils import AlgorandClient
44

5-
algorand = AlgorandClient.main_net()
5+
algorand = AlgorandClient.mainnet()
66

77
# The watermark is used to track how far the subscriber has processed transactions
88
# In this example, we are starting at round 41651683

examples/usdc/usdc.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
from algokit_subscriber.subscriber import AlgorandSubscriber
22
from algokit_subscriber.types.subscription import SubscribedTransaction
3-
from algokit_utils.beta.algorand_client import AlgorandClient
3+
from algokit_utils import AlgorandClient
44

5-
algorand = AlgorandClient.main_net()
5+
algorand = AlgorandClient.mainnet()
66

77
# The watermark is used to track how far the subscriber has processed transactions
88
# In this example, we are starting at round 41651683

poetry.lock

Lines changed: 38 additions & 110 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ readme = "README.md"
88
[tool.poetry.dependencies]
99
python = "^3.12"
1010
py-algorand-sdk = "^2.7.0"
11-
algokit-utils = "^2.3.0"
12-
python-semantic-release = "^9.19.1"
1311

1412
[tool.poetry.group.dev.dependencies]
13+
algokit-utils = "^3.0.0"
14+
python-semantic-release = "^9.8.8"
1515
mypy = "^1.10.1"
1616
ruff = "^0.5.0"
1717
pytest = "^8.2.2"
@@ -26,6 +26,7 @@ sphinx-copybutton = "^0.5.2"
2626
sphinx-autobuild = "^2024.4.16"
2727
sphinx-mermaid = "^0.0.8"
2828
poethepoet = "^0.24.4"
29+
pytest-sugar = "^1.0.0"
2930

3031
[build-system]
3132
requires = ["poetry-core"]
@@ -178,4 +179,3 @@ upload_to_vcs_release = true
178179

179180
[tool.semantic_release.remote.token]
180181
env = "GITHUB_TOKEN"
181-

tests/accounts.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
1-
from algokit_utils.beta.algorand_client import AlgorandClient
2-
from algokit_utils.beta.composer import PayParams
1+
from algokit_utils import AlgoAmount, AlgorandClient, PaymentParams
32

43

54
def generate_account(algorand: AlgorandClient, amount: int = int(5e6)) -> str:
6-
dispsener = algorand.account.dispenser().address
5+
dispsener = algorand.account.localnet_dispenser().address
76
addr = algorand.account.random().address
87

9-
algorand.send.payment(PayParams(sender=dispsener, receiver=addr, amount=amount))
8+
algorand.send.payment(
9+
PaymentParams(
10+
sender=dispsener, receiver=addr, amount=AlgoAmount(micro_algo=amount)
11+
)
12+
)
1013

1114
return addr

tests/filter_fixture.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
SubscribedTransaction,
66
TransactionSubscriptionResult,
77
)
8-
from algokit_utils.beta.algorand_client import AlgorandClient
8+
from algokit_utils import AlgorandClient
99

1010
from .transactions import get_subscribed_transactions_for_test, send_x_transactions
1111

@@ -21,7 +21,7 @@ def filter_synthetic_transactions(t: SubscribedTransaction) -> bool:
2121

2222
@pytest.fixture()
2323
def filter_fixture() -> dict:
24-
localnet = AlgorandClient.default_local_net()
24+
localnet = AlgorandClient.default_localnet()
2525
localnet.set_default_validity_window(1000)
2626

2727
def subscribe_algod(

tests/test_balance_changes.py

Lines changed: 86 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,14 @@
44
AlgorandSubscriberConfig,
55
BalanceChangeRole,
66
)
7-
from algokit_utils.beta.algorand_client import AlgorandClient
8-
from algokit_utils.beta.composer import (
7+
from algokit_utils import (
8+
AlgoAmount,
9+
AlgorandClient,
910
AssetCreateParams,
1011
AssetDestroyParams,
1112
AssetOptInParams,
1213
AssetTransferParams,
13-
PayParams,
14+
PaymentParams,
1415
)
1516

1617
from .accounts import generate_account
@@ -25,9 +26,11 @@ def test_asset_create_txns(filter_fixture: dict) -> None:
2526
txns = (
2627
localnet.new_group()
2728
.add_asset_create(
28-
AssetCreateParams(sender=sender, static_fee=2000, total=100_000_000)
29+
AssetCreateParams(
30+
sender=sender, static_fee=AlgoAmount(micro_algo=2000), total=100_000_000
31+
)
2932
)
30-
.execute()
33+
.send()
3134
)
3235
confirmations = get_confirmations(localnet, txns.tx_ids)
3336
asset = confirmations[0]["asset-index"]
@@ -64,19 +67,24 @@ def test_asset_destroy_txns(filter_fixture: dict) -> None:
6467
localnet.new_group()
6568
.add_asset_create(
6669
AssetCreateParams(
67-
sender=sender, static_fee=2000, total=100_000_000, manager=sender
70+
sender=sender,
71+
static_fee=AlgoAmount(micro_algo=2000),
72+
total=100_000_000,
73+
manager=sender,
6874
)
6975
)
70-
.execute()
76+
.send()
7177
)
7278
asset = get_confirmations(localnet, create_asset_txns.tx_ids)[0]["asset-index"]
7379

7480
txns = (
7581
localnet.new_group()
7682
.add_asset_destroy(
77-
AssetDestroyParams(sender=sender, static_fee=2000, asset_id=asset)
83+
AssetDestroyParams(
84+
sender=sender, static_fee=AlgoAmount(micro_algo=2000), asset_id=asset
85+
)
7886
)
79-
.execute()
87+
.send()
8088
)
8189

8290
subscription = filter_fixture["subscribe_and_verify"](
@@ -112,18 +120,26 @@ def test_balance_change_filter_on_fee(filter_fixture: dict) -> None:
112120
txns = (
113121
localnet.new_group()
114122
.add_asset_create(
115-
AssetCreateParams(sender=random_account, static_fee=3000, total=1)
123+
AssetCreateParams(
124+
sender=random_account, static_fee=AlgoAmount(micro_algo=3000), total=1
125+
)
116126
)
117127
.add_asset_create(
118-
AssetCreateParams(sender=test_account, static_fee=1000, total=1)
128+
AssetCreateParams(
129+
sender=test_account, static_fee=AlgoAmount(micro_algo=1000), total=1
130+
)
119131
)
120132
.add_asset_create(
121-
AssetCreateParams(sender=test_account, static_fee=3000, total=1)
133+
AssetCreateParams(
134+
sender=test_account, static_fee=AlgoAmount(micro_algo=3000), total=1
135+
)
122136
)
123137
.add_asset_create(
124-
AssetCreateParams(sender=test_account, static_fee=5000, total=1)
138+
AssetCreateParams(
139+
sender=test_account, static_fee=AlgoAmount(micro_algo=5000), total=1
140+
)
125141
)
126-
.execute()
142+
.send()
127143
)
128144

129145
filter_fixture["subscribe_and_verify_filter"](
@@ -155,54 +171,89 @@ def test_various_filters_on_payments(filter_fixture: dict) -> None:
155171
txns = (
156172
localnet.new_group()
157173
.add_payment(
158-
PayParams(amount=1000, sender=account, receiver=account2, static_fee=1000)
174+
PaymentParams(
175+
amount=AlgoAmount(micro_algo=1000),
176+
sender=account,
177+
receiver=account2,
178+
static_fee=AlgoAmount(micro_algo=1000),
179+
)
159180
)
160181
.add_payment(
161-
PayParams(amount=1000, sender=account2, receiver=account, static_fee=1000)
182+
PaymentParams(
183+
amount=AlgoAmount(micro_algo=1000),
184+
sender=account2,
185+
receiver=account,
186+
static_fee=AlgoAmount(micro_algo=1000),
187+
)
162188
)
163189
.add_payment(
164-
PayParams(amount=2000, sender=account, receiver=account2, static_fee=1000)
190+
PaymentParams(
191+
amount=AlgoAmount(micro_algo=2000),
192+
sender=account,
193+
receiver=account2,
194+
static_fee=AlgoAmount(micro_algo=1000),
195+
)
165196
)
166197
.add_payment(
167-
PayParams(amount=2000, sender=account2, receiver=account, static_fee=1000)
198+
PaymentParams(
199+
amount=AlgoAmount(micro_algo=2000),
200+
sender=account2,
201+
receiver=account,
202+
static_fee=AlgoAmount(micro_algo=1000),
203+
)
168204
)
169205
.add_payment(
170-
PayParams(amount=3000, sender=account, receiver=account2, static_fee=1000)
206+
PaymentParams(
207+
amount=AlgoAmount(micro_algo=3000),
208+
sender=account,
209+
receiver=account2,
210+
static_fee=AlgoAmount(micro_algo=1000),
211+
)
171212
)
172213
.add_payment(
173-
PayParams(amount=3000, sender=account2, receiver=account, static_fee=1000)
214+
PaymentParams(
215+
amount=AlgoAmount(micro_algo=3000),
216+
sender=account2,
217+
receiver=account,
218+
static_fee=AlgoAmount(micro_algo=1000),
219+
)
174220
)
175221
.add_payment(
176-
PayParams(
177-
amount=100_000,
222+
PaymentParams(
223+
amount=AlgoAmount(micro_algo=100_000),
178224
sender=account,
179225
receiver=account2,
180-
static_fee=1000,
226+
static_fee=AlgoAmount(micro_algo=1000),
181227
close_remainder_to=account3,
182228
)
183229
)
184230
.add_payment(
185-
PayParams(
186-
amount=100_000,
231+
PaymentParams(
232+
amount=AlgoAmount(micro_algo=100_000),
187233
sender=account2,
188234
receiver=account,
189-
static_fee=1000,
235+
static_fee=AlgoAmount(micro_algo=1000),
190236
close_remainder_to=account,
191237
)
192238
)
193239
.add_payment(
194-
PayParams(
195-
amount=100_000,
240+
PaymentParams(
241+
amount=AlgoAmount(micro_algo=100_000),
196242
sender=account3,
197243
receiver=account2,
198-
static_fee=2000,
244+
static_fee=AlgoAmount(micro_algo=2000),
199245
close_remainder_to=account,
200246
)
201247
)
202248
.add_payment(
203-
PayParams(amount=0, sender=account, receiver=account, static_fee=0)
249+
PaymentParams(
250+
amount=AlgoAmount(micro_algo=0),
251+
sender=account,
252+
receiver=account,
253+
static_fee=AlgoAmount(micro_algo=0),
254+
)
204255
)
205-
.execute()
256+
.send()
206257
)
207258

208259
subscribe_and_verify_filter(
@@ -471,10 +522,10 @@ def test_various_filters_on_axfers(filter_fixture: dict) -> None: # noqa: PLR09
471522

472523
asset1 = localnet.send.asset_create(
473524
AssetCreateParams(sender=test_account, total=1000, clawback=test_account)
474-
)["confirmation"]["asset-index"]
525+
).confirmation["asset-index"]
475526
asset2 = localnet.send.asset_create(
476527
AssetCreateParams(sender=test_account, total=1001, clawback=test_account)
477-
)["confirmation"]["asset-index"]
528+
).confirmation["asset-index"]
478529

479530
localnet.send.asset_opt_in(AssetOptInParams(sender=account, asset_id=asset1))
480531
localnet.send.asset_opt_in(AssetOptInParams(sender=account2, asset_id=asset1))
@@ -588,7 +639,7 @@ def test_various_filters_on_axfers(filter_fixture: dict) -> None: # noqa: PLR09
588639
sender=account2, receiver=account, asset_id=asset2, amount=23
589640
)
590641
)
591-
.execute()
642+
.send()
592643
)
593644

594645
subscribe_and_verify_filter(
@@ -861,7 +912,7 @@ def test_various_filters_on_axfers(filter_fixture: dict) -> None: # noqa: PLR09
861912

862913

863914
def test_block_payouts() -> None:
864-
algorand = AlgorandClient.main_net()
915+
algorand = AlgorandClient.mainnet()
865916
payout_round = 46838092
866917
watermark: int = payout_round - 1
867918

0 commit comments

Comments
 (0)