Search in sources :

Example 11 with DynamicArray

use of org.fisco.bcos.web3j.abi.datatypes.DynamicArray in project web3sdk by FISCO-BCOS.

the class TypeTest method dynamicTest.

@Test
public void dynamicTest() {
    // bool
    assertThat(new Bool(true).dynamicType(), is(false));
    // bool
    assertThat(new Bool(false).dynamicType(), is(false));
    assertThat(new Address("0xb87213121fb89cbd8b877cb1bb3ff84dd2869cfa").dynamicType(), // address
    is(false));
    // string
    assertThat(new Utf8String("").dynamicType(), is(true));
    // string
    assertThat(new Utf8String("abcdef").dynamicType(), is(true));
    // bytes10
    assertThat(new Bytes10("0123456789".getBytes()).dynamicType(), is(false));
    // bytes3
    assertThat(new Bytes3("abc".getBytes()).dynamicType(), is(false));
    // bytes1
    assertThat(new Bytes1("a".getBytes()).dynamicType(), is(false));
    // uint256
    assertThat(new Uint256(1).dynamicType(), is(false));
    // int256
    assertThat(new Int256(1).dynamicType(), is(false));
    // bytes
    assertThat(new DynamicBytes("".getBytes()).dynamicType(), is(true));
    // bytes
    assertThat(new DynamicBytes("abc".getBytes()).dynamicType(), is(true));
    // bool[1]
    assertThat(new StaticArray1<Bool>(new Bool(true)).dynamicType(), is(false));
    // bool[]
    assertThat(new DynamicArray<Bool>(new Bool(true)).dynamicType(), is(true));
    assertThat(new DynamicArray<DynamicArray<Bool>>(new DynamicArray<Bool>(new Bool(true))).dynamicType(), // bool[][]
    is(true));
    assertThat(new StaticArray1<DynamicArray<Bool>>(new DynamicArray<Bool>(new Bool(true))).dynamicType(), // bool[][1]
    is(true));
    assertThat(new DynamicArray<StaticArray1<Bool>>(new StaticArray1<Bool>(new Bool(true))).dynamicType(), // bool[1][]
    is(true));
    assertThat(new StaticArray1<StaticArray1<Bool>>(new StaticArray1<Bool>(new Bool(true))).dynamicType(), // bool[1][1]
    is(false));
    assertThat(new StaticArray1<Uint256>(new Uint256(1)).dynamicType(), // uint256[1]
    is(false));
    assertThat(new DynamicArray<Uint256>(new Uint256(1), new Uint256(1)).dynamicType(), // uint256[]
    is(true));
    assertThat(new DynamicArray<DynamicArray<Uint256>>(new DynamicArray<Uint256>(new Uint256(1))).dynamicType(), // uint256[][]
    is(true));
    assertThat(new StaticArray1<DynamicArray<Uint256>>(new DynamicArray<Uint256>(new Uint256(1))).dynamicType(), // uint256[][1]
    is(true));
    assertThat(new DynamicArray<StaticArray1<Uint256>>(new StaticArray1<Uint256>(new Uint256(1))).dynamicType(), // uint256[1][]
    is(true));
    assertThat(new StaticArray1<StaticArray1<Uint256>>(new StaticArray1<Uint256>(new Uint256(1))).dynamicType(), // uint256[1][1]
    is(false));
    // int256[1]
    assertThat(new StaticArray1<Int256>(new Int256(1)).dynamicType(), is(false));
    // int256[]
    assertThat(new DynamicArray<Int256>(new Int256(1)).dynamicType(), is(true));
    assertThat(new DynamicArray<DynamicArray<Int256>>(new DynamicArray<Int256>(new Int256(1))).dynamicType(), // int256[][]
    is(true));
    assertThat(new StaticArray1<DynamicArray<Int256>>(new DynamicArray<Int256>(new Int256(1))).dynamicType(), // int256[][1]
    is(true));
    assertThat(new DynamicArray<StaticArray1<Int256>>(new StaticArray1<Int256>(new Int256(1))).dynamicType(), // int256[1][]
    is(true));
    assertThat(new StaticArray1<StaticArray1<Int256>>(new StaticArray1<Int256>(new Int256(1))).dynamicType(), // int256[1][1]
    is(false));
    assertThat(new StaticArray1<Address>(new Address("0xb87213121fb89cbd8b877cb1bb3ff84dd2869cfa")).dynamicType(), // address[1]
    is(false));
    assertThat(new DynamicArray<Address>(new Address("0xb87213121fb89cbd8b877cb1bb3ff84dd2869cfa")).dynamicType(), // address[]
    is(true));
    assertThat(new DynamicArray<DynamicArray<Address>>(new DynamicArray<Address>(new Address("0xb87213121fb89cbd8b877cb1bb3ff84dd2869cfa"))).dynamicType(), // address[][]
    is(true));
    assertThat(new StaticArray1<DynamicArray<Address>>(new DynamicArray<Address>(new Address("0xb87213121fb89cbd8b877cb1bb3ff84dd2869cfa"))).dynamicType(), // address[][1]
    is(true));
    assertThat(new DynamicArray<StaticArray1<Address>>(new StaticArray1<Address>(new Address("0xb87213121fb89cbd8b877cb1bb3ff84dd2869cfa"))).dynamicType(), // address[1][]
    is(true));
    assertThat(new StaticArray1<StaticArray1<Address>>(new StaticArray1<Address>(new Address("0xb87213121fb89cbd8b877cb1bb3ff84dd2869cfa"))).dynamicType(), // address[1][1]
    is(false));
    assertThat(new StaticArray1<Utf8String>(new Utf8String("")).dynamicType(), // string[1]
    is(true));
    assertThat(new DynamicArray<Utf8String>(new Utf8String("")).dynamicType(), // string[]
    is(true));
    assertThat(new DynamicArray<DynamicArray<Utf8String>>(new DynamicArray<Utf8String>(new Utf8String("0xb87213121fb89cbd8b877cb1bb3ff84dd2869cfa"))).dynamicType(), // string[][]
    is(true));
    assertThat(new StaticArray1<DynamicArray<Utf8String>>(new DynamicArray<Utf8String>(new Utf8String("0xb87213121fb89cbd8b877cb1bb3ff84dd2869cfa"))).dynamicType(), // string[][1]
    is(true));
    assertThat(new DynamicArray<StaticArray1<Utf8String>>(new StaticArray1<Utf8String>(new Utf8String("0xb87213121fb89cbd8b877cb1bb3ff84dd2869cfa"))).dynamicType(), // string[1][]
    is(true));
    assertThat(new StaticArray1<StaticArray1<Utf8String>>(new StaticArray1<Utf8String>(new Utf8String("0xb87213121fb89cbd8b877cb1bb3ff84dd2869cfa"))).dynamicType(), // string[1][1]
    is(true));
    assertThat(new StaticArray1<DynamicBytes>(new DynamicBytes("aa".getBytes())).dynamicType(), // bytes[1]
    is(true));
    assertThat(new DynamicArray<DynamicBytes>(new DynamicBytes("".getBytes())).dynamicType(), // bytes[]
    is(true));
    assertThat(new DynamicArray<DynamicArray<DynamicBytes>>(new DynamicArray<DynamicBytes>(new DynamicBytes("0xb87213121fb89cbd8b877cb1bb3ff84dd2869cfa".getBytes()))).dynamicType(), // bytes[][]
    is(true));
    assertThat(new StaticArray1<DynamicArray<DynamicBytes>>(new DynamicArray<DynamicBytes>(new DynamicBytes("0xb87213121fb89cbd8b877cb1bb3ff84dd2869cfa".getBytes()))).dynamicType(), // bytes[][1]
    is(true));
    assertThat(new DynamicArray<StaticArray1<DynamicBytes>>(new StaticArray1<DynamicBytes>(new DynamicBytes("0xb87213121fb89cbd8b877cb1bb3ff84dd2869cfa".getBytes()))).dynamicType(), // bytes[1][]
    is(true));
    assertThat(new StaticArray1<StaticArray1<DynamicBytes>>(new StaticArray1<DynamicBytes>(new DynamicBytes("0xb87213121fb89cbd8b877cb1bb3ff84dd2869cfa".getBytes()))).dynamicType(), // bytes[1][1]
    is(true));
}
Also used : Address(org.fisco.bcos.web3j.abi.datatypes.Address) Bytes10(org.fisco.bcos.web3j.abi.datatypes.generated.Bytes10) Utf8String(org.fisco.bcos.web3j.abi.datatypes.Utf8String) Int256(org.fisco.bcos.web3j.abi.datatypes.generated.Int256) DynamicBytes(org.fisco.bcos.web3j.abi.datatypes.DynamicBytes) Bool(org.fisco.bcos.web3j.abi.datatypes.Bool) DynamicArray(org.fisco.bcos.web3j.abi.datatypes.DynamicArray) Bytes3(org.fisco.bcos.web3j.abi.datatypes.generated.Bytes3) Bytes1(org.fisco.bcos.web3j.abi.datatypes.generated.Bytes1) Uint256(org.fisco.bcos.web3j.abi.datatypes.generated.Uint256) StaticArray1(org.fisco.bcos.web3j.abi.datatypes.generated.StaticArray1) Test(org.junit.Test)

