use of org.fisco.bcos.web3j.abi.datatypes.generated.Int256 in project web3sdk by FISCO-BCOS.
the class TransactionDecoderTest method testStaticParams0.
@Test
public void testStaticParams0() throws JsonProcessingException, TransactionException, BaseException {
/*
function test(uint256[4] _u,int256[4] _i,bool[4] _b,address[4] _addr,bytes32[4] _bs32,string[4] _s,bytes[4] _bs) public constant returns (uint256[2],int256[2],bool[2],address[2],bytes32[2],string[2],bytes[2]) {
}
*/
TransactionDecoder decode = TransactionDecoderFactory.buildTransactionDecoder("[{\"constant\":true,\"inputs\":[{\"name\":\"_u\",\"type\":\"uint256[4]\"},{\"name\":\"_i\",\"type\":\"int256[4]\"},{\"name\":\"_b\",\"type\":\"bool[4]\"},{\"name\":\"_addr\",\"type\":\"address[4]\"},{\"name\":\"_bs32\",\"type\":\"bytes32[4]\"},{\"name\":\"_s\",\"type\":\"string[4]\"},{\"name\":\"_bs\",\"type\":\"bytes[4]\"}],\"name\":\"test\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256[2]\"},{\"name\":\"\",\"type\":\"int256[2]\"},{\"name\":\"\",\"type\":\"bool[2]\"},{\"name\":\"\",\"type\":\"address[2]\"},{\"name\":\"\",\"type\":\"bytes32[2]\"},{\"name\":\"\",\"type\":\"string[2]\"},{\"name\":\"\",\"type\":\"bytes[2]\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_u\",\"type\":\"uint256\"},{\"name\":\"_i\",\"type\":\"int256\"},{\"name\":\"_b\",\"type\":\"bool\"},{\"name\":\"_addr\",\"type\":\"address\"},{\"name\":\"_bs32\",\"type\":\"bytes32\"},{\"name\":\"_s\",\"type\":\"string\"},{\"name\":\"_bs\",\"type\":\"bytes\"}],\"name\":\"test\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"},{\"name\":\"\",\"type\":\"int256\"},{\"name\":\"\",\"type\":\"bool\"},{\"name\":\"\",\"type\":\"address\"},{\"name\":\"\",\"type\":\"bytes32\"},{\"name\":\"\",\"type\":\"string\"},{\"name\":\"\",\"type\":\"bytes\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_u\",\"type\":\"uint256[]\"},{\"name\":\"_i\",\"type\":\"int256[]\"},{\"name\":\"_b\",\"type\":\"bool[]\"},{\"name\":\"_addr\",\"type\":\"address[]\"},{\"name\":\"_bs32\",\"type\":\"bytes32[]\"},{\"name\":\"_s\",\"type\":\"string[]\"},{\"name\":\"_bs\",\"type\":\"bytes[]\"}],\"name\":\"test\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256[]\"},{\"name\":\"\",\"type\":\"int256[]\"},{\"name\":\"\",\"type\":\"bool[]\"},{\"name\":\"\",\"type\":\"address[]\"},{\"name\":\"\",\"type\":\"bytes32[]\"},{\"name\":\"\",\"type\":\"string[]\"},{\"name\":\"\",\"type\":\"bytes[]\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"_u\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"_i\",\"type\":\"int256\"},{\"indexed\":false,\"name\":\"_b\",\"type\":\"bool\"},{\"indexed\":false,\"name\":\"_addr\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"_bs32\",\"type\":\"bytes32\"},{\"indexed\":false,\"name\":\"_s\",\"type\":\"string\"},{\"indexed\":false,\"name\":\"_bs\",\"type\":\"bytes\"}],\"name\":\"TestEventSimpleParams\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"_u\",\"type\":\"uint256[]\"},{\"indexed\":false,\"name\":\"_i\",\"type\":\"int256[]\"},{\"indexed\":false,\"name\":\"_b\",\"type\":\"bool[]\"},{\"indexed\":false,\"name\":\"_addr\",\"type\":\"address[]\"},{\"indexed\":false,\"name\":\"_bs32\",\"type\":\"bytes32[]\"},{\"indexed\":false,\"name\":\"_s\",\"type\":\"string[]\"},{\"indexed\":false,\"name\":\"_bs\",\"type\":\"bytes[]\"}],\"name\":\"TestEventDArrayParams\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"_u\",\"type\":\"uint256[4]\"},{\"indexed\":false,\"name\":\"_i\",\"type\":\"int256[4]\"},{\"indexed\":false,\"name\":\"_b\",\"type\":\"bool[4]\"},{\"indexed\":false,\"name\":\"_addr\",\"type\":\"address[4]\"},{\"indexed\":false,\"name\":\"_bs32\",\"type\":\"bytes32[4]\"},{\"indexed\":false,\"name\":\"_s\",\"type\":\"string[4]\"},{\"indexed\":false,\"name\":\"_bs\",\"type\":\"bytes[4]\"}],\"name\":\"TestEventSArrayParams\",\"type\":\"event\"}]", "");
List<Type> test1Params = Arrays.asList(new StaticArray4<Uint256>(new Uint256(11111), new Uint256(22222), new Uint256(33333), new Uint256(44444)), new StaticArray4<Int256>(new Int256(-1111111), new Int256(-2222222), new Int256(-3333333), new Int256(-4444444)), new StaticArray4<Bool>(new Bool(true), new Bool(false), new Bool(true), new Bool(false)), new StaticArray4<Address>(new Address("0x692a70d2e424a56d2c6c27aa97d1a86395877b3a"), new Address("0x692a70d2e424a56d2c6c27aa97d1a86395877b3a"), new Address("0x0"), new Address("0x692a70d2e424a56d2c6c27aa97d1a86395877b3a")), new StaticArray4<Bytes32>(new Bytes32("abcdefghiabcdefghiabcdefghiabhji".getBytes()), new Bytes32("abcdefghiabcdefghiabcdefghiabhji".getBytes()), new Bytes32("00000000000000000000000000000000".getBytes()), new Bytes32("abcdefghiabcdefghiabcdefghiabhji".getBytes())), new StaticArray4<Utf8String>(new Utf8String("章鱼小丸子ljjkl;adjsfkljlkjl"), new Utf8String("xxxfjlk"), new Utf8String("fdajl;jkdsafjkljkadfjklf"), new Utf8String("")), new StaticArray4<DynamicBytes>(new DynamicBytes("sadfljkjkljkl".getBytes()), new DynamicBytes("".getBytes()), new DynamicBytes("sadfljkjkljkl".getBytes()), new DynamicBytes("章鱼小丸子ljjkl;adjsfkljlkjl".getBytes())));
Function test1 = new Function("test", test1Params, Arrays.asList(new TypeReference<Uint256>() {
}, new TypeReference<Int256>() {
}, new TypeReference<Address>() {
}, new TypeReference<Utf8String>() {
}, new TypeReference<DynamicBytes>() {
}, new TypeReference<Bytes32>() {
}));
assertThat(decode.decodeInputReturnJson(FunctionEncoder.encode(test1)), is("{\"function\":\"test(uint256[4],int256[4],bool[4],address[4],bytes32[4],string[4],bytes[4])\",\"methodID\":\"0x5682504e\",\"result\":[{\"name\":\"_u\",\"type\":\"uint256[4]\",\"data\":[11111,22222,33333,44444]},{\"name\":\"_i\",\"type\":\"int256[4]\",\"data\":[-1111111,-2222222,-3333333,-4444444]},{\"name\":\"_b\",\"type\":\"bool[4]\",\"data\":[true,false,true,false]},{\"name\":\"_addr\",\"type\":\"address[4]\",\"data\":[\"0x692a70d2e424a56d2c6c27aa97d1a86395877b3a\",\"0x692a70d2e424a56d2c6c27aa97d1a86395877b3a\",\"0x0000000000000000000000000000000000000000\",\"0x692a70d2e424a56d2c6c27aa97d1a86395877b3a\"]},{\"name\":\"_bs32\",\"type\":\"bytes32[4]\",\"data\":[\"abcdefghiabcdefghiabcdefghiabhji\",\"abcdefghiabcdefghiabcdefghiabhji\",\"00000000000000000000000000000000\",\"abcdefghiabcdefghiabcdefghiabhji\"]},{\"name\":\"_s\",\"type\":\"string[4]\",\"data\":[\"章鱼小丸子ljjkl;adjsfkljlkjl\",\"xxxfjlk\",\"fdajl;jkdsafjkljkadfjklf\",\"\"]},{\"name\":\"_bs\",\"type\":\"bytes[4]\",\"data\":[\"sadfljkjkljkl\",\"\",\"sadfljkjkljkl\",\"章鱼小丸子ljjkl;adjsfkljlkjl\"]}]}"));
InputAndOutputResult inputAndOutputResult1 = decode.decodeInputReturnObject(FunctionEncoder.encode(test1));
List<ResultEntity> resultInputList = inputAndOutputResult1.getResult();
assertThat(transEntitytoType(resultInputList), is(test1Params));
List<Type> test1Output = Arrays.asList(new StaticArray2<Uint256>(new Uint256(11111), new Uint256(33333)), new StaticArray2<Int256>(new Int256(-1111111), new Int256(-2222222)), new StaticArray2<Bool>(new Bool(true), new Bool(false)), new StaticArray2<Address>(new Address("0x692a70d2e424a56d2c6c27aa97d1a86395877b3a"), new Address("0x692a70d2e424a56d2c6c27aa97d1a86395877b3a")), new StaticArray2<Bytes32>(new Bytes32("abcdefghiabcdefghiabcdefghiabhji".getBytes()), new Bytes32("01234567890123456789012345678901".getBytes())), new StaticArray2<Utf8String>(new Utf8String("章鱼小丸子ljjkl;adjsfkljlkjl"), new Utf8String("dasfjklk;jlj")), new StaticArray2<DynamicBytes>(new DynamicBytes("章鱼小丸子ljjkl;adjsfkljlkjl".getBytes()), new DynamicBytes("dasfjklk;jlj".getBytes())));
assertThat(decode.decodeOutputReturnJson(FunctionEncoder.encode(test1), FunctionEncoder.encodeConstructor(test1Output)), is("{\"function\":\"test(uint256[4],int256[4],bool[4],address[4],bytes32[4],string[4],bytes[4])\",\"methodID\":\"0x5682504e\",\"result\":[{\"name\":\"\",\"type\":\"uint256[2]\",\"data\":[11111,33333]},{\"name\":\"\",\"type\":\"int256[2]\",\"data\":[-1111111,-2222222]},{\"name\":\"\",\"type\":\"bool[2]\",\"data\":[true,false]},{\"name\":\"\",\"type\":\"address[2]\",\"data\":[\"0x692a70d2e424a56d2c6c27aa97d1a86395877b3a\",\"0x692a70d2e424a56d2c6c27aa97d1a86395877b3a\"]},{\"name\":\"\",\"type\":\"bytes32[2]\",\"data\":[\"abcdefghiabcdefghiabcdefghiabhji\",\"01234567890123456789012345678901\"]},{\"name\":\"\",\"type\":\"string[2]\",\"data\":[\"章鱼小丸子ljjkl;adjsfkljlkjl\",\"dasfjklk;jlj\"]},{\"name\":\"\",\"type\":\"bytes[2]\",\"data\":[\"章鱼小丸子ljjkl;adjsfkljlkjl\",\"dasfjklk;jlj\"]}]}"));
InputAndOutputResult inputAndOutputResult = decode.decodeOutputReturnObject(FunctionEncoder.encode(test1), FunctionEncoder.encodeConstructor(test1Output));
List<ResultEntity> resultOutputList = inputAndOutputResult.getResult();
assertThat(transEntitytoType(resultOutputList), is(test1Output));
}
use of org.fisco.bcos.web3j.abi.datatypes.generated.Int256 in project web3sdk by FISCO-BCOS.
the class CallContractTest method testAsyncCallContract.
private static void testAsyncCallContract(CallContract callContract, String address) {
TransactionCallback callback = new TransactionCallback();
TransactionReceipt receipt;
callContract.asyncSendTransaction(callback, gasPrice, gasLimit, address, "setAndget", new Utf8String("hello world"), new Int256(10086));
try {
callback.semaphore.acquire(1);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
System.out.println(e.getLocalizedMessage());
}
receipt = callback.receipt;
List<TypeReference<?>> referencesList = Arrays.<TypeReference<?>>asList(new TypeReference<Utf8String>() {
}, new TypeReference<Int256>() {
});
List<Type> returnList1 = FunctionReturnDecoder.decode(receipt.getOutput(), Utils.convert(referencesList));
System.out.println("async call setAndget: " + (String) returnList1.get(0).getValue() + ", " + (BigInteger) returnList1.get(1).getValue());
callContract.asyncSendTransaction(callback, address, "setAndget", new Utf8String("hello world"), new Int256(10086));
try {
callback.semaphore.acquire(1);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
System.out.println(e.getLocalizedMessage());
}
receipt = callback.receipt;
referencesList = Arrays.<TypeReference<?>>asList(new TypeReference<Utf8String>() {
}, new TypeReference<Int256>() {
});
List<Type> returnList2 = FunctionReturnDecoder.decode(receipt.getOutput(), Utils.convert(referencesList));
System.out.println("default async call setAndget: " + (String) returnList2.get(0).getValue() + ", " + (BigInteger) returnList2.get(1).getValue());
}
use of org.fisco.bcos.web3j.abi.datatypes.generated.Int256 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.Int256 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));
}
Aggregations