Skip to content

Commit

Permalink
chore: add test case to confirm group simulate and send matches (#146)
Browse files Browse the repository at this point in the history
  • Loading branch information
neilcampbell authored Feb 27, 2025
1 parent 6134a86 commit ef79632
Showing 1 changed file with 44 additions and 2 deletions.
46 changes: 44 additions & 2 deletions tests/applications/test_app_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
from algokit_utils.applications.app_spec.arc56 import Arc56Contract, Network
from algokit_utils.errors.logic_error import LogicError
from algokit_utils.models.account import SigningAccount
from algokit_utils.models.amount import AlgoAmount
from algokit_utils.models.amount import AlgoAmount, micro_algo
from algokit_utils.models.state import BoxReference
from algokit_utils.transactions.transaction_composer import AppCreateParams, PaymentParams
from algokit_utils.transactions.transaction_composer import AppCallMethodCallParams, AppCreateParams, PaymentParams


@pytest.fixture
Expand Down Expand Up @@ -279,6 +279,48 @@ def test_clone_inheriting_app_name_based_on_default_handling(
assert cloned_app_client.app_name == hello_world_arc32_app_spec.contract.name == app_client.app_name


def test_group_simulate_matches_send(
funded_account: SigningAccount,
test_app_client: AppClient,
) -> None:
app_call1_params = AppCallMethodCallParams(
sender=funded_account.address,
app_id=test_app_client.app_id,
method=algosdk.abi.Method.from_signature("set_global(uint64,uint64,string,byte[4])void"),
args=[1, 2, "asdf", bytes([1, 2, 3, 4])],
)
payment_params = PaymentParams(
sender=funded_account.address, receiver=funded_account.address, amount=micro_algo(10000)
)
app_call2_params = AppCallMethodCallParams(
sender=funded_account.address,
app_id=test_app_client.app_id,
method=algosdk.abi.Method.from_signature("call_abi(string)string"),
args=["test"],
)

simulate_result = (
test_app_client.algorand.new_group()
.add_app_call_method_call(app_call1_params)
.add_payment(payment_params)
.add_app_call_method_call(app_call2_params)
.simulate(skip_signatures=True)
)

send_result = (
test_app_client.algorand.new_group()
.add_app_call_method_call(app_call1_params)
.add_payment(payment_params)
.add_app_call_method_call(app_call2_params)
.send()
)

assert len(simulate_result.transactions) == len(send_result.transactions)
assert len(simulate_result.returns) == len(send_result.returns)
assert simulate_result.returns[0].value == send_result.returns[0].value
assert simulate_result.returns[1].value == send_result.returns[1].value


def test_normalise_app_spec(
raw_hello_world_arc32_app_spec: str,
hello_world_arc32_app_spec: ApplicationSpecification,
Expand Down

1 comment on commit ef79632

@github-actions
Copy link

Choose a reason for hiding this comment

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

Coverage

Coverage Report
FileStmtsMissCoverMissing
src/algokit_utils
   _debugging.py1411887%21, 40–42, 45, 54, 62, 81, 87, 96, 110–114, 133, 141–143
   account.py330%1–12
   algorand.py981585%64–65, 79–80, 110–111, 125–127, 138–139, 299, 322, 338, 357
   application_client.py330%1–11
   application_specification.py770%1–39
   config.py782173%23, 30–34, 73–74, 90, 95, 100, 111–116, 141, 144–146, 149, 151
   deploy.py330%1–10
   logic_error.py330%1–10
src/algokit_utils/_legacy_v2
   _ensure_funded.py72199%96
   _transfer.py72396%14, 77–78
   account.py931386%15–18, 71–75, 109, 126, 156, 159, 203
   application_client.py5377786%56–57, 176, 181, 210, 322, 327–328, 330, 332, 801, 816, 834–837, 931, 971, 983, 996, 1038, 1098–1104, 1108–1113, 1115, 1151, 1158, 1271, 1307, 1321, 1359–1361, 1363, 1373–1430, 1441–1446, 1466–1469
   asset.py80495%24–27
   common.py13192%13
   deploy.py4072394%32–35, 170, 174–175, 193, 208, 249, 339–340, 361, 395, 406–414, 429, 437, 593–594, 618
   network_clients.py73593%79–80, 105–106, 139
src/algokit_utils/accounts
   account_manager.py2433386%167, 183–184, 211–216, 234–235, 252, 269–274, 321–323, 352, 391, 411–415, 428, 487, 508, 665, 771, 850, 855, 870–871, 894
   kmd_account_manager.py731086%47–53, 94, 150, 157
src/algokit_utils/applications
   abi.py1397149%14, 75, 111, 117, 119, 121, 125–126, 141–160, 176, 179–185, 201–214, 227–239, 254–265
   app_client.py74221471%66–74, 133, 141, 328–331, 334, 337, 340, 343, 355–358, 361, 364, 367, 370, 382, 391, 400, 403–470, 483–541, 565–567, 584–587, 595–598, 606–609, 617–620, 628–631, 642–645, 658, 754–757, 791, 803, 815, 827, 839, 854, 869, 879, 889, 899, 909, 919, 956–969, 985, 1002, 1019, 1036, 1057, 1078, 1168, 1364, 1428–1429, 1478, 1480, 1486, 1539–1547, 1580–1583, 1586–1589, 1610, 1658, 1721–1723, 1736–1743, 1788, 1805, 1807, 1810, 1814, 1961, 1972–1973, 2001, 2011–2013, 2016–2038, 2048, 2057–2072, 2077–2082
   app_deployer.py2373784%96, 270, 277, 287–292, 295–299, 375–376, 587, 599–613, 625, 631–634, 643, 657, 664, 671, 700, 711–752
   app_factory.py2712790%430, 451, 460, 652, 662, 712, 944, 958–963, 974–975, 1008, 1046, 1064–1065, 1108, 1116–1130
   app_manager.py2181693%258, 341–342, 387–392, 424, 448–449, 479, 507–510, 542, 551
src/algokit_utils/applications/app_spec
   arc32.py95892%198–207
   arc56.py5783294%71, 171, 292, 308–309, 379, 399–401, 453, 462, 464, 736, 750, 909, 911, 944–955, 968, 970–971, 987
src/algokit_utils/assets
   asset_manager.py1281291%282–283, 292, 298–322, 332
src/algokit_utils/clients
   client_manager.py1785470%24–26, 79–86, 111, 143–145, 205, 216–219, 244, 283, 318–323, 358–360, 393, 410, 432, 477–480, 520–523, 564–567, 604–607, 629–654, 692, 705, 717
   dispenser_api_client.py961288%134–135, 139–142, 198–200, 219–221
src/algokit_utils/errors
   logic_error.py561180%14, 105–121
src/algokit_utils/models
   account.py921584%32, 34, 80–81, 128, 136, 144, 168–175, 188, 196, 209, 217
   amount.py1061784%35, 42, 88, 98, 104, 112, 117–119, 126, 131–133, 140, 147, 160, 166
   application.py66198%8
   state.py41588%60, 64–67
   transaction.py51394%66, 86, 91
src/algokit_utils/protocols
   account.py11282%17, 22
   typed_clients.py24483%12–24
src/algokit_utils/transactions
   transaction_composer.py110411090%34–41, 574, 619, 622, 627, 631–642, 674, 715, 782, 789, 811, 846, 943–972, 1001, 1019–1021, 1027–1042, 1047, 1055, 1057, 1059, 1075, 1081, 1119, 1127, 1140, 1236, 1286, 1735–1736, 1775–1776, 1817, 2031, 2034, 2053, 2058, 2082–2084, 2121–2157, 2164–2171, 2312, 2316, 2447, 2449–2450, 2500–2501
   transaction_creator.py75791%394, 427, 482, 520, 557, 590, 688
   transaction_sender.py1611094%99, 268, 311–312, 711–716, 721–722, 887
TOTAL669691186% 

Tests Skipped Failures Errors Time
405 0 💤 0 ❌ 0 🔥 4m 50s ⏱️

Please sign in to comment.