Aggregations

DynamicArray (org.fisco.bcos.web3j.abi.datatypes.DynamicArray)11 Utf8String (org.fisco.bcos.web3j.abi.datatypes.Utf8String)10 Test (org.junit.Test)8 Bool (org.fisco.bcos.web3j.abi.datatypes.Bool)7 DynamicBytes (org.fisco.bcos.web3j.abi.datatypes.DynamicBytes)7 Int256 (org.fisco.bcos.web3j.abi.datatypes.generated.Int256)7 Address (org.fisco.bcos.web3j.abi.datatypes.Address)6 Event (org.fisco.bcos.web3j.abi.datatypes.Event)6 Uint256 (org.fisco.bcos.web3j.abi.datatypes.generated.Uint256)6 ArrayList (java.util.ArrayList)5 TypeReference (org.fisco.bcos.web3j.abi.TypeReference)5 Type (org.fisco.bcos.web3j.abi.datatypes.Type)5 List (java.util.List)4 Bytes32 (org.fisco.bcos.web3j.abi.datatypes.generated.Bytes32)4 NamedType (org.fisco.bcos.web3j.protocol.core.methods.response.AbiDefinition.NamedType)3 Log (org.fisco.bcos.web3j.protocol.core.methods.response.Log)3 BigInteger (java.math.BigInteger)2 StaticArray (org.fisco.bcos.web3j.abi.datatypes.StaticArray)2 Bytes1 (org.fisco.bcos.web3j.abi.datatypes.generated.Bytes1)2 Bytes10 (org.fisco.bcos.web3j.abi.datatypes.generated.Bytes10)2