def tree_b(redis_store: Store): tree = ActionTree(redis_store) tree.add_action(ActionB()) redis_store.add(b_times_ran, 0) yield tree redis_store.delete(b_times_ran)
async def test_on_next(self, pools): store = Store() store.add("web3", MagicMock()) store.add("all_pools", pools) tree = ActionTree(store) tree.add_action(PoolUpdater()) with pytest.raises(ValueError): await tree.run()
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
def tree_a(redis_store: Store): tree = ActionTree(redis_store) tree.add_action(ActionA()) redis_store.add(a_times_ran, 0) yield tree redis_store.delete(a_times_ran) redis_store.delete(a_result)
def trade_store(w3_with_gas_strategy, router, bad_trade, trade, weth, trader_account): store = Store() store.add("router", router) store.add("filtered_trades", [bad_trade, trade]) store.add("weth", weth) store.add("web3", w3_with_gas_strategy) store.add("account", trader_account) return store
def store(pools, eth) -> Store: store = Store() store.add("pools", pools) future = asyncio.Future() future.set_result(eth) weth_mock = MagicMock() weth_mock.create_token.return_value = future store.add("eth", weth_mock) return store
def trade_store(self, w3, router, real_weth, dummy_account): real_weth.set_account(dummy_account) store = Store() store.add("weth", real_weth) store.add("web3", w3) store.add("account", dummy_account) store.add("router", router) return store
def store() -> Store: store = Store() store.add("pools", None) store.add("weth", None) return store
def test_store_add(self, redis_state, mocker: MockerFixture): mock_set = mocker.patch.object(RedisState, "__setitem__") store = Store(redis_state) store.add(MockAction.redis_collection_key, None) assert mock_set.called