def test_should_not_create_orders_if_bands_overlap(self, deployment: Deployment, tmpdir): # given config_file = BandConfig.bands_overlapping_invalid_config(tmpdir) # and keeper = OasisMarketMakerKeeper(args=args( f"--eth-from {deployment.our_address} " f"--tub-address {deployment.tub.address} " f"--oasis-address {deployment.otc.address} " f"--buy-token-address {deployment.sai.address} " f"--sell-token-address {deployment.gem.address} " f"--price-feed tub " f"--config {config_file}"), web3=deployment.web3) keeper.lifecycle = Lifecycle(web3=keeper.web3) # and self.mint_tokens(deployment) self.set_price(deployment, Wad.from_number(100)) # and keeper.approve() # when self.synchronize_orders_twice(keeper) # then assert len(deployment.otc.get_orders()) == 0
def test_should_fail_to_operate_if_bands_overlap(self, deployment: Deployment, tmpdir): # given config_file = BandConfig.bands_overlapping_invalid_config(tmpdir) # and keeper = OasisMarketMakerKeeper(args=args( f"--eth-from {deployment.our_address} " f"--tub-address {deployment.tub.address} " f"--oasis-address {deployment.otc.address} " f"--price-feed tub " f"--config {config_file}"), web3=deployment.web3) keeper.lifecycle = Lifecycle(web3=keeper.web3) # and self.mint_tokens(deployment) self.set_price(deployment, Wad.from_number(100)) # and keeper.approve() # expect with pytest.raises(Exception): self.synchronize_orders_twice(keeper)
def test_should_fail_to_operate_if_bands_overlap(self, deployment: Deployment, tmpdir: py.path.local): # given config_file = BandConfig.bands_overlapping_invalid_config(tmpdir) # and keeper = EtherDeltaMarketMakerKeeper(args=args( f"--eth-from {deployment.our_address} --config {config_file}" f" --tub-address {deployment.tub.address}" f" --etherdelta-address {deployment.etherdelta.address}" f" --etherdelta-socket https://127.0.0.1:99999/" f" --order-age 3600 --eth-reserve 10" f" --min-eth-deposit 1 --min-sai-deposit 400"), web3=deployment.web3) keeper.lifecycle = Web3Lifecycle(web3=keeper.web3) keeper.etherdelta_api.publish_order = MagicMock() # and self.mint_tokens(deployment) self.set_price(deployment, Wad.from_number(100)) # and keeper.approve() # expect with pytest.raises(Exception): keeper.synchronize_orders()
def test_should_not_create_orders_if_bands_overlap(self, deployment: Deployment, tmpdir): # given config_file = BandConfig.bands_overlapping_invalid_config(tmpdir) # and keeper = OasisMarketMakerKeeper(args=args(f"--eth-from {deployment.our_address} " f"--tub-address {deployment.tub.address} " f"--oasis-address {deployment.otc.address} " f"--buy-token-address {deployment.sai.address} " f"--sell-token-address {deployment.gem.address} " f"--price-feed tub " f"--config {config_file}"), web3=deployment.web3) keeper.lifecycle = Lifecycle(web3=keeper.web3) # and self.mint_tokens(deployment) self.set_price(deployment, Wad.from_number(100)) # and keeper.approve() # when self.synchronize_orders_twice(keeper) # then assert len(deployment.otc.get_orders()) == 0
def test_should_cancel_all_orders_but_not_terminate_if_config_file_becomes_invalid( self, deployment: Deployment, tmpdir): # given config_file = BandConfig.sample_config(tmpdir) # and keeper = OasisMarketMakerKeeper(args=args( f"--eth-from {deployment.our_address} " f"--tub-address {deployment.tub.address} " f"--oasis-address {deployment.otc.address} " f"--buy-token-address {deployment.sai.address} " f"--sell-token-address {deployment.gem.address} " f"--price-feed tub " f"--config {config_file}"), web3=deployment.web3) keeper.lifecycle = Lifecycle(web3=keeper.web3) # and self.mint_tokens(deployment) self.set_price(deployment, Wad.from_number(100)) # when keeper.approve() self.synchronize_orders_twice(keeper) # then assert len(deployment.otc.get_orders()) == 2 # when second_config_file = BandConfig.bands_overlapping_invalid_config( tmpdir) shutil.copyfile(second_config_file, config_file) # and self.synchronize_orders_twice(keeper) # then assert len(deployment.otc.get_orders()) == 0 assert not keeper.lifecycle.terminated_internally
def test_should_cancel_all_orders_but_not_terminate_if_config_file_becomes_invalid(self, deployment: Deployment, tmpdir): # given config_file = BandConfig.sample_config(tmpdir) # and keeper = OasisMarketMakerKeeper(args=args(f"--eth-from {deployment.our_address} " f"--tub-address {deployment.tub.address} " f"--oasis-address {deployment.otc.address} " f"--buy-token-address {deployment.sai.address} " f"--sell-token-address {deployment.gem.address} " f"--price-feed tub " f"--config {config_file}"), web3=deployment.web3) keeper.lifecycle = Lifecycle(web3=keeper.web3) # and self.mint_tokens(deployment) self.set_price(deployment, Wad.from_number(100)) # when keeper.approve() self.synchronize_orders_twice(keeper) # then assert len(deployment.otc.get_orders()) == 2 # when second_config_file = BandConfig.bands_overlapping_invalid_config(tmpdir) shutil.copyfile(second_config_file, config_file) # and self.synchronize_orders_twice(keeper) # then assert len(deployment.otc.get_orders()) == 0 assert not keeper.lifecycle.terminated_internally