use of org.fisco.bcos.web3j.abi.datatypes.generated.StaticArray2 in project web3sdk by FISCO-BCOS.
the class FunctionEncoderTest method testMixTypeEncode9.
@Test
public void testMixTypeEncode9() {
// function baz(uint32,bool)
Function function0 = new Function("baz", Arrays.asList(new Uint32(69), new Bool(true)), Collections.singletonList(new TypeReference<DynamicArray<Utf8String>>() {
}));
assertThat(FunctionEncoder.encode(function0), is("0xcdcd77c0" + "0000000000000000000000000000000000000000000000000000000000000045" + "0000000000000000000000000000000000000000000000000000000000000001"));
// function baz(bytes3[2])
Function function1 = new Function("bar", Arrays.asList(new StaticArray2<Bytes3>(new Bytes3("abc".getBytes()), new Bytes3("def".getBytes()))), Collections.singletonList(new TypeReference<DynamicArray<Utf8String>>() {
}));
assertThat(FunctionEncoder.encode(function1), is("0xfce353f6" + "6162630000000000000000000000000000000000000000000000000000000000" + "6465660000000000000000000000000000000000000000000000000000000000"));
// function sam(bytes,bool,uint[])
Function function2 = new Function("sam", Arrays.asList(new DynamicBytes("dave".getBytes()), new Bool(true), new DynamicArray<Uint256>(new Uint256(1), new Uint256(2), new Uint256(3))), Collections.singletonList(new TypeReference<DynamicArray<Utf8String>>() {
}));
assertThat(FunctionEncoder.encode(function2), is("0xa5643bf2" + "0000000000000000000000000000000000000000000000000000000000000060" + "0000000000000000000000000000000000000000000000000000000000000001" + "00000000000000000000000000000000000000000000000000000000000000a0" + "0000000000000000000000000000000000000000000000000000000000000004" + "6461766500000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000003" + "0000000000000000000000000000000000000000000000000000000000000001" + "0000000000000000000000000000000000000000000000000000000000000002" + "0000000000000000000000000000000000000000000000000000000000000003"));
// function f(uint,uint32[],bytes10,bytes)
Function function3 = new Function("f", Arrays.asList(new Uint256(0x123), new DynamicArray<Uint32>(new Uint32(0x456), new Uint32(0x789)), new Bytes10("1234567890".getBytes()), new DynamicBytes("Hello, world!".getBytes())), Collections.singletonList(new TypeReference<DynamicArray<Utf8String>>() {
}));
assertThat(FunctionEncoder.encode(function3), is("0x8be65246" + "0000000000000000000000000000000000000000000000000000000000000123" + "0000000000000000000000000000000000000000000000000000000000000080" + "3132333435363738393000000000000000000000000000000000000000000000" + "00000000000000000000000000000000000000000000000000000000000000e0" + "0000000000000000000000000000000000000000000000000000000000000002" + "0000000000000000000000000000000000000000000000000000000000000456" + "0000000000000000000000000000000000000000000000000000000000000789" + "000000000000000000000000000000000000000000000000000000000000000d" + "48656c6c6f2c20776f726c642100000000000000000000000000000000000000"));
// function g(uint[][],string[])
Function function4 = new Function("g", Arrays.asList(new DynamicArray<DynamicArray<Uint256>>(new DynamicArray<Uint256>(new Uint256(1), new Uint256(2)), new DynamicArray<Uint256>(new Uint256(3))), new DynamicArray<Utf8String>(new Utf8String("one"), new Utf8String("two"), new Utf8String("three"))), Collections.singletonList(new TypeReference<DynamicArray<Utf8String>>() {
}));
assertThat(FunctionEncoder.encode(function4), is("0x2289b18c" + "0000000000000000000000000000000000000000000000000000000000000040" + "0000000000000000000000000000000000000000000000000000000000000140" + "0000000000000000000000000000000000000000000000000000000000000002" + "0000000000000000000000000000000000000000000000000000000000000040" + "00000000000000000000000000000000000000000000000000000000000000a0" + "0000000000000000000000000000000000000000000000000000000000000002" + "0000000000000000000000000000000000000000000000000000000000000001" + "0000000000000000000000000000000000000000000000000000000000000002" + "0000000000000000000000000000000000000000000000000000000000000001" + "0000000000000000000000000000000000000000000000000000000000000003" + "0000000000000000000000000000000000000000000000000000000000000003" + "0000000000000000000000000000000000000000000000000000000000000060" + "00000000000000000000000000000000000000000000000000000000000000a0" + "00000000000000000000000000000000000000000000000000000000000000e0" + "0000000000000000000000000000000000000000000000000000000000000003" + "6f6e650000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000003" + "74776f0000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000005" + "7468726565000000000000000000000000000000000000000000000000000000"));
}
use of org.fisco.bcos.web3j.abi.datatypes.generated.StaticArray2 in project web3sdk by FISCO-BCOS.
the class UtilsTest method encodeGetLengthTest.
@Test
public void encodeGetLengthTest() {
// uint256
assertThat(Utils.getLength(Arrays.asList(new Uint256(1))), is(1));
// int256
assertThat(Utils.getLength(Arrays.asList(new Int256(1))), is(1));
// bool
assertThat(Utils.getLength(Arrays.asList(new Bool(true))), is(1));
// address
assertThat(Utils.getLength(Arrays.asList(new Address("0xb87213121fb89cbd8b877cb1bb3ff84dd2869cfa"))), is(1));
// bytes2
assertThat(Utils.getLength(Arrays.asList(new Bytes2("ab".getBytes()))), is(1));
// bytes32
assertThat(Utils.getLength(Arrays.asList(new Bytes32("b87213121fb89cbd8b877cb1bb3ff84d".getBytes()))), is(1));
// bytes
assertThat(Utils.getLength(Arrays.asList(new DynamicBytes("b87213121fb89cbd8b877cb1bb3ff84d".getBytes()))), is(1));
// string
assertThat(Utils.getLength(Arrays.asList(new Utf8String("b87213121fb89cbd8b877cb1bb3ff84d"))), is(1));
// uint256[4]
assertThat(Utils.getLength(Arrays.asList(new StaticArray4<Uint256>(new Uint256(1), new Uint256(1), new Uint256(1), new Uint256(1)))), is(4));
// uint256[5]
assertThat(Utils.getLength(Arrays.asList(new StaticArray5<Uint256>(new Uint256(1), new Uint256(1), new Uint256(1), new Uint256(1), new Uint256(1)))), is(5));
// uint256[]
assertThat(Utils.getLength(Arrays.asList(new DynamicArray<Uint256>(new Uint256(1), new Uint256(1), new Uint256(1), new Uint256(1), new Uint256(1)))), is(1));
// uint256[][2]
assertThat(Utils.getLength(Arrays.asList(new StaticArray2<DynamicArray>(new DynamicArray<Uint256>(new Uint256(1), new Uint256(1), new Uint256(1), new Uint256(1), new Uint256(1)), new DynamicArray<Uint256>(new Uint256(1), new Uint256(1), new Uint256(1), new Uint256(1), new Uint256(1))))), is(1));
// uint256[2][]
assertThat(Utils.getLength(Arrays.asList(new DynamicArray<StaticArray2>(new StaticArray2<Uint256>(new Uint256(1), new Uint256(1)), new StaticArray2<Uint256>(new Uint256(1), new Uint256(1))))), is(1));
// uint256[][]
assertThat(Utils.getLength(Arrays.asList(new DynamicArray<DynamicArray>(new DynamicArray<Uint256>(new Uint256(1), new Uint256(1)), new DynamicArray<Uint256>(new Uint256(1), new Uint256(1))))), is(1));
// uint256[2][2]
assertThat(Utils.getLength(Arrays.asList(new StaticArray2<StaticArray2>(new StaticArray2<Uint256>(new Uint256(1), new Uint256(1)), new StaticArray2<Uint256>(new Uint256(1), new Uint256(1))))), is(4));
// int256[4]
assertThat(Utils.getLength(Arrays.asList(new StaticArray4<Int256>(new Int256(1), new Int256(1), new Int256(1), new Int256(1)))), is(4));
// int256[5]
assertThat(Utils.getLength(Arrays.asList(new StaticArray5<Int256>(new Int256(1), new Int256(1), new Int256(1), new Int256(1), new Int256(1)))), is(5));
// int256[]
assertThat(Utils.getLength(Arrays.asList(new DynamicArray<Int256>(new Int256(1), new Int256(1), new Int256(1), new Int256(1), new Int256(1)))), is(1));
// int256[][2]
assertThat(Utils.getLength(Arrays.asList(new StaticArray2<DynamicArray>(new DynamicArray<Int256>(new Int256(1), new Int256(1), new Int256(1), new Int256(1), new Int256(1)), new DynamicArray<Int256>(new Int256(1), new Int256(1), new Int256(1), new Int256(1), new Int256(1))))), is(1));
// int256[][]
assertThat(Utils.getLength(Arrays.asList(new DynamicArray<DynamicArray>(new DynamicArray<Int256>(new Int256(1), new Int256(1), new Int256(1), new Int256(1), new Int256(1)), new DynamicArray<Int256>(new Int256(1), new Int256(1), new Int256(1), new Int256(1), new Int256(1))))), is(1));
// int256[2][]
assertThat(Utils.getLength(Arrays.asList(new DynamicArray<StaticArray2>(new StaticArray2<Int256>(new Int256(1), new Int256(1)), new StaticArray2<Int256>(new Int256(1), new Int256(1))))), is(1));
// int256[2][2]
assertThat(Utils.getLength(Arrays.asList(new StaticArray2<StaticArray2>(new StaticArray2<Int256>(new Int256(1), new Int256(1)), new StaticArray2<Int256>(new Int256(1), new Int256(1))))), is(4));
// bool[4]
assertThat(Utils.getLength(Arrays.asList(new StaticArray4<Bool>(new Bool(true), new Bool(true), new Bool(true), new Bool(true)))), is(4));
// bool[10]
assertThat(Utils.getLength(Arrays.asList(new StaticArray10<Bool>(new Bool(true), new Bool(true), new Bool(true), new Bool(true), new Bool(true), new Bool(true), new Bool(true), new Bool(true), new Bool(true), new Bool(true)))), is(10));
// bool[]
assertThat(Utils.getLength(Arrays.asList(new DynamicArray<Bool>(new Bool(true), new Bool(true), new Bool(true), new Bool(true), new Bool(true), new Bool(true), new Bool(true), new Bool(true), new Bool(true), new Bool(true)))), is(1));
// bool[][2]
assertThat(Utils.getLength(Arrays.asList(new StaticArray2<DynamicArray>(new DynamicArray<Bool>(new Bool(true), new Bool(true), new Bool(true), new Bool(true), new Bool(true)), new DynamicArray<Bool>(new Bool(true), new Bool(true), new Bool(true), new Bool(true), new Bool(true))))), is(1));
// bool[2][]
assertThat(Utils.getLength(Arrays.asList(new DynamicArray<StaticArray2>(new StaticArray2<Bool>(new Bool(true), new Bool(true)), new StaticArray2<Bool>(new Bool(true), new Bool(true))))), is(1));
// bool[][]
assertThat(Utils.getLength(Arrays.asList(new DynamicArray<DynamicArray>(new DynamicArray<Bool>(new Bool(true), new Bool(true)), new DynamicArray<Bool>(new Bool(true), new Bool(true))))), is(1));
// bool[2][2]
assertThat(Utils.getLength(Arrays.asList(new StaticArray2<StaticArray2>(new StaticArray2<Bool>(new Bool(true), new Bool(true)), new StaticArray2<Bool>(new Bool(true), new Bool(true))))), is(4));
// bool[2][2][2]
assertThat(Utils.getLength(Arrays.asList(new StaticArray2<StaticArray2<StaticArray2>>(new StaticArray2<StaticArray2>(new StaticArray2<Bool>(new Bool(true), new Bool(true)), new StaticArray2<Bool>(new Bool(true), new Bool(true))), new StaticArray2<StaticArray2>(new StaticArray2<Bool>(new Bool(true), new Bool(true)), new StaticArray2<Bool>(new Bool(true), new Bool(true)))))), is(8));
// address[4]
assertThat(Utils.getLength(Arrays.asList(new StaticArray4<Address>(new Address("0xb87213121fb89cbd8b877cb1bb3ff84dd2869cfa"), new Address("0xb87213121fb89cbd8b877cb1bb3ff84dd2869cfa"), new Address("0xb87213121fb89cbd8b877cb1bb3ff84dd2869cfa"), new Address("0xb87213121fb89cbd8b877cb1bb3ff84dd2869cfa")))), is(4));
// address[5]
assertThat(Utils.getLength(Arrays.asList(new StaticArray5<Address>(new Address("0xb87213121fb89cbd8b877cb1bb3ff84dd2869cfa"), new Address("0xb87213121fb89cbd8b877cb1bb3ff84dd2869cfa"), new Address("0xb87213121fb89cbd8b877cb1bb3ff84dd2869cfa"), new Address("0xb87213121fb89cbd8b877cb1bb3ff84dd2869cfa"), new Address("0xb87213121fb89cbd8b877cb1bb3ff84dd2869cfa")))), is(5));
// address[]
assertThat(Utils.getLength(Arrays.asList(new DynamicArray<Address>(new Address("0xb87213121fb89cbd8b877cb1bb3ff84dd2869cfa"), new Address("0xb87213121fb89cbd8b877cb1bb3ff84dd2869cfa"), new Address("0xb87213121fb89cbd8b877cb1bb3ff84dd2869cfa"), new Address("0xb87213121fb89cbd8b877cb1bb3ff84dd2869cfa"), new Address("0xb87213121fb89cbd8b877cb1bb3ff84dd2869cfa")))), is(1));
// address[][2]
assertThat(Utils.getLength(Arrays.asList(new StaticArray2<DynamicArray>(new DynamicArray<Address>(new Address("0xb87213121fb89cbd8b877cb1bb3ff84dd2869cfa"), new Address("0xb87213121fb89cbd8b877cb1bb3ff84dd2869cfa"), new Address("0xb87213121fb89cbd8b877cb1bb3ff84dd2869cfa"), new Address("0xb87213121fb89cbd8b877cb1bb3ff84dd2869cfa"), new Address("0xb87213121fb89cbd8b877cb1bb3ff84dd2869cfa")), new DynamicArray<Address>(new Address("0xb87213121fb89cbd8b877cb1bb3ff84dd2869cfa"), new Address("0xb87213121fb89cbd8b877cb1bb3ff84dd2869cfa"), new Address("0xb87213121fb89cbd8b877cb1bb3ff84dd2869cfa"), new Address("0xb87213121fb89cbd8b877cb1bb3ff84dd2869cfa"), new Address("0xb87213121fb89cbd8b877cb1bb3ff84dd2869cfa"))))), is(1));
// address[2][]
assertThat(Utils.getLength(Arrays.asList(new DynamicArray<StaticArray2>(new StaticArray2<Address>(new Address("0xb87213121fb89cbd8b877cb1bb3ff84dd2869cfa"), new Address("0xb87213121fb89cbd8b877cb1bb3ff84dd2869cfa")), new StaticArray2<Address>(new Address("0xb87213121fb89cbd8b877cb1bb3ff84dd2869cfa"), new Address("0xb87213121fb89cbd8b877cb1bb3ff84dd2869cfa"))))), is(1));
// address[][]
assertThat(Utils.getLength(Arrays.asList(new DynamicArray<DynamicArray>(new DynamicArray<Address>(new Address("0xb87213121fb89cbd8b877cb1bb3ff84dd2869cfa"), new Address("0xb87213121fb89cbd8b877cb1bb3ff84dd2869cfa")), new DynamicArray<Address>(new Address("0xb87213121fb89cbd8b877cb1bb3ff84dd2869cfa"), new Address("0xb87213121fb89cbd8b877cb1bb3ff84dd2869cfa"))))), is(1));
// address[3][3]
assertThat(Utils.getLength(Arrays.asList(new StaticArray3<StaticArray3>(new StaticArray3<Address>(new Address("0xb87213121fb89cbd8b877cb1bb3ff84dd2869cfa"), new Address("0xb87213121fb89cbd8b877cb1bb3ff84dd2869cfa"), new Address("0xb87213121fb89cbd8b877cb1bb3ff84dd2869cfa")), new StaticArray3<Address>(new Address("0xb87213121fb89cbd8b877cb1bb3ff84dd2869cfa"), new Address("0xb87213121fb89cbd8b877cb1bb3ff84dd2869cfa"), new Address("0xb87213121fb89cbd8b877cb1bb3ff84dd2869cfa")), new StaticArray3<Address>(new Address("0xb87213121fb89cbd8b877cb1bb3ff84dd2869cfa"), new Address("0xb87213121fb89cbd8b877cb1bb3ff84dd2869cfa"), new Address("0xb87213121fb89cbd8b877cb1bb3ff84dd2869cfa"))))), is(9));
// bytes32[6]
assertThat(Utils.getLength(Arrays.asList(new StaticArray6<Bytes32>(new Bytes32("b87213121fb89cbd8b877cb1bb3ff84d".getBytes()), new Bytes32("b87213121fb89cbd8b877cb1bb3ff84d".getBytes()), new Bytes32("b87213121fb89cbd8b877cb1bb3ff84d".getBytes()), new Bytes32("b87213121fb89cbd8b877cb1bb3ff84d".getBytes()), new Bytes32("b87213121fb89cbd8b877cb1bb3ff84d".getBytes()), new Bytes32("b87213121fb89cbd8b877cb1bb3ff84d".getBytes())))), is(6));
// bytes32[]
assertThat(Utils.getLength(Arrays.asList(new DynamicArray<Bytes32>(new Bytes32("b87213121fb89cbd8b877cb1bb3ff84d".getBytes()), new Bytes32("b87213121fb89cbd8b877cb1bb3ff84d".getBytes()), new Bytes32("b87213121fb89cbd8b877cb1bb3ff84d".getBytes()), new Bytes32("b87213121fb89cbd8b877cb1bb3ff84d".getBytes()), new Bytes32("b87213121fb89cbd8b877cb1bb3ff84d".getBytes()), new Bytes32("b87213121fb89cbd8b877cb1bb3ff84d".getBytes())))), is(1));
// bytes32[][2]
assertThat(Utils.getLength(Arrays.asList(new StaticArray2<DynamicArray>(new DynamicArray<Bytes32>(new Bytes32("b87213121fb89cbd8b877cb1bb3ff84d".getBytes()), new Bytes32("b87213121fb89cbd8b877cb1bb3ff84d".getBytes()), new Bytes32("b87213121fb89cbd8b877cb1bb3ff84d".getBytes()), new Bytes32("b87213121fb89cbd8b877cb1bb3ff84d".getBytes()), new Bytes32("b87213121fb89cbd8b877cb1bb3ff84d".getBytes())), new DynamicArray<Bytes32>(new Bytes32("b87213121fb89cbd8b877cb1bb3ff84d".getBytes()), new Bytes32("b87213121fb89cbd8b877cb1bb3ff84d".getBytes()), new Bytes32("b87213121fb89cbd8b877cb1bb3ff84d".getBytes()), new Bytes32("b87213121fb89cbd8b877cb1bb3ff84d".getBytes()), new Bytes32("b87213121fb89cbd8b877cb1bb3ff84d".getBytes()))))), is(1));
// bytes32[2][]
assertThat(Utils.getLength(Arrays.asList(new DynamicArray<StaticArray2>(new StaticArray2<Bytes32>(new Bytes32("b87213121fb89cbd8b877cb1bb3ff84d".getBytes()), new Bytes32("b87213121fb89cbd8b877cb1bb3ff84d".getBytes())), new StaticArray2<Bytes32>(new Bytes32("b87213121fb89cbd8b877cb1bb3ff84d".getBytes()), new Bytes32("b87213121fb89cbd8b877cb1bb3ff84d".getBytes()))))), is(1));
// bytes32[][]
assertThat(Utils.getLength(Arrays.asList(new DynamicArray<DynamicArray>(new DynamicArray<Bytes32>(new Bytes32("b87213121fb89cbd8b877cb1bb3ff84d".getBytes()), new Bytes32("b87213121fb89cbd8b877cb1bb3ff84d".getBytes())), new DynamicArray<Bytes32>(new Bytes32("b87213121fb89cbd8b877cb1bb3ff84d".getBytes()), new Bytes32("b87213121fb89cbd8b877cb1bb3ff84d".getBytes()))))), is(1));
// bytes32[3][3]
assertThat(Utils.getLength(Arrays.asList(new StaticArray3<StaticArray3>(new StaticArray3<Bytes32>(new Bytes32("b87213121fb89cbd8b877cb1bb3ff84d".getBytes()), new Bytes32("b87213121fb89cbd8b877cb1bb3ff84d".getBytes()), new Bytes32("b87213121fb89cbd8b877cb1bb3ff84d".getBytes())), new StaticArray3<Bytes32>(new Bytes32("b87213121fb89cbd8b877cb1bb3ff84d".getBytes()), new Bytes32("b87213121fb89cbd8b877cb1bb3ff84d".getBytes()), new Bytes32("b87213121fb89cbd8b877cb1bb3ff84d".getBytes())), new StaticArray3<Bytes32>(new Bytes32("b87213121fb89cbd8b877cb1bb3ff84d".getBytes()), new Bytes32("b87213121fb89cbd8b877cb1bb3ff84d".getBytes()), new Bytes32("b87213121fb89cbd8b877cb1bb3ff84d".getBytes()))))), is(9));
// string[2]
assertThat(Utils.getLength(Arrays.asList(new StaticArray2<Utf8String>(new Utf8String("b87213121fb89cbd8b877cb1bb3ff84d"), new Utf8String("b87213121fb89cbd8b877cb1bb3ff84d")))), is(1));
// string[4]
assertThat(Utils.getLength(Arrays.asList(new StaticArray4<Utf8String>(new Utf8String("b87213121fb89cbd8b877cb1bb3ff84d"), new Utf8String("b87213121fb89cbd8b877cb1bb3ff84d"), new Utf8String("b87213121fb89cbd8b877cb1bb3ff84d"), new Utf8String("b87213121fb89cbd8b877cb1bb3ff84d")))), is(1));
// string[]
assertThat(Utils.getLength(Arrays.asList(new DynamicArray<Utf8String>(new Utf8String("b87213121fb89cbd8b877cb1bb3ff84d"), new Utf8String("b87213121fb89cbd8b877cb1bb3ff84d"), new Utf8String("b87213121fb89cbd8b877cb1bb3ff84d"), new Utf8String("b87213121fb89cbd8b877cb1bb3ff84d")))), is(1));
// string[][2]
assertThat(Utils.getLength(Arrays.asList(new StaticArray2<DynamicArray>(new DynamicArray<Utf8String>(new Utf8String("b87213121fb89cbd8b877cb1bb3ff84d"), new Utf8String("b87213121fb89cbd8b877cb1bb3ff84d"), new Utf8String("b87213121fb89cbd8b877cb1bb3ff84d"), new Utf8String("b87213121fb89cbd8b877cb1bb3ff84d"), new Utf8String("b87213121fb89cbd8b877cb1bb3ff84d")), new DynamicArray<Utf8String>(new Utf8String("b87213121fb89cbd8b877cb1bb3ff84d"), new Utf8String("b87213121fb89cbd8b877cb1bb3ff84d"), new Utf8String("b87213121fb89cbd8b877cb1bb3ff84d"), new Utf8String("b87213121fb89cbd8b877cb1bb3ff84d"), new Utf8String("b87213121fb89cbd8b877cb1bb3ff84d"))))), is(1));
// string[2][]
assertThat(Utils.getLength(Arrays.asList(new DynamicArray<StaticArray2>(new StaticArray2<Utf8String>(new Utf8String("b87213121fb89cbd8b877cb1bb3ff84d"), new Utf8String("b87213121fb89cbd8b877cb1bb3ff84d")), new StaticArray2<Utf8String>(new Utf8String("b87213121fb89cbd8b877cb1bb3ff84d"), new Utf8String("b87213121fb89cbd8b877cb1bb3ff84d"))))), is(1));
// string[][]
assertThat(Utils.getLength(Arrays.asList(new DynamicArray<DynamicArray>(new DynamicArray<Utf8String>(new Utf8String("b87213121fb89cbd8b877cb1bb3ff84d"), new Utf8String("b87213121fb89cbd8b877cb1bb3ff84d")), new DynamicArray<Utf8String>(new Utf8String("b87213121fb89cbd8b877cb1bb3ff84d"), new Utf8String("b87213121fb89cbd8b877cb1bb3ff84d"))))), is(1));
// string[3][3]
assertThat(Utils.getLength(Arrays.asList(new StaticArray3<StaticArray3>(new StaticArray3<Utf8String>(new Utf8String("b87213121fb89cbd8b877cb1bb3ff84d"), new Utf8String("b87213121fb89cbd8b877cb1bb3ff84d"), new Utf8String("b87213121fb89cbd8b877cb1bb3ff84d")), new StaticArray3<Utf8String>(new Utf8String("b87213121fb89cbd8b877cb1bb3ff84d"), new Utf8String("b87213121fb89cbd8b877cb1bb3ff84d"), new Utf8String("b87213121fb89cbd8b877cb1bb3ff84d")), new StaticArray3<Utf8String>(new Utf8String("b87213121fb89cbd8b877cb1bb3ff84d"), new Utf8String("b87213121fb89cbd8b877cb1bb3ff84d"), new Utf8String("b87213121fb89cbd8b877cb1bb3ff84d"))))), is(1));
// bytes[2]
assertThat(Utils.getLength(Arrays.asList(new StaticArray2<DynamicBytes>(new DynamicBytes("b87213121fb89cbd8b877cb1bb3ff84d".getBytes()), new DynamicBytes("b87213121fb89cbd8b877cb1bb3ff84d".getBytes())))), is(1));
// bytes[3]
assertThat(Utils.getLength(Arrays.asList(new StaticArray3<DynamicBytes>(new DynamicBytes("b87213121fb89cbd8b877cb1bb3ff84d".getBytes()), new DynamicBytes("b87213121fb89cbd8b877cb1bb3ff84d".getBytes()), new DynamicBytes("b87213121fb89cbd8b877cb1bb3ff84d".getBytes())))), is(1));
// bytes[]
assertThat(Utils.getLength(Arrays.asList(new DynamicArray<DynamicBytes>(new DynamicBytes("b87213121fb89cbd8b877cb1bb3ff84d".getBytes()), new DynamicBytes("b87213121fb89cbd8b877cb1bb3ff84d".getBytes()), new DynamicBytes("b87213121fb89cbd8b877cb1bb3ff84d".getBytes())))), is(1));
// bytes[][2]
assertThat(Utils.getLength(Arrays.asList(new StaticArray2<DynamicArray>(new DynamicArray<DynamicBytes>(new DynamicBytes("b87213121fb89cbd8b877cb1bb3ff84d".getBytes()), new DynamicBytes("b87213121fb89cbd8b877cb1bb3ff84d".getBytes()), new DynamicBytes("b87213121fb89cbd8b877cb1bb3ff84d".getBytes()), new DynamicBytes("b87213121fb89cbd8b877cb1bb3ff84d".getBytes()), new DynamicBytes("b87213121fb89cbd8b877cb1bb3ff84d".getBytes())), new DynamicArray<DynamicBytes>(new DynamicBytes("b87213121fb89cbd8b877cb1bb3ff84d".getBytes()), new DynamicBytes("b87213121fb89cbd8b877cb1bb3ff84d".getBytes()), new DynamicBytes("b87213121fb89cbd8b877cb1bb3ff84d".getBytes()), new DynamicBytes("b87213121fb89cbd8b877cb1bb3ff84d".getBytes()), new DynamicBytes("b87213121fb89cbd8b877cb1bb3ff84d".getBytes()))))), is(1));
// bytes[2][]
assertThat(Utils.getLength(Arrays.asList(new DynamicArray<StaticArray2>(new StaticArray2<DynamicBytes>(new DynamicBytes("b87213121fb89cbd8b877cb1bb3ff84d".getBytes()), new DynamicBytes("b87213121fb89cbd8b877cb1bb3ff84d".getBytes())), new StaticArray2<DynamicBytes>(new DynamicBytes("b87213121fb89cbd8b877cb1bb3ff84d".getBytes()), new DynamicBytes("b87213121fb89cbd8b877cb1bb3ff84d".getBytes()))))), is(1));
// bytes[][]
assertThat(Utils.getLength(Arrays.asList(new DynamicArray<DynamicArray>(new DynamicArray<DynamicBytes>(new DynamicBytes("b87213121fb89cbd8b877cb1bb3ff84d".getBytes()), new DynamicBytes("b87213121fb89cbd8b877cb1bb3ff84d".getBytes())), new DynamicArray<DynamicBytes>(new DynamicBytes("b87213121fb89cbd8b877cb1bb3ff84d".getBytes()), new DynamicBytes("b87213121fb89cbd8b877cb1bb3ff84d".getBytes()))))), is(1));
// bytes[3][3]
assertThat(Utils.getLength(Arrays.asList(new StaticArray3<StaticArray3>(new StaticArray3<DynamicBytes>(new DynamicBytes("b87213121fb89cbd8b877cb1bb3ff84d".getBytes()), new DynamicBytes("b87213121fb89cbd8b877cb1bb3ff84d".getBytes()), new DynamicBytes("b87213121fb89cbd8b877cb1bb3ff84d".getBytes())), new StaticArray3<DynamicBytes>(new DynamicBytes("b87213121fb89cbd8b877cb1bb3ff84d".getBytes()), new DynamicBytes("b87213121fb89cbd8b877cb1bb3ff84d".getBytes()), new DynamicBytes("b87213121fb89cbd8b877cb1bb3ff84d".getBytes())), new StaticArray3<DynamicBytes>(new DynamicBytes("b87213121fb89cbd8b877cb1bb3ff84d".getBytes()), new DynamicBytes("b87213121fb89cbd8b877cb1bb3ff84d".getBytes()), new DynamicBytes("b87213121fb89cbd8b877cb1bb3ff84d".getBytes()))))), is(1));
// int256
assertThat(Utils.getLength(Arrays.asList(new Int256(1))), is(1));
// uint256
assertThat(Utils.getLength(Arrays.asList(new Uint256(1))), is(1));
// int
assertThat(Utils.getLength(Arrays.asList(new Int(new BigInteger("1")))), is(1));
// uint
assertThat(Utils.getLength(Arrays.asList(new Uint(new BigInteger("1")))), is(1));
// address
assertThat(Utils.getLength(Arrays.asList(new Address("0xb87213121fb89cbd8b877cb1bb3ff84dd2869cfa"))), is(1));
// int,uint,bool,address,bytes32,bytes,string
assertThat(Utils.getLength(Arrays.asList(new Int256(1), new Uint256(1), new Bool(true), new Address("0xb87213121fb89cbd8b877cb1bb3ff84dd2869cfa"), new Bytes32("b87213121fb89cbd8b877cb1bb3ff84d".getBytes()), new DynamicBytes("aa".getBytes()), new Utf8String("bb"))), is(7));
// int[3],uint[3],bool[3],address[3],bytes32[3],bytes[3],string[3]
assertThat(Utils.getLength(Arrays.asList(new StaticArray3<Int256>(new Int256(1), new Int256(1), new Int256(1)), new StaticArray3<Uint256>(new Uint256(1), new Uint256(1), new Uint256(1)), new StaticArray3<Bool>(new Bool(true), new Bool(false), new Bool(true)), new StaticArray3<Address>(new Address("0xb87213121fb89cbd8b877cb1bb3ff84dd2869cfa"), new Address("0xb87213121fb89cbd8b877cb1bb3ff84dd2869cfa"), new Address("0xb87213121fb89cbd8b877cb1bb3ff84dd2869cfa")), new StaticArray3<Bytes32>(new Bytes32("b87213121fb89cbd8b877cb1bb3ff84d".getBytes()), new Bytes32("b87213121fb89cbd8b877cb1bb3ff84d".getBytes()), new Bytes32("b87213121fb89cbd8b877cb1bb3ff84d".getBytes())), new StaticArray3<DynamicBytes>(new DynamicBytes("aa".getBytes()), new DynamicBytes("aa".getBytes()), new DynamicBytes("aa".getBytes())), new StaticArray3<Utf8String>(new Utf8String("bb"), new Utf8String("bb"), new Utf8String("bb")))), is(17));
// int[],uint[],bool[],address[],bytes32[],bytes[],string[]
assertThat(Utils.getLength(Arrays.asList(new DynamicArray<Int256>(new Int256(1), new Int256(1), new Int256(1)), new DynamicArray<Uint256>(new Uint256(1), new Uint256(1), new Uint256(1)), new DynamicArray<Bool>(new Bool(true), new Bool(false), new Bool(true)), new DynamicArray<Address>(new Address("0xb87213121fb89cbd8b877cb1bb3ff84dd2869cfa"), new Address("0xb87213121fb89cbd8b877cb1bb3ff84dd2869cfa"), new Address("0xb87213121fb89cbd8b877cb1bb3ff84dd2869cfa")), new DynamicArray<Bytes32>(new Bytes32("b87213121fb89cbd8b877cb1bb3ff84d".getBytes()), new Bytes32("b87213121fb89cbd8b877cb1bb3ff84d".getBytes()), new Bytes32("b87213121fb89cbd8b877cb1bb3ff84d".getBytes())), new DynamicArray<DynamicBytes>(new DynamicBytes("aa".getBytes()), new DynamicBytes("aa".getBytes()), new DynamicBytes("aa".getBytes())), new DynamicArray<Utf8String>(new Utf8String("bb"), new Utf8String("bb"), new Utf8String("bb")))), is(7));
// int,uint,bool,address,bytes32,bytes,string,int[3],uint[3],bool[3],address[3],bytes32[3],bytes[3],string[3]
assertThat(Utils.getLength(Arrays.asList(new Int256(1), new Uint256(1), new Bool(true), new Address("0xb87213121fb89cbd8b877cb1bb3ff84dd2869cfa"), new Bytes32("b87213121fb89cbd8b877cb1bb3ff84d".getBytes()), new DynamicBytes("aa".getBytes()), new Utf8String("bb"), new StaticArray3<Int256>(new Int256(1), new Int256(1), new Int256(1)), new StaticArray3<Uint256>(new Uint256(1), new Uint256(1), new Uint256(1)), new StaticArray3<Bool>(new Bool(true), new Bool(false), new Bool(true)), new StaticArray3<Address>(new Address("0xb87213121fb89cbd8b877cb1bb3ff84dd2869cfa"), new Address("0xb87213121fb89cbd8b877cb1bb3ff84dd2869cfa"), new Address("0xb87213121fb89cbd8b877cb1bb3ff84dd2869cfa")), new StaticArray3<Bytes32>(new Bytes32("b87213121fb89cbd8b877cb1bb3ff84d".getBytes()), new Bytes32("b87213121fb89cbd8b877cb1bb3ff84d".getBytes()), new Bytes32("b87213121fb89cbd8b877cb1bb3ff84d".getBytes())), new StaticArray3<DynamicBytes>(new DynamicBytes("aa".getBytes()), new DynamicBytes("aa".getBytes()), new DynamicBytes("aa".getBytes())), new StaticArray3<Utf8String>(new Utf8String("bb"), new Utf8String("bb"), new Utf8String("bb")))), is(24));
// int,uint,bool,address,bytes32,bytes,string,int[],uint[],bool[],address[],bytes32[],bytes[],string[]
assertThat(Utils.getLength(Arrays.asList(new Int256(1), new Uint256(1), new Bool(true), new Address("0xb87213121fb89cbd8b877cb1bb3ff84dd2869cfa"), new Bytes32("b87213121fb89cbd8b877cb1bb3ff84d".getBytes()), new DynamicBytes("aa".getBytes()), new Utf8String("bb"), new DynamicArray<Int256>(new Int256(1), new Int256(1), new Int256(1)), new DynamicArray<Uint256>(new Uint256(1), new Uint256(1), new Uint256(1)), new DynamicArray<Bool>(new Bool(true), new Bool(false), new Bool(true)), new DynamicArray<Address>(new Address("0xb87213121fb89cbd8b877cb1bb3ff84dd2869cfa"), new Address("0xb87213121fb89cbd8b877cb1bb3ff84dd2869cfa"), new Address("0xb87213121fb89cbd8b877cb1bb3ff84dd2869cfa")), new DynamicArray<Bytes32>(new Bytes32("b87213121fb89cbd8b877cb1bb3ff84d".getBytes()), new Bytes32("b87213121fb89cbd8b877cb1bb3ff84d".getBytes()), new Bytes32("b87213121fb89cbd8b877cb1bb3ff84d".getBytes())), new DynamicArray<DynamicBytes>(new DynamicBytes("aa".getBytes()), new DynamicBytes("aa".getBytes()), new DynamicBytes("aa".getBytes())), new DynamicArray<Utf8String>(new Utf8String("bb"), new Utf8String("bb"), new Utf8String("bb")))), is(14));
// uint256[][2],uint256[2][],uint256[][],uint256[2][2]
assertThat(Utils.getLength(Arrays.asList(new StaticArray2<DynamicArray>(new DynamicArray<Uint256>(new Uint256(1), new Uint256(1), new Uint256(1), new Uint256(1), new Uint256(1)), new DynamicArray<Uint256>(new Uint256(1), new Uint256(1), new Uint256(1), new Uint256(1), new Uint256(1))), new DynamicArray<StaticArray2>(new StaticArray2<Uint256>(new Uint256(1), new Uint256(1)), new StaticArray2<Uint256>(new Uint256(1), new Uint256(1))), new DynamicArray<DynamicArray>(new DynamicArray<Uint256>(new Uint256(1), new Uint256(1)), new DynamicArray<Uint256>(new Uint256(1), new Uint256(1))), new StaticArray2<StaticArray2>(new StaticArray2<Uint256>(new Uint256(1), new Uint256(1)), new StaticArray2<Uint256>(new Uint256(1), new Uint256(1))))), is(7));
// int256[][2],int256[2][],int256[][],int256[2][2]
assertThat(Utils.getLength(Arrays.asList(new StaticArray2<DynamicArray>(new DynamicArray<Int256>(new Int256(1), new Int256(1), new Int256(1), new Int256(1), new Int256(1)), new DynamicArray<Int256>(new Int256(1), new Int256(1), new Int256(1), new Int256(1), new Int256(1))), new DynamicArray<StaticArray2>(new StaticArray2<Int256>(new Int256(1), new Int256(1)), new StaticArray2<Int256>(new Int256(1), new Int256(1))), new DynamicArray<DynamicArray>(new DynamicArray<Int256>(new Int256(1), new Int256(1)), new DynamicArray<Int256>(new Int256(1), new Int256(1))), new StaticArray2<StaticArray2>(new StaticArray2<Int256>(new Int256(1), new Int256(1)), new StaticArray2<Int256>(new Int256(1), new Int256(1))))), is(7));
// string[][2],string[2][],string[][],string[3][3]
assertThat(Utils.getLength(Arrays.asList(new StaticArray2<DynamicArray>(new DynamicArray<Utf8String>(new Utf8String("b87213121fb89cbd8b877cb1bb3ff84d"), new Utf8String("b87213121fb89cbd8b877cb1bb3ff84d"), new Utf8String("b87213121fb89cbd8b877cb1bb3ff84d"), new Utf8String("b87213121fb89cbd8b877cb1bb3ff84d"), new Utf8String("b87213121fb89cbd8b877cb1bb3ff84d")), new DynamicArray<Utf8String>(new Utf8String("b87213121fb89cbd8b877cb1bb3ff84d"), new Utf8String("b87213121fb89cbd8b877cb1bb3ff84d"), new Utf8String("b87213121fb89cbd8b877cb1bb3ff84d"), new Utf8String("b87213121fb89cbd8b877cb1bb3ff84d"), new Utf8String("b87213121fb89cbd8b877cb1bb3ff84d"))), new DynamicArray<StaticArray2>(new StaticArray2<Utf8String>(new Utf8String("b87213121fb89cbd8b877cb1bb3ff84d"), new Utf8String("b87213121fb89cbd8b877cb1bb3ff84d")), new StaticArray2<Utf8String>(new Utf8String("b87213121fb89cbd8b877cb1bb3ff84d"), new Utf8String("b87213121fb89cbd8b877cb1bb3ff84d"))), new DynamicArray<DynamicArray>(new DynamicArray<Utf8String>(new Utf8String("b87213121fb89cbd8b877cb1bb3ff84d"), new Utf8String("b87213121fb89cbd8b877cb1bb3ff84d")), new DynamicArray<Utf8String>(new Utf8String("b87213121fb89cbd8b877cb1bb3ff84d"), new Utf8String("b87213121fb89cbd8b877cb1bb3ff84d"))), new StaticArray3<StaticArray3>(new StaticArray3<Utf8String>(new Utf8String("b87213121fb89cbd8b877cb1bb3ff84d"), new Utf8String("b87213121fb89cbd8b877cb1bb3ff84d"), new Utf8String("b87213121fb89cbd8b877cb1bb3ff84d")), new StaticArray3<Utf8String>(new Utf8String("b87213121fb89cbd8b877cb1bb3ff84d"), new Utf8String("b87213121fb89cbd8b877cb1bb3ff84d"), new Utf8String("b87213121fb89cbd8b877cb1bb3ff84d")), new StaticArray3<Utf8String>(new Utf8String("b87213121fb89cbd8b877cb1bb3ff84d"), new Utf8String("b87213121fb89cbd8b877cb1bb3ff84d"), new Utf8String("b87213121fb89cbd8b877cb1bb3ff84d"))))), is(4));
// bytes[][2],bytes[2][],bytes[][],bytes[2][2]
assertThat(Utils.getLength(Arrays.asList(new StaticArray2<DynamicArray>(new DynamicArray<DynamicBytes>(new DynamicBytes("b87213121fb89cbd8b877cb1bb3ff84d".getBytes()), new DynamicBytes("b87213121fb89cbd8b877cb1bb3ff84d".getBytes()), new DynamicBytes("b87213121fb89cbd8b877cb1bb3ff84d".getBytes()), new DynamicBytes("b87213121fb89cbd8b877cb1bb3ff84d".getBytes()), new DynamicBytes("b87213121fb89cbd8b877cb1bb3ff84d".getBytes())), new DynamicArray<DynamicBytes>(new DynamicBytes("b87213121fb89cbd8b877cb1bb3ff84d".getBytes()), new DynamicBytes("b87213121fb89cbd8b877cb1bb3ff84d".getBytes()), new DynamicBytes("b87213121fb89cbd8b877cb1bb3ff84d".getBytes()), new DynamicBytes("b87213121fb89cbd8b877cb1bb3ff84d".getBytes()), new DynamicBytes("b87213121fb89cbd8b877cb1bb3ff84d".getBytes()))), new DynamicArray<StaticArray2>(new StaticArray2<DynamicBytes>(new DynamicBytes("b87213121fb89cbd8b877cb1bb3ff84d".getBytes()), new DynamicBytes("b87213121fb89cbd8b877cb1bb3ff84d".getBytes())), new StaticArray2<DynamicBytes>(new DynamicBytes("b87213121fb89cbd8b877cb1bb3ff84d".getBytes()), new DynamicBytes("b87213121fb89cbd8b877cb1bb3ff84d".getBytes()))), new DynamicArray<DynamicArray>(new DynamicArray<DynamicBytes>(new DynamicBytes("b87213121fb89cbd8b877cb1bb3ff84d".getBytes()), new DynamicBytes("b87213121fb89cbd8b877cb1bb3ff84d".getBytes())), new DynamicArray<DynamicBytes>(new DynamicBytes("b87213121fb89cbd8b877cb1bb3ff84d".getBytes()), new DynamicBytes("b87213121fb89cbd8b877cb1bb3ff84d".getBytes()))), new StaticArray3<StaticArray3>(new StaticArray3<DynamicBytes>(new DynamicBytes("b87213121fb89cbd8b877cb1bb3ff84d".getBytes()), new DynamicBytes("b87213121fb89cbd8b877cb1bb3ff84d".getBytes()), new DynamicBytes("b87213121fb89cbd8b877cb1bb3ff84d".getBytes())), new StaticArray3<DynamicBytes>(new DynamicBytes("b87213121fb89cbd8b877cb1bb3ff84d".getBytes()), new DynamicBytes("b87213121fb89cbd8b877cb1bb3ff84d".getBytes()), new DynamicBytes("b87213121fb89cbd8b877cb1bb3ff84d".getBytes())), new StaticArray3<DynamicBytes>(new DynamicBytes("b87213121fb89cbd8b877cb1bb3ff84d".getBytes()), new DynamicBytes("b87213121fb89cbd8b877cb1bb3ff84d".getBytes()), new DynamicBytes("b87213121fb89cbd8b877cb1bb3ff84d".getBytes()))))), is(4));
}
use of org.fisco.bcos.web3j.abi.datatypes.generated.StaticArray2 in project web3sdk by FISCO-BCOS.
the class CallContractTest method testSyncCallContract.
private static void testSyncCallContract(CallContract callContract, String address) {
CallResult contractResult;
contractResult = callContract.call(address, "getStringOld", new Utf8String("hello world"), new Int256(10086), new Bool(true));
List<TypeReference<?>> referencesList = Arrays.<TypeReference<?>>asList(new TypeReference<Utf8String>() {
});
List<Type> returnList1 = FunctionReturnDecoder.decode(contractResult.getOutput(), Utils.convert(referencesList));
System.out.println("call getStringOld: " + (String) returnList1.get(0).getValue());
TransactionReceipt receipt;
receipt = callContract.sendTransaction(gasPrice, gasLimit, address, "setAndget", new Utf8String("hello world"), new Int256(10086));
referencesList = Arrays.<TypeReference<?>>asList(new TypeReference<Utf8String>() {
}, new TypeReference<Int256>() {
});
List<Type> returnList2 = FunctionReturnDecoder.decode(receipt.getOutput(), Utils.convert(referencesList));
System.out.println("call setAndget: " + (String) returnList2.get(0).getValue() + ", " + (BigInteger) returnList2.get(1).getValue());
receipt = callContract.sendTransaction(address, "setAndget", new Utf8String("hello world"), new Int256(10086));
referencesList = Arrays.<TypeReference<?>>asList(new TypeReference<Utf8String>() {
}, new TypeReference<Int256>() {
});
List<Type> returnList3 = FunctionReturnDecoder.decode(receipt.getOutput(), Utils.convert(referencesList));
System.out.println("default call setAndget: " + (String) returnList3.get(0).getValue() + ", " + (BigInteger) returnList3.get(1).getValue());
contractResult = callContract.call(address, "getArray", new StaticArray2(typeMap(Arrays.asList(BigInteger.valueOf(-1), BigInteger.valueOf(2)), Int16.class)), new DynamicArray(typeMap(Arrays.asList(BigInteger.valueOf(2), BigInteger.valueOf(2)), Uint16.class)));
List<Type> returnList4 = callContract.decode(contractResult.getOutput(), new TypeReference<StaticArray2<Int16>>() {
}, new TypeReference<DynamicArray<Int16>>() {
});
System.out.println("call getArray: " + callContract.convertList((List<Type>) returnList4.get(0).getValue()) + ", " + callContract.convertList((List<Type>) returnList4.get(1).getValue()));
List<List<BigInteger>> dyadicArray = new ArrayList<List<BigInteger>>();
dyadicArray.add(Arrays.asList(BigInteger.valueOf(-1), BigInteger.valueOf(2)));
dyadicArray.add(Arrays.asList(BigInteger.valueOf(-1), BigInteger.valueOf(992)));
byte[] bytes = new byte[] { 'a', 'b' };
contractResult = callContract.call(address, "newTest", new StaticArray2(typeMap(dyadicArray, StaticArray2.class, Int256.class)), new DynamicBytes(bytes));
List<Type> returnList5 = callContract.decode(contractResult.getOutput(), new TypeReference<StaticArray2<StaticArray2<Int256>>>() {
}, new TypeReference<DynamicBytes>() {
});
System.out.println("call newTest: " + callContract.convertListList((List<StaticArray<Int256>>) returnList5.get(0).getValue()) + ", " + new String((byte[]) returnList5.get(1).getValue()) + ", " + dyadicArray);
}
use of org.fisco.bcos.web3j.abi.datatypes.generated.StaticArray2 in project web3sdk by FISCO-BCOS.
the class TypeTest method dynamicOffsetTest.
@Test
public void dynamicOffsetTest() {
// bool
assertThat(new Bool(true).offset(), is(1));
// bool
assertThat(new Bool(false).offset(), is(1));
assertThat(new Address("0xb87213121fb89cbd8b877cb1bb3ff84dd2869cfa").offset(), // address
is(1));
// string
assertThat(new Utf8String("").offset(), is(1));
// string
assertThat(new Utf8String("abcdef").offset(), is(1));
// bytes10
assertThat(new Bytes10("0123456789".getBytes()).offset(), is(1));
// bytes3
assertThat(new Bytes3("abc".getBytes()).offset(), is(1));
// bytes1
assertThat(new Bytes1("a".getBytes()).offset(), is(1));
// uint256
assertThat(new Uint256(1).offset(), is(1));
// int256
assertThat(new Int256(1).offset(), is(1));
// bytes
assertThat(new DynamicBytes("".getBytes()).offset(), is(1));
// bytes
assertThat(new DynamicBytes("abc".getBytes()).offset(), is(1));
// bool[1]
assertThat(new StaticArray1<Bool>(new Bool(true)).offset(), is(1));
assertThat(new StaticArray3<Bool>(new Bool(true), new Bool(true), new Bool(true)).offset(), // bool[3]
is(3));
assertThat(new DynamicArray<Bool>(new Bool(true), new Bool(true), new Bool(true), new Bool(true)).offset(), // bool[]
is(1));
assertThat(new DynamicArray<DynamicArray<Bool>>(new DynamicArray<Bool>(new Bool(true), new Bool(true), new Bool(true))).offset(), // bool[][]
is(1));
assertThat(new StaticArray2<DynamicArray<Bool>>(new DynamicArray<Bool>(new Bool(true)), new DynamicArray<Bool>(new Bool(true))).offset(), // bool[][2]
is(1));
assertThat(new DynamicArray<StaticArray2<Bool>>(new StaticArray2<Bool>(new Bool(true), new Bool(true)), new StaticArray2<Bool>(new Bool(true), new Bool(true))).offset(), // bool[1][]
is(1));
assertThat(new StaticArray2<StaticArray2<Bool>>(new StaticArray2<Bool>(new Bool(true), new Bool(true)), new StaticArray2<Bool>(new Bool(true), new Bool(true))).offset(), // bool[2][2]
is(4));
// uint256[1]
assertThat(new StaticArray1<Uint256>(new Uint256(1)).offset(), is(1));
assertThat(new DynamicArray<Uint256>(new Uint256(1), new Uint256(1)).offset(), // uint256[]
is(1));
assertThat(new DynamicArray<DynamicArray<Uint256>>(new DynamicArray<Uint256>(new Uint256(1), new Uint256(1)), new DynamicArray<Uint256>(new Uint256(1), new Uint256(1))).offset(), // uint256[][]
is(1));
assertThat(new StaticArray2<DynamicArray<Uint256>>(new DynamicArray<Uint256>(new Uint256(1)), new DynamicArray<Uint256>(new Uint256(1))).offset(), // uint256[][2]
is(1));
assertThat(new DynamicArray<StaticArray2<Uint256>>(new StaticArray2<Uint256>(new Uint256(1), new Uint256(1))).offset(), // uint256[2][]
is(1));
assertThat(new StaticArray2<StaticArray2<Uint256>>(new StaticArray2<Uint256>(new Uint256(1), new Uint256(1)), new StaticArray2<Uint256>(new Uint256(1), new Uint256(1))).offset(), // uint256[2][2]
is(4));
// int256[1]
assertThat(new StaticArray1<Int256>(new Int256(1)).offset(), is(1));
// int256[]
assertThat(new DynamicArray<Int256>(new Int256(1)).offset(), is(1));
assertThat(new DynamicArray<DynamicArray<Int256>>(new DynamicArray<Int256>(new Int256(1), new Int256(1)), new DynamicArray<Int256>(new Int256(1), new Int256(1))).offset(), // int256[][]
is(1));
assertThat(new StaticArray2<DynamicArray<Int256>>(new DynamicArray<Int256>(new Int256(1)), new DynamicArray<Int256>(new Int256(1))).offset(), // int256[][2]
is(1));
assertThat(new DynamicArray<StaticArray2<Int256>>(new StaticArray2<Int256>(new Int256(1), new Int256(1))).offset(), // int256[2][]
is(1));
assertThat(new StaticArray2<StaticArray2<Int256>>(new StaticArray2<Int256>(new Int256(1), new Int256(1)), new StaticArray2<Int256>(new Int256(1), new Int256(1))).offset(), // int256[2][2]
is(4));
assertThat(new StaticArray1<Address>(new Address("0xb87213121fb89cbd8b877cb1bb3ff84dd2869cfa")).offset(), // address[1]
is(1));
assertThat(new DynamicArray<Address>(new Address("0xb87213121fb89cbd8b877cb1bb3ff84dd2869cfa")).offset(), // address[]
is(1));
assertThat(new DynamicArray<DynamicArray<Address>>(new DynamicArray<Address>(new Address("0xb87213121fb89cbd8b877cb1bb3ff84dd2869cfa"), new Address("0xb87213121fb89cbd8b877cb1bb3ff84dd2869cfa")), new DynamicArray<Address>(new Address("0xb87213121fb89cbd8b877cb1bb3ff84dd2869cfa"), new Address("0xb87213121fb89cbd8b877cb1bb3ff84dd2869cfa"))).offset(), // address[][]
is(1));
assertThat(new StaticArray2<DynamicArray<Address>>(new DynamicArray<Address>(new Address("0xb87213121fb89cbd8b877cb1bb3ff84dd2869cfa")), new DynamicArray<Address>(new Address("0xb87213121fb89cbd8b877cb1bb3ff84dd2869cfa"))).offset(), // address[][2]
is(1));
assertThat(new DynamicArray<StaticArray2<Address>>(new StaticArray2<Address>(new Address("0xb87213121fb89cbd8b877cb1bb3ff84dd2869cfa"), new Address("0xb87213121fb89cbd8b877cb1bb3ff84dd2869cfa"))).offset(), // address[2][]
is(1));
assertThat(new StaticArray2<StaticArray2<Address>>(new StaticArray2<Address>(new Address("0xb87213121fb89cbd8b877cb1bb3ff84dd2869cfa"), new Address("0xb87213121fb89cbd8b877cb1bb3ff84dd2869cfa")), new StaticArray2<Address>(new Address("0xb87213121fb89cbd8b877cb1bb3ff84dd2869cfa"), new Address("0xb87213121fb89cbd8b877cb1bb3ff84dd2869cfa"))).offset(), // address[2][2]
is(4));
// string[1]
assertThat(new StaticArray1<Utf8String>(new Utf8String("")).offset(), is(1));
// string[]
assertThat(new DynamicArray<Utf8String>(new Utf8String("")).offset(), is(1));
assertThat(new DynamicArray<DynamicArray<Utf8String>>(new DynamicArray<Utf8String>(new Utf8String("0xb87213121fb89cbd8b877cb1bb3ff84dd2869cfa"))).offset(), // string[][]
is(1));
assertThat(new StaticArray2<DynamicArray<Utf8String>>(new DynamicArray<Utf8String>(new Utf8String("0xb87213121fb89cbd8b877cb1bb3ff84dd2869cfa")), new DynamicArray<Utf8String>(new Utf8String("0xb87213121fb89cbd8b877cb1bb3ff84dd2869cfa"))).offset(), // string[][2]
is(1));
assertThat(new DynamicArray<StaticArray2<Utf8String>>(new StaticArray2<Utf8String>(new Utf8String("0xb87213121fb89cbd8b877cb1bb3ff84dd2869cfa"), new Utf8String("0xb87213121fb89cbd8b877cb1bb3ff84dd2869cfa"))).offset(), // string[2][]
is(1));
assertThat(new StaticArray2<StaticArray2<Utf8String>>(new StaticArray2<Utf8String>(new Utf8String("0xb87213121fb89cbd8b877cb1bb3ff84dd2869cfa"), new Utf8String("0xb87213121fb89cbd8b877cb1bb3ff84dd2869cfa")), new StaticArray2<Utf8String>(new Utf8String("0xb87213121fb89cbd8b877cb1bb3ff84dd2869cfa"), new Utf8String("0xb87213121fb89cbd8b877cb1bb3ff84dd2869cfa"))).offset(), // string[2][2]
is(1));
assertThat(new StaticArray1<DynamicBytes>(new DynamicBytes("aa".getBytes())).offset(), // bytes[1]
is(1));
assertThat(new DynamicArray<DynamicBytes>(new DynamicBytes("".getBytes())).offset(), // bytes[]
is(1));
assertThat(new DynamicArray<DynamicArray<DynamicBytes>>(new DynamicArray<DynamicBytes>(new DynamicBytes("0xb87213121fb89cbd8b877cb1bb3ff84dd2869cfa".getBytes()))).offset(), // bytes[][]
is(1));
assertThat(new StaticArray2<DynamicArray<DynamicBytes>>(new DynamicArray<DynamicBytes>(new DynamicBytes("0xb87213121fb89cbd8b877cb1bb3ff84dd2869cfa".getBytes()), new DynamicBytes("0xb87213121fb89cbd8b877cb1bb3ff84dd2869cfa".getBytes())), new DynamicArray<DynamicBytes>(new DynamicBytes("0xb87213121fb89cbd8b877cb1bb3ff84dd2869cfa".getBytes()), new DynamicBytes("0xb87213121fb89cbd8b877cb1bb3ff84dd2869cfa".getBytes()))).offset(), // bytes[][2]
is(1));
assertThat(new DynamicArray<StaticArray2<DynamicBytes>>(new StaticArray2<DynamicBytes>(new DynamicBytes("0xb87213121fb89cbd8b877cb1bb3ff84dd2869cfa".getBytes()), new DynamicBytes("0xb87213121fb89cbd8b877cb1bb3ff84dd2869cfa".getBytes())), new StaticArray2<DynamicBytes>(new DynamicBytes("0xb87213121fb89cbd8b877cb1bb3ff84dd2869cfa".getBytes()), new DynamicBytes("0xb87213121fb89cbd8b877cb1bb3ff84dd2869cfa".getBytes()))).offset(), // bytes21][]
is(1));
assertThat(new StaticArray2<StaticArray2<DynamicBytes>>(new StaticArray2<DynamicBytes>(new DynamicBytes("0xb87213121fb89cbd8b877cb1bb3ff84dd2869cfa".getBytes()), new DynamicBytes("0xb87213121fb89cbd8b877cb1bb3ff84dd2869cfa".getBytes())), new StaticArray2<DynamicBytes>(new DynamicBytes("0xb87213121fb89cbd8b877cb1bb3ff84dd2869cfa".getBytes()), new DynamicBytes("0xb87213121fb89cbd8b877cb1bb3ff84dd2869cfa".getBytes()))).offset(), // bytes[2][2]
is(1));
}
use of org.fisco.bcos.web3j.abi.datatypes.generated.StaticArray2 in project web3sdk by FISCO-BCOS.
the class UtilsTest method testTypeMapNested.
@Test
public void testTypeMapNested() {
List<BigInteger> innerList1 = Arrays.asList(BigInteger.valueOf(1), BigInteger.valueOf(2));
List<BigInteger> innerList2 = Arrays.asList(BigInteger.valueOf(3), BigInteger.valueOf(4));
final List<List<BigInteger>> input = Arrays.asList(innerList1, innerList2);
StaticArray2<Uint256> staticArray1 = new StaticArray2<>(new Uint256(1), new Uint256(2));
StaticArray2<Uint256> staticArray2 = new StaticArray2<>(new Uint256(3), new Uint256(4));
List<StaticArray2<Uint256>> expectedList = Arrays.asList(staticArray1, staticArray2);
assertThat(Utils.typeMap(input, StaticArray2.class, Uint256.class), equalTo(expectedList));
}
Aggregations