async def test_subscribe_publish(self, redis_store: Store, tree_a: ActionTree, tree_b: ActionTree): tree_b.register_event(redis_channel) await asyncio.gather(tree_b.run(), tree_a.run(), wait_and_stop(tree_b)) assert redis_store.get(b_times_ran) == 1 assert redis_store.get(a_times_ran) == 1 assert redis_store.get(a_result) == 1337 assert redis_store.get(b_result) == 1338
async def test_on_next(self, trade1, trade2): store = Store() store.add("all_trades", [trade1, trade2]) tree = ActionTree(store) tree.add_action(Arbitrage()) await tree.run() assert len(store.get("filtered_trades")) == 2
async def test_on_next(self, mocker: MockerFixture): mocker.patch.object( Coingecko, "coins", return_value=[ "0xdac17f958d2ee523a2206206994597c13d831ec7", "0x514910771af9ca656af840dff83e8264ecf986ca", ], ) store = Store() tree = ActionTree(store) tree.add_action(Whitelist()) await tree.run() assert len(store.get("whitelist")) == 2
async def test_subscribe(self, redis_store: Store, tree_a): tree_a.register_event("my_channel") redis_store.publish("my_channel", "new pool added") await asyncio.gather(tree_a.run(), wait_and_stop(tree_a)) assert redis_store.get(a_times_ran) == 1