def test_should_start_a_new_model_and_provide_it_with_info_on_auction_kick( self, kick): # given (model, model_factory) = models(self.keeper, kick) # when self.keeper.check_all_auctions() wait_for_other_threads() # then model_factory.create_model.assert_called_once_with( Parameters(flipper=None, flapper=None, flopper=self.flopper.address, id=kick)) # and status = model.send_status.call_args[0][0] assert status.id == kick assert status.flipper is None assert status.flapper is None assert status.flopper == self.flopper.address assert status.bid > Rad.from_number(0) assert status.lot == self.mcd.vow.dump() assert status.tab is None assert status.beg > Wad.from_number(1) assert status.guy == self.mcd.vow.address assert status.era > 0 assert status.end < status.era + self.flopper.tau() + 1 assert status.tic == 0 assert status.price == Wad(status.bid / Rad(status.lot))
def test_should_start_a_new_model_and_provide_it_with_info_on_auction_kick( self): # given self.flopper.kick(self.gal_address, Wad.from_number(2), Wad.from_number(10)).transact() # when self.keeper.check_all_auctions() wait_for_other_threads() # then self.model_factory.create_model.assert_called_once_with( Parameters(flipper=None, flapper=None, flopper=self.flopper.address, id=1)) # and assert self.model.send_status.call_args[0][0].id == 1 assert self.model.send_status.call_args[0][0].flipper is None assert self.model.send_status.call_args[0][0].flapper is None assert self.model.send_status.call_args[0][ 0].flopper == self.flopper.address assert self.model.send_status.call_args[0][0].bid == Wad.from_number( 10) assert self.model.send_status.call_args[0][0].lot == Wad.from_number(2) assert self.model.send_status.call_args[0][0].tab is None assert self.model.send_status.call_args[0][0].beg == Ray.from_number( 1.05) assert self.model.send_status.call_args[0][0].guy == self.gal_address assert self.model.send_status.call_args[0][0].era > 0 assert self.model.send_status.call_args[0][ 0].end > self.model.send_status.call_args[0][0].era + 3600 assert self.model.send_status.call_args[0][0].tic == 0 assert self.model.send_status.call_args[0][0].price == Wad.from_number( 5.0)
def test_should_start_a_new_model_and_provide_it_with_info_on_auction_start( self, auction_id): # given (model, model_factory) = models(self.keeper, auction_id) # when self.keeper.check_all_auctions() wait_for_other_threads() # then model_factory.create_model.assert_called_once_with( Parameters(collateral_auction_house=None, surplus_auction_house=None, debt_auction_house=self.debt_auction_house.address, staked_token_auction_house=None, id=auction_id)) # and status = model.send_status.call_args[0][0] assert status.id == auction_id assert status.collateral_auction_house is None assert status.surplus_auction_house is None assert status.debt_auction_house == self.debt_auction_house.address assert status.bid_amount > Rad.from_number(0) assert status.amount_to_sell == self.geb.accounting_engine.initial_debt_auction_minted_tokens( ) assert status.amount_to_raise is None assert status.bid_decrease > Wad.from_number(1) assert status.high_bidder == self.geb.accounting_engine.address assert status.block_time > 0 assert status.auction_deadline < status.block_time + self.debt_auction_house.total_auction_length( ) + 1 assert status.bid_expiry == 0 assert status.price == Wad(status.bid_amount * self.geb.oracle_relayer.redemption_price() / Rad(status.amount_to_sell))
def test_should_start_a_new_model_and_provide_it_with_info_on_auction_kick( self, c, kick, mcd, keeper): # given (model, model_factory) = models(keeper, kick) # when keeper.check_all_auctions() wait_for_other_threads() initial_bid = c.flipper.bids(kick) # then model_factory.create_model.assert_called_once_with( Parameters(flipper=c.flipper.address, flapper=None, flopper=None, id=kick)) # and status = model.send_status.call_args[0][0] assert status.id == kick assert status.flipper == c.flipper.address assert status.flapper is None assert status.flopper is None assert status.bid == Rad.from_number(0) assert status.lot == initial_bid.lot assert status.tab == initial_bid.tab assert status.beg > Wad.from_number(1) assert status.guy == mcd.cat.address assert status.era > 0 assert status.end < status.era + c.flipper.tau() + 1 assert status.tic == 0 assert status.price == Wad(0)
def test_should_start_a_new_model_and_provide_it_with_info_on_auction_start(self, auction_id, other_address): # given collateral_auction_house = self.collateral.collateral_auction_house if not isinstance(collateral_auction_house, FixedDiscountCollateralAuctionHouse): return (model, model_factory) = models(self.keeper, auction_id) # when self.keeper.check_all_auctions() wait_for_other_threads() initial_bid = self.collateral.collateral_auction_house.bids(auction_id) # then model_factory.create_model.assert_called_once_with(Parameters(collateral_auction_house=collateral_auction_house.address, surplus_auction_house=None, debt_auction_house=None, id=auction_id)) # and status = model.send_status.call_args[0][0] assert status.id == auction_id assert status.collateral_auction_house == collateral_auction_house.address assert status.surplus_auction_house is None assert status.debt_auction_house is None assert status.amount_to_sell == initial_bid.amount_to_sell assert status.amount_to_raise == initial_bid.amount_to_raise assert status.block_time > 0 assert status.auction_deadline < status.block_time + collateral_auction_house.total_auction_length() + 1 # cleanup TestAuctionKeeperFixedDiscountCollateralAuctionHouse.buy_collateral_with_system_coin(self.geb, self.collateral, collateral_auction_house, auction_id, other_address, Wad.from_number(30))
def test_should_start_a_new_model_and_provide_it_with_info_on_auction_kick( self, bid_id, d, keeper, c): # given (model, model_factory) = self.models(keeper) # when keeper.check_all_auctions() wait_for_other_threads() # then model_factory.create_model.assert_called_once_with( Parameters(flipper=c.flipper.address, flapper=None, flopper=None, id=bid_id)) # and assert model.send_status.call_args[0][0].id == bid_id assert model.send_status.call_args[0][0].flipper == c.flipper.address assert model.send_status.call_args[0][0].flapper is None assert model.send_status.call_args[0][0].flopper is None assert model.send_status.call_args[0][0].bid == Wad.from_number(0) assert model.send_status.call_args[0][0].lot == Wad(684931506849315068) assert model.send_status.call_args[0][0].tab == Wad.from_number(100) assert model.send_status.call_args[0][0].beg == Ray.from_number(1.05) assert model.send_status.call_args[0][0].guy == d.cat.address assert model.send_status.call_args[0][0].era > 0 assert model.send_status.call_args[ 0][0].end < model.send_status.call_args[0][0].era + c.flipper.tau( ) + 1 assert model.send_status.call_args[0][0].tic == 0 assert model.send_status.call_args[0][0].price == Wad(0)
def get_auction(self, id: int, create: bool = True) -> Optional[Auction]: assert isinstance(id, int) assert isinstance(create, bool) if create and id not in self.auctions: # Log the fact that new auction has been detected self.logger.info(f"Started monitoring auction #{id}") # Prepare model startup parameters model_parameters = Parameters( auction_contract=self.auction_contract, id=id) # Start the model model = self.model_factory.create_model(model_parameters) # Register new auction self.auctions[id] = Auction(id, model) return self.auctions.get(id)
def test_should_start_a_new_model_and_provide_it_with_info_on_auction_kick( self, kick, other_address): # given (model, model_factory) = models(self.keeper, kick) flipper = self.collateral.flipper # when self.keeper.check_all_auctions() wait_for_other_threads() initial_bid = self.collateral.flipper.bids(kick) # then model_factory.create_model.assert_called_once_with( Parameters(flipper=flipper.address, flapper=None, flopper=None, id=kick)) # and status = model.send_status.call_args[0][0] assert status.id == kick assert status.flipper == flipper.address assert status.flapper is None assert status.flopper is None assert status.bid == Rad.from_number(0) assert status.lot == initial_bid.lot assert status.tab == initial_bid.tab assert status.beg > Wad.from_number(1) assert status.guy == self.mcd.cat.address assert status.era > 0 assert status.end < status.era + flipper.tau() + 1 assert status.tic == 0 assert status.price == Wad(0) # cleanup time_travel_by(self.web3, flipper.ttl() + 1) self.keeper.check_all_auctions() TestAuctionKeeperFlipper.tend_with_dai(self.mcd, self.collateral, flipper, kick, other_address, Rad.from_number(80)) flipper.deal(kick).transact(from_address=other_address)
def test_should_start_a_new_model_and_provide_it_with_info_on_auction_kick(self, kick): # given (model, model_factory) = models(self.keeper, kick) (needs_redo, price, lot, tab) = self.clipper.status(kick) # when self.keeper.check_all_auctions() initial_sale = self.clipper.sales(kick) # then model_factory.create_model.assert_called_once_with(Parameters(auction_contract=self.keeper.collateral.clipper, id=kick)) # and status = model.send_status.call_args[0][0] assert status.id == kick assert status.clipper == self.clipper.address assert status.flipper is None assert status.flapper is None assert status.flopper is None assert status.bid == Ray(status.lot) * status.price assert status.lot == initial_sale.lot assert status.tab == initial_sale.tab assert status.beg is None assert status.era > 0 assert time.time() - 5 < status.tic < time.time() + 5 assert status.price == price