Ejemplo n.º 1
0
    def test_from_signature(self, web3):
        # given
        calldata1a = Calldata(
            '0xa9059cbb'  # function 4byte signature
            '00000000000000000000000011223344556600000000000000000000000000ff'
            '000000000000000000000000000000000000000000000000000000000000007b')
        calldata1b = Calldata.from_signature(
            web3, 'transfer(address,uint256)',
            ['0x11223344556600000000000000000000000000ff', 123])

        # expect
        assert calldata1a == calldata1b

        # given
        calldata2a = Calldata(
            '0x2b4e4e96'  # function 4byte signature
            '00000000000000000000000011223344556600000000000000000000000000ff'
            '0000000000000000000000000000000000000000000000000000000000000040'
            '0000000000000000000000000000000000000000000000000000000000000002'
            '000000000000000000000000000000000000000000000000000000000000007b'
            '00000000000000000000000000000000000000000000000000000000000001c8')
        calldata2b = Calldata.from_signature(
            web3, 'transfer(address,uint256[])',
            ['0x11223344556600000000000000000000000000ff', [123, 456]])

        # expect
        assert calldata2a == calldata2b
Ejemplo n.º 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
            ]))
Ejemplo n.º 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
Ejemplo n.º 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
Ejemplo n.º 5
0
    def test_from_signature(self):
        # given
        calldata1a = Calldata('0xa9059cbb'  # function 4byte signature
                              '00000000000000000000000011223344556600000000000000000000000000ff'
                              '000000000000000000000000000000000000000000000000000000000000007b')
        calldata1b = Calldata.from_signature('transfer(address,uint256)',
                                             ['0x11223344556600000000000000000000000000ff', 123])

        # expect
        assert calldata1a == calldata1b
Ejemplo n.º 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
            ]))
Ejemplo n.º 7
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
Ejemplo n.º 8
0
 def test_execute(self, proxy: DSProxy):
     assert proxy.execute(DSProxyFactory.bin,
                          Calldata.from_signature("build()",
                                                  [])).transact()