Beispiel #1
0
async def test_array_output(jsonrpc, abiv2_contract):

    method_id = keccak256("testArrayOutput()")[:4].hex()
    rval = await jsonrpc.eth_call(to_address=abiv2_contract.address,
                                  data="0x" + method_id)
    assert decode_hex(rval) == words('20', '2', '1', '2')
    assert await abiv2_contract.testArrayOutput() == (1, 2)
Beispiel #2
0
async def test_struct_multidimensional_array_output(jsonrpc, abiv2_contract):
    method_id = keccak256("testStructMultidimensionalArrayOutput()")[:4].hex()
    rval = await jsonrpc.eth_call(to_address=abiv2_contract.address,
                                  data="0x" + method_id)
    assert decode_hex(rval) == words('20', '40', 'e0', '2', '1', '2', '3', '4',
                                     '2', '5', '6', '7', '8')
    rval = await abiv2_contract.testStructMultidimensionalArrayOutput()
    assert rval == (((1, 2), (3, 4)), ((5, 6), (7, 8)))
Beispiel #3
0
async def test_multidimensional_array_input(jsonrpc, abiv2_contract):

    method_id = keccak256(
        "testMultidimensionalArrayInput(uint256[][])")[:4].hex()
    data = "0x" + method_id + words('20', '2', '40', 'a0', '2', '1', '2', '2',
                                    '3', '4').hex()
    rval = await jsonrpc.eth_call(to_address=abiv2_contract.address, data=data)
    assert int(rval, 16) == 10

    assert await abiv2_contract.testMultidimensionalArrayInput(
        ((1, 2), (3, 4))) == 10
Beispiel #4
0
async def test_f(jsonrpc, abiv2_contract):
    method_id = keccak256(
        "f((uint256,uint256[],(uint256,uint256)[]),(uint256,uint256),uint256)"
    )[:4].hex()
    data = words('80', '8', '9', 'a', '1', '60', 'c0', '2', '2', '3', '2', '4',
                 '5', '6', '7').hex()
    data = "0x{method_id}{data}".format(method_id=method_id, data=data)
    await jsonrpc.eth_call(to_address=abiv2_contract.address, data=data)

    function_input = ((1, (2, 3), ((4, 5), (6, 7))), (8, 9), 10)
    await abiv2_contract.f(*function_input)