19
19
)
20
20
from algokit_utils .dispenser_api import DispenserApiConfig
21
21
from algokit_utils .network_clients import get_algod_client , get_algonode_config
22
+ from algosdk .atomic_transaction_composer import AccountTransactionSigner
23
+ from algosdk .transaction import PaymentTxn
22
24
from algosdk .util import algos_to_microalgos
23
25
from pytest_httpx import HTTPXMock
24
26
@@ -38,6 +40,53 @@ def to_account(kmd_client: "KMDClient") -> Account:
38
40
return create_kmd_wallet_account (kmd_client , get_unique_name ())
39
41
40
42
43
+ @pytest .fixture ()
44
+ def rekeyed_from_account (algod_client : "AlgodClient" , kmd_client : "KMDClient" ) -> Account :
45
+ account = create_kmd_wallet_account (kmd_client , get_unique_name ())
46
+ rekey_account = create_kmd_wallet_account (kmd_client , get_unique_name ())
47
+
48
+ ensure_funded (
49
+ algod_client ,
50
+ EnsureBalanceParameters (
51
+ account_to_fund = account ,
52
+ min_spending_balance_micro_algos = 300000 ,
53
+ min_funding_increment_micro_algos = 1 ,
54
+ ),
55
+ )
56
+
57
+ rekey_txn = PaymentTxn (
58
+ sender = account .address ,
59
+ receiver = account .address ,
60
+ amt = 0 ,
61
+ note = "rekey account" ,
62
+ rekey_to = rekey_account .address ,
63
+ sp = algod_client .suggested_params (),
64
+ ) # type: ignore[no-untyped-call]
65
+ signed_rekey_txn = rekey_txn .sign (account .private_key ) # type: ignore[no-untyped-call]
66
+ algod_client .send_transaction (signed_rekey_txn )
67
+
68
+ return Account (address = account .address , private_key = rekey_account .private_key )
69
+
70
+
71
+ @pytest .fixture ()
72
+ def transaction_signer_from_account (
73
+ kmd_client : "KMDClient" ,
74
+ algod_client : "AlgodClient" ,
75
+ ) -> AccountTransactionSigner :
76
+ account = create_kmd_wallet_account (kmd_client , get_unique_name ())
77
+
78
+ ensure_funded (
79
+ algod_client ,
80
+ EnsureBalanceParameters (
81
+ account_to_fund = account ,
82
+ min_spending_balance_micro_algos = 300000 ,
83
+ min_funding_increment_micro_algos = 1 ,
84
+ ),
85
+ )
86
+
87
+ return AccountTransactionSigner (private_key = account .private_key )
88
+
89
+
41
90
@pytest .fixture ()
42
91
def clawback_account (kmd_client : "KMDClient" ) -> Account :
43
92
return create_kmd_wallet_account (kmd_client , get_unique_name ())
@@ -60,6 +109,44 @@ def test_transfer_algo(algod_client: "AlgodClient", to_account: Account, funded_
60
109
assert actual_amount == requested_amount
61
110
62
111
112
+ def test_transfer_algo_rekey_account (
113
+ algod_client : "AlgodClient" , to_account : Account , rekeyed_from_account : Account
114
+ ) -> None :
115
+ requested_amount = 100_000
116
+ transfer (
117
+ algod_client ,
118
+ TransferParameters (
119
+ from_account = rekeyed_from_account ,
120
+ to_address = to_account .address ,
121
+ micro_algos = requested_amount ,
122
+ ),
123
+ )
124
+
125
+ to_account_info = algod_client .account_info (to_account .address )
126
+ assert isinstance (to_account_info , dict )
127
+ actual_amount = to_account_info .get ("amount" )
128
+ assert actual_amount == requested_amount
129
+
130
+
131
+ def test_transfer_algo_transaction_signer_account (
132
+ algod_client : "AlgodClient" , to_account : Account , transaction_signer_from_account : AccountTransactionSigner
133
+ ) -> None :
134
+ requested_amount = 100_000
135
+ transfer (
136
+ algod_client ,
137
+ TransferParameters (
138
+ from_account = transaction_signer_from_account ,
139
+ to_address = to_account .address ,
140
+ micro_algos = requested_amount ,
141
+ ),
142
+ )
143
+
144
+ to_account_info = algod_client .account_info (to_account .address )
145
+ assert isinstance (to_account_info , dict )
146
+ actual_amount = to_account_info .get ("amount" )
147
+ assert actual_amount == requested_amount
148
+
149
+
63
150
def test_transfer_algo_max_fee_fails (algod_client : "AlgodClient" , to_account : Account , funded_account : Account ) -> None :
64
151
requested_amount = 100_000
65
152
max_fee = 123
0 commit comments