Esempio n. 1
0
def test_bad_abi():
    with pytest.raises(InvalidABI):
        format_output({'outputs': []}, [])
    with pytest.raises(InvalidABI):
        format_output({'name': "bad"}, [])
    with pytest.raises(InvalidABI):
        format_output([], [])
Esempio n. 2
0
    def decode_abi(self, hexstr):
        '''Decodes hexstring data returned by this method.

        Args:
            hexstr: Hexstring of returned call data

        Returns: Decoded values.'''
        result = eth_abi.decode_abi([i['type'] for i in self.abi['outputs']],
                                    HexBytes(hexstr))
        result = format_output(self.abi, result)
        if len(result) == 1:
            return result[0]
        return ReturnValue(result, self.abi)
Esempio n. 3
0
    def decode_abi(self, hexstr):
        '''Decodes hexstring data returned by this method.

        Args:
            hexstr: Hexstring of returned call data

        Returns: Decoded values.'''
        types = [i[1] for i in _params(self.abi['outputs'])]
        result = eth_abi.decode_abi(types, HexBytes(hexstr))
        result = format_output(self.abi, result)
        if len(result) == 1:
            result = result[0]
        return result
Esempio n. 4
0
def test_non_sequence():
    with pytest.raises(TypeError):
        format_output(abi, ["123", (1, ), ([1, 1], [2, 2]), b"\xff"])
Esempio n. 5
0
def test_wrong_length_nested_array():
    with pytest.raises(ValueError):
        format_output(abi, [(1, 2, 3), (2, ), ([2, 2, 2], [2, 2, 2]), b"\xff"])
Esempio n. 6
0
def test_wrong_length_initial():
    with pytest.raises(TypeError):
        format_output(abi, [(1, 2, 3), (1, ), ([1, 1], [2, 2])])
    with pytest.raises(TypeError):
        format_output(abi, [(1, 2, 3), (1, ),
                            ([1, 1], [2, 2]), b"\xff", b"\xff"])
Esempio n. 7
0
def test_success():
    assert format_output(abi, [(1, 2, 3), (1, ), ([1, 1], [2, 2]), b"\xff"])
Esempio n. 8
0
def test_empty():
    with pytest.raises(TypeError):
        format_output({'outputs': [], 'name': "empty"}, [1])
Esempio n. 9
0
def test_empty():
    with pytest.raises(TypeError):
        format_output({"outputs": [], "name": "empty"}, [1])