Example #1
0
    def test_execute_at(self, proxy: DSProxy):
        # given
        proxy_cache = DSProxyCache(proxy.web3, proxy.cache())
        proxy_cache.write(DSProxyFactory.bin).transact()
        new_factory_addr = proxy_cache.read(DSProxyFactory.bin)
        assert new_factory_addr

        # when
        receipt = proxy.execute_at(
            new_factory_addr,
            Calldata.from_signature("build(address)",
                                    [proxy.address.address])).transact()
        assert receipt
        build_event = DSProxyFactory.log_created(receipt)[0]

        # then
        assert build_event.owner == proxy.address
Example #2
0
    def exit_all(self, proxy: DSProxy) -> Transact:
        assert (isinstance(proxy, DSProxy))

        return proxy.execute_at(
            self.mcd.dss_proxy_actions.address,
            Calldata.from_signature("exitAll(address,address)", [
                self.mcd.dai_adapter.address.address,
                self.mcd.pot.address.address
            ]))
Example #3
0
    def test_call_at(self, proxy: DSProxy):
        # given
        proxy_cache = DSProxyCache(proxy.web3, proxy.cache())
        proxy_cache.write(DSProxyFactory.bin).transact()
        new_factory_addr = proxy_cache.read(DSProxyFactory.bin)
        receipt = proxy.execute_at(
            new_factory_addr,
            Calldata.from_signature("build(address)",
                                    [proxy.address.address])).transact()
        log_created: LogCreated = DSProxyFactory.log_created(receipt)[0]

        # when
        calldata = Calldata.from_signature("isProxy(address)",
                                           [log_created.proxy.address])
        response = proxy.call_at(new_factory_addr, calldata)

        # then
        assert Web3.toInt(response) == 1
Example #4
0
    def test_call(self, proxy: DSProxy):
        # when
        calldata = Calldata.from_signature("isProxy(address)",
                                           [Address(40 * '0').address])
        target, response = proxy.call(DSProxyFactory.bin, calldata)

        # then
        assert target != Address(40 * '0')
        assert Web3.toInt(response) == 0
Example #5
0
    def test_name_formatting_with_hexstrings(self):
        # given
        proxy_cache = DSProxyCache.deploy(self.web3)
        proxy = DSProxy.deploy(self.web3, proxy_cache.address)

        # when
        transact = proxy.execute("0x11223344", Calldata("0x55667788"))

        # then
        assert transact.name() == f"DSProxy('{proxy.address}').execute(bytes,bytes)('0x11223344', '0x55667788')"
Example #6
0
    def exit(self, amount: Wad, proxy: DSProxy) -> Transact:
        assert (isinstance(amount, Wad))
        assert (isinstance(proxy, DSProxy))

        return proxy.execute_at(
            self.mcd.dss_proxy_actions.address,
            Calldata.from_signature("exit(address,address,uint256)", [
                self.mcd.dai_adapter.address.address,
                self.mcd.pot.address.address, amount.value
            ]))
Example #7
0
 def get_proxy(self) -> DSProxy:
     return DSProxy(self.mcd.web3,
                    Address(self.mcd.proxy_registry.proxies(self.owner)))
Example #8
0
def proxy(web3, proxy_cache):
    return DSProxy.deploy(web3=web3, cache=proxy_cache.address)
Example #9
0
 def test_execute(self, proxy: DSProxy):
     assert proxy.execute(DSProxyFactory.bin,
                          Calldata.from_signature("build()",
                                                  [])).transact()