Skip to content

Commit 7e46800

Browse files
committed
fix: mock account tests
1 parent 620293c commit 7e46800

File tree

2 files changed

+55
-5
lines changed

2 files changed

+55
-5
lines changed

pypergraph/__about__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "0.2.9"
1+
__version__ = "0.2.10"

pypergraph/account/tests/test_account.py

Lines changed: 54 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,59 @@ async def test_currency_transfer(
228228
)
229229
assert isinstance(r, dict)
230230

231+
@pytest.mark.asyncio
232+
async def test_currency_batch_transfer(
233+
self,
234+
dag_account,
235+
metagraph_account,
236+
httpx_mock: HTTPXMock,
237+
mock_l1_api_responses,
238+
):
239+
# TODO: Mock this
240+
from secret import to_address
241+
242+
dag_account.connect(network_id="integrationnet")
243+
# last_ref = await account.network.get_address_last_accepted_transaction_ref(account.address)
244+
245+
txn_data = [
246+
{"to_address": to_address, "amount": 10000000, "fee": 200000},
247+
{"to_address": to_address, "amount": 5000000, "fee": 200000},
248+
{"to_address": to_address, "amount": 2500000, "fee": 200000},
249+
{"to_address": to_address, "amount": 1, "fee": 200000},
250+
]
251+
252+
httpx_mock.add_response(
253+
method="GET",
254+
url="https://l1-lb-integrationnet.constellationnetwork.io/transactions/last-reference/DAG0zJW14beJtZX2BY2KA9gLbpaZ8x6vgX4KVPVX",
255+
json=mock_l1_api_responses["last_ref"],
256+
)
257+
for _ in range(len(txn_data)):
258+
httpx_mock.add_response(
259+
method="POST",
260+
url="https://l1-lb-integrationnet.constellationnetwork.io/transactions",
261+
json={
262+
"data": {
263+
"hash": "b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9"
264+
}
265+
},
266+
status_code=200,
267+
)
268+
try:
269+
r = await dag_account.transfer_batch(transfers=txn_data)
270+
assert len(r) == 4
271+
except (NetworkError, httpx.ReadTimeout) as e:
272+
pytest.skip(f"Got expected error: {e}")
273+
"""PACA Metagraph doesn't function well with bulk transfers, it seems"""
274+
# metagraph_account = MetagraphTokenClient(
275+
# account=account,
276+
# metagraph_id="DAG7ChnhUF7uKgn8tXy45aj4zn9AFuhaZr8VXY43",
277+
# l0_host="http://elpaca-l0-2006678808.us-west-1.elb.amazonaws.com:9100",
278+
# currency_l1_host="http://elpaca-cl1-1512652691.us-west-1.elb.amazonaws.com:9200"
279+
# )
280+
# last_ref = await metagraph_account.network.get_address_last_accepted_transaction_ref(account.address)
281+
# r = await metagraph_account.transfer_batch(transfers=txn_data)
282+
# assert len(r) == 4
283+
231284

232285
@pytest.mark.integration
233286
class TestIntegrationAccount:
@@ -269,7 +322,6 @@ async def test_get_currency_transactions(self):
269322

270323
@pytest.mark.asyncio
271324
async def test_currency_transfer(self):
272-
# TODO: Mock this
273325
from secret import mnemo, to_address
274326

275327
account = DagAccount()
@@ -297,7 +349,6 @@ async def test_currency_transfer(self):
297349
r = await metagraph_account.transfer(
298350
to_address=to_address, amount=10000000, fee=2000000
299351
)
300-
print(r)
301352
assert isinstance(r, dict)
302353
except (NetworkError, httpx.ReadError):
303354
failed.append("El Paca Metagraph: Network or HTTPX ReadError (timeout)")
@@ -307,7 +358,6 @@ async def test_currency_transfer(self):
307358

308359
@pytest.mark.asyncio
309360
async def test_currency_batch_transfer(self):
310-
# TODO: Mock this
311361
from secret import mnemo, to_address
312362
from pypergraph.account import DagAccount
313363

@@ -332,7 +382,7 @@ async def test_currency_batch_transfer(self):
332382
# account=account,
333383
# metagraph_id="DAG7ChnhUF7uKgn8tXy45aj4zn9AFuhaZr8VXY43",
334384
# l0_host="http://elpaca-l0-2006678808.us-west-1.elb.amazonaws.com:9100",
335-
# cl1_host="http://elpaca-cl1-1512652691.us-west-1.elb.amazonaws.com:9200"
385+
# currency_l1_host="http://elpaca-cl1-1512652691.us-west-1.elb.amazonaws.com:9200"
336386
# )
337387
# last_ref = await metagraph_account.network.get_address_last_accepted_transaction_ref(account.address)
338388
# r = await metagraph_account.transfer_batch(transfers=txn_data)

0 commit comments

Comments
 (0)