Exemplo n.º 1
0
    def test_check_eta_receipt(self, mcd: DssDeployment, keeper: ChiefKeeper,
                               simpledb: SimpleDatabase, our_address: Address):
        print_out("test_check_eta_receipt")

        # clear out anything that came before
        keeper.check_hat()
        keeper.check_eta()

        # Give 1000 MKR to our_address
        amount = Wad.from_number(5000)
        mint_mkr(mcd.mkr, our_address, amount)
        assert mcd.mkr.balance_of(our_address) == amount

        # Lock MKR in DS-Chief
        assert mcd.mkr.approve(
            mcd.ds_chief.address).transact(from_address=our_address)
        assert mcd.ds_chief.lock(amount).transact(from_address=our_address)

        # Deploy spell
        spell = DSSBadSpell.deploy(mcd.web3)

        # Vote 5000 mkr on the spell
        assert mcd.ds_chief.vote_yays([spell.address.address
                                       ]).transact(from_address=our_address)

        keeper.check_hat()

        block = mcd.web3.eth.blockNumber
        simpledb.update_db_etas(block)

        hat = mcd.ds_chief.get_hat()

        etas = keeper.database.db.get(doc_id=3)['upcoming_etas']
        verify([hat.address], etas, 1)

        keeper.check_eta()

        # Confirm that the spell was casted and that the database was updated
        # For the DSSBadSpell, the cast() call in non-conformant.  Usually
        # cast() will flip done to true, but in this broken spell it's modified
        # to not set done to true so we can test this bug and prevent
        # regressions.
        assert DSSBadSpell(mcd.web3, Address(hat)).done() == False
        etas = keeper.database.db.get(doc_id=3)['upcoming_etas']
        verify([], etas, 0)
Exemplo n.º 2
0
    def test_check_hat(self, mcd: DssDeployment, keeper: ChiefKeeper,
                       guy_address: Address):
        print_out("test_check_hat")

        # Confirm the hat with the most approval is unchanged
        oldHat = mcd.ds_chief.get_hat()
        keeper.check_hat()
        newHat = mcd.ds_chief.get_hat()
        assert oldHat.address == newHat.address

        # Move the 2000 MKR vote from the last spell in test_database.py to new spell
        self.spell = DSSSpell.deploy(mcd.web3, mcd.pause.address,
                                     mcd.vat.address)
        assert mcd.ds_chief.vote_yays([self.spell.address.address
                                       ]).transact(from_address=guy_address)

        keeper.check_hat()

        # Confirm that the hat has been lifted
        newerHat = mcd.ds_chief.get_hat()
        assert newerHat.address == self.spell.address.address

        # Confirm that the spell was scheduled
        assert self.spell.eta() != 0