Exemple #1
0
    def test_write_invalid(self, proxy_cache: DSProxyCache):
        # when
        address = proxy_cache.write('0x001122').transact()

        # then
        assert address is None
        assert proxy_cache.read('0x001122') == None
Exemple #2
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
Exemple #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
Exemple #4
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')"
Exemple #5
0
    def test_write(self, proxy_cache: DSProxyCache):
        # when
        proxy_cache.write(DSProxyCache.bin).transact()

        # then
        assert proxy_cache.read(DSProxyCache.bin) is not None
Exemple #6
0
 def test_read(self, proxy_cache: DSProxyCache):
     assert proxy_cache.read('0x001122') == None
Exemple #7
0
def proxy_cache(web3):
    return DSProxyCache.deploy(web3=web3)