Пример #1
0
    def decode_output(self, hexstr: str) -> Tuple:
        """Decodes hexstring data returned by this method.

        Args:
            hexstr: Hexstring of returned call data

        Returns: Decoded values."""
        types_list = get_type_strings(self.abi["outputs"])
        result = eth_abi.decode_abi(types_list, HexBytes(hexstr))
        result = format_output(self.abi, result)
        if len(result) == 1:
            result = result[0]
        return result
Пример #2
0
def test_non_sequence():
    with pytest.raises(TypeError):
        format_output(abi, ["123", (1,), ([1, 1], [2, 2]), b"\xff"])
Пример #3
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"])
Пример #4
0
def test_wrong_length_initial():
    with pytest.raises(ValueError):
        format_output(abi, [(1, 2, 3), (1,), ([1, 1], [2, 2])])
    with pytest.raises(ValueError):
        format_output(abi, [(1, 2, 3), (1,), ([1, 1], [2, 2]), b"\xff", b"\xff"])
Пример #5
0
def test_success():
    assert format_output(abi, [(1, 2, 3), (1,), ([1, 1], [2, 2]), b"\xff"])
Пример #6
0
def test_empty():
    with pytest.raises(ValueError):
        format_output({"outputs": [], "name": "empty"}, [1])