Пример #1
0
    def test_bite_and_flip(self, web3, mcd, gal_address, keeper_address):
        # given
        c = mcd.collaterals['ETH-A']
        keeper = AuctionKeeper(args=args(f"--eth-from {keeper_address} "
                                         f"--type flip "
                                         f"--from-block 1 "
                                         f"--ilk {c.ilk.name} "
                                         f"--model ./bogus-model.sh"),
                               web3=mcd.web3)
        keeper.approve()
        unsafe_cdp = create_unsafe_cdp(mcd, c, Wad.from_number(1.2),
                                       gal_address)
        assert len(mcd.active_auctions()["flips"][c.ilk.name]) == 0
        # Keeper won't bid with a 0 Dai balance
        purchase_dai(Wad(20), keeper_address)
        assert mcd.dai_adapter.join(
            keeper_address, Wad(20)).transact(from_address=keeper_address)

        # when
        keeper.check_cdps()
        wait_for_other_threads()

        # then
        print(mcd.cat.past_bites(10))
        assert len(mcd.cat.past_bites(10)) > 0
        urn = mcd.vat.urn(unsafe_cdp.ilk, unsafe_cdp.address)
        assert urn.art == Wad(0)  # unsafe cdp has been bitten
        assert urn.ink == Wad(0)  # unsafe cdp is now safe ...
        assert c.flipper.kicks() == 1  # One auction started
Пример #2
0
    def test_bite_only(self, other_keeper: AuctionKeeper, d: DssDeployment, c: Collateral, unsafe_cdp: Urn):
        # given
        nflip = d.cat.nflip()
        nkick = c.flipper.kicks()

        # when
        other_keeper.check_cdps()
        wait_for_other_threads()

        # then
        urn = d.vat.urn(unsafe_cdp.ilk, unsafe_cdp.address)
        assert urn.art == Wad(0)  # unsafe cdp has been biten
        assert urn.ink == Wad(0)  # unsafe cdp is now safe ...
        assert d.cat.nflip() == nflip + 1 # One more flip available
        assert c.flipper.kicks() == nkick  # No auction started because no available fund to tend()
Пример #3
0
    def test_bite_and_flip(self, web3, mcd, gal_address, keeper_address):
        # given
        c = mcd.collaterals['ETH-A']
        keeper = AuctionKeeper(args=args(f"--eth-from {keeper_address} "
                                         f"--type flip "
                                         f"--network testnet "
                                         f"--ilk {c.ilk.name} "
                                         f"--model ./bogus-model.sh"),
                               web3=mcd.web3)
        keeper.approve()
        unsafe_cdp = create_unsafe_cdp(mcd, c, Wad.from_number(1.2),
                                       gal_address)
        assert len(mcd.active_auctions()["flips"][c.ilk.name]) == 0

        # when
        keeper.check_cdps()
        wait_for_other_threads()

        # then
        urn = mcd.vat.urn(unsafe_cdp.ilk, unsafe_cdp.address)
        assert urn.art == Wad(0)  # unsafe cdp has been bitten
        assert urn.ink == Wad(0)  # unsafe cdp is now safe ...
        assert c.flipper.kicks() == 1  # One auction started