async def test_zip(): async for va, vb in a.zip(asyncify(range(5)), range(5)): assert va == vb async for idx, vs in a.enumerate(a.zip(asyncify(range(5)), range(5))): assert vs[0] == vs[1] == idx async for _ in a.zip(): assert False
async def test_slots_updates_subscribe( websocket: SolanaWsClientProtocol, slots_updates_subscribed: None, ): """Test slots updates subscription.""" async for idx, resp in asyncstdlib.enumerate(websocket): assert resp.result.slot > 0 if idx == 40: break
async def test_cycle(): async for _ in a.cycle([]): assert False assert True async for idx, val in a.enumerate(a.cycle([0, 1])): assert idx % 2 == val if idx == 6: break assert idx == 6
async def test_zip_longest(): async for va, vb in a.zip_longest(asyncify(range(5)), range(5)): assert va == vb async for idx, vs in a.enumerate( a.zip_longest(asyncify(range(5)), range(5), [])): assert vs[0] == vs[1] == idx assert vs[2] is None async for _ in a.zip_longest(): assert False
async def get_all_boards(collection, skip, limit): boards = [] limit = limit - skip async for index, item in a.enumerate(collection.find({"deleted": False}).sort("registerDate", -1).skip(skip).limit(limit)): boards.append(convert_responses(item, index)) return boards
async def test_multiple_subscriptions( stubbed_sender: Keypair, test_http_client_async: AsyncClient, multiple_subscriptions: List[RequestBody], websocket: SolanaWsClientProtocol, ): """Test subscribing to multiple feeds.""" await test_http_client_async.request_airdrop(stubbed_sender.public_key, AIRDROP_AMOUNT) async for idx, message in asyncstdlib.enumerate(websocket): assert message.result is not None if idx == len(multiple_subscriptions) - 1: break balance = await test_http_client_async.get_balance( stubbed_sender.public_key, ) assert balance["result"]["value"] == AIRDROP_AMOUNT
async def test_enumerate(): async for count, value in a.enumerate(asyncify(range(5))): assert count == value async for count, value in a.enumerate(asyncify(range(5, 10)), start=5): assert count == value