Search in sources :

Example 46 with Function

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

the class TransactionDecoderTest method testStaticParams1.

@Test
public void testStaticParams1() 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(0), new Uint256(0), new Uint256(0), new Uint256(0)), new StaticArray4<Int256>(new Int256(0), new Int256(0), new Int256(0), new Int256(0)), new StaticArray4<Bool>(new Bool(true), new Bool(false), new Bool(true), new Bool(false)), new StaticArray4<Address>(new Address("0x0"), new Address("0x0"), new Address("0x0"), new Address("0x0")), new StaticArray4<Bytes32>(new Bytes32("                                ".getBytes()), new Bytes32("                                ".getBytes()), new Bytes32("                                ".getBytes()), new Bytes32("                                ".getBytes())), new StaticArray4<Utf8String>(new Utf8String(""), new Utf8String(""), new Utf8String(""), new Utf8String("")), new StaticArray4<DynamicBytes>(new DynamicBytes("".getBytes()), new DynamicBytes("".getBytes()), new DynamicBytes("".getBytes()), new DynamicBytes("".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\":[0,0,0,0]},{\"name\":\"_i\",\"type\":\"int256[4]\",\"data\":[0,0,0,0]},{\"name\":\"_b\",\"type\":\"bool[4]\",\"data\":[true,false,true,false]},{\"name\":\"_addr\",\"type\":\"address[4]\",\"data\":[\"0x0000000000000000000000000000000000000000\",\"0x0000000000000000000000000000000000000000\",\"0x0000000000000000000000000000000000000000\",\"0x0000000000000000000000000000000000000000\"]},{\"name\":\"_bs32\",\"type\":\"bytes32[4]\",\"data\":[\"\",\"\",\"\",\"\"]},{\"name\":\"_s\",\"type\":\"string[4]\",\"data\":[\"\",\"\",\"\",\"\"]},{\"name\":\"_bs\",\"type\":\"bytes[4]\",\"data\":[\"\",\"\",\"\",\"\"]}]}"));
    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(0), new Uint256(0)), new StaticArray2<Int256>(new Int256(0), new Int256(0)), new StaticArray2<Bool>(new Bool(true), new Bool(false)), new StaticArray2<Address>(new Address("0x0"), new Address("0x0")), new StaticArray2<Bytes32>(new Bytes32("                                ".getBytes()), new Bytes32("                                ".getBytes())), new StaticArray2<Utf8String>(new Utf8String(""), new Utf8String("")), new StaticArray2<DynamicBytes>(new DynamicBytes("".getBytes()), new DynamicBytes("".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\":[0,0]},{\"name\":\"\",\"type\":\"int256[2]\",\"data\":[0,0]},{\"name\":\"\",\"type\":\"bool[2]\",\"data\":[true,false]},{\"name\":\"\",\"type\":\"address[2]\",\"data\":[\"0x0000000000000000000000000000000000000000\",\"0x0000000000000000000000000000000000000000\"]},{\"name\":\"\",\"type\":\"bytes32[2]\",\"data\":[\"\",\"\"]},{\"name\":\"\",\"type\":\"string[2]\",\"data\":[\"\",\"\"]},{\"name\":\"\",\"type\":\"bytes[2]\",\"data\":[\"\",\"\"]}]}"));
    InputAndOutputResult inputAndOutputResult = decode.decodeOutputReturnObject(FunctionEncoder.encode(test1), FunctionEncoder.encodeConstructor(test1Output));
    List<ResultEntity> resultOutputList = inputAndOutputResult.getResult();
    assertThat(transEntitytoType(resultOutputList), is(test1Output));
}
Also used : Address(org.fisco.bcos.web3j.abi.datatypes.Address) Bytes32(org.fisco.bcos.web3j.abi.datatypes.generated.Bytes32) Function(org.fisco.bcos.web3j.abi.datatypes.Function) DynamicBytes(org.fisco.bcos.web3j.abi.datatypes.DynamicBytes) Bool(org.fisco.bcos.web3j.abi.datatypes.Bool) TypeReference(org.fisco.bcos.web3j.abi.TypeReference) Int256(org.fisco.bcos.web3j.abi.datatypes.generated.Int256) Utf8String(org.fisco.bcos.web3j.abi.datatypes.Utf8String) Type(org.fisco.bcos.web3j.abi.datatypes.Type) NamedType(org.fisco.bcos.web3j.protocol.core.methods.response.AbiDefinition.NamedType) Uint256(org.fisco.bcos.web3j.abi.datatypes.generated.Uint256) Test(org.junit.Test)

Example 47 with Function

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

the class TransactionDecoderTest method testSimpleParams0.

@Test
public void testSimpleParams0() throws JsonProcessingException, TransactionException, BaseException {
    /*
        function test(uint256 _u,int256 _i,bool _b,address _addr,bytes32 _bs32, string _s,bytes _bs) public constant returns (uint256,int256,bool,address,bytes32,string,bytes)
        */
    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 Uint256(111111), new Int256(-1111111), new Bool(false), new Address("0x692a70d2e424a56d2c6c27aa97d1a86395877b3a"), new Bytes32("abcdefghiabcdefghiabcdefghiabhji".getBytes()), new Utf8String("章鱼小丸子ljjkl;adjsfkljlkjl"), new DynamicBytes("sadfljkjkljkl".getBytes()));
    Function test1 = new Function("test", test1Params, Collections.<TypeReference<?>>emptyList());
    String resultInputJson = decode.decodeInputReturnJson(FunctionEncoder.encode(test1));
    InputAndOutputResult inputAndOutputResult = decode.decodeInputReturnObject(FunctionEncoder.encode(test1));
    List<ResultEntity> resultInputList = inputAndOutputResult.getResult();
    List<Type> resultInputListType = transEntitytoType(resultInputList);
    assertThat(resultInputJson, is("{\"function\":\"test(uint256,int256,bool,address,bytes32,string,bytes)\",\"methodID\":\"0x58a12c20\",\"result\":[{\"name\":\"_u\",\"type\":\"uint256\",\"data\":111111},{\"name\":\"_i\",\"type\":\"int256\",\"data\":-1111111},{\"name\":\"_b\",\"type\":\"bool\",\"data\":false},{\"name\":\"_addr\",\"type\":\"address\",\"data\":\"0x692a70d2e424a56d2c6c27aa97d1a86395877b3a\"},{\"name\":\"_bs32\",\"type\":\"bytes32\",\"data\":\"abcdefghiabcdefghiabcdefghiabhji\"},{\"name\":\"_s\",\"type\":\"string\",\"data\":\"章鱼小丸子ljjkl;adjsfkljlkjl\"},{\"name\":\"_bs\",\"type\":\"bytes\",\"data\":\"sadfljkjkljkl\"}]}"));
    assertThat(resultInputListType, is(test1Params));
    String resultOutputJson = decode.decodeOutputReturnJson(FunctionEncoder.encode(test1), FunctionEncoder.encodeConstructor(test1Params));
    InputAndOutputResult inputAndOutputResult2 = decode.decodeOutputReturnObject(FunctionEncoder.encode(test1), FunctionEncoder.encodeConstructor(test1Params));
    List<ResultEntity> resultOutputList = inputAndOutputResult2.getResult();
    List<Type> resultOutputListType = transEntitytoType(resultOutputList);
    assertThat(resultOutputJson, is("{\"function\":\"test(uint256,int256,bool,address,bytes32,string,bytes)\",\"methodID\":\"0x58a12c20\",\"result\":[{\"name\":\"\",\"type\":\"uint256\",\"data\":111111},{\"name\":\"\",\"type\":\"int256\",\"data\":-1111111},{\"name\":\"\",\"type\":\"bool\",\"data\":false},{\"name\":\"\",\"type\":\"address\",\"data\":\"0x692a70d2e424a56d2c6c27aa97d1a86395877b3a\"},{\"name\":\"\",\"type\":\"bytes32\",\"data\":\"abcdefghiabcdefghiabcdefghiabhji\"},{\"name\":\"\",\"type\":\"string\",\"data\":\"章鱼小丸子ljjkl;adjsfkljlkjl\"},{\"name\":\"\",\"type\":\"bytes\",\"data\":\"sadfljkjkljkl\"}]}"));
    assertThat(resultOutputListType, is(test1Params));
}
Also used : Address(org.fisco.bcos.web3j.abi.datatypes.Address) Utf8String(org.fisco.bcos.web3j.abi.datatypes.Utf8String) Bytes32(org.fisco.bcos.web3j.abi.datatypes.generated.Bytes32) Int256(org.fisco.bcos.web3j.abi.datatypes.generated.Int256) Utf8String(org.fisco.bcos.web3j.abi.datatypes.Utf8String) Function(org.fisco.bcos.web3j.abi.datatypes.Function) Type(org.fisco.bcos.web3j.abi.datatypes.Type) NamedType(org.fisco.bcos.web3j.protocol.core.methods.response.AbiDefinition.NamedType) DynamicBytes(org.fisco.bcos.web3j.abi.datatypes.DynamicBytes) Bool(org.fisco.bcos.web3j.abi.datatypes.Bool) Uint256(org.fisco.bcos.web3j.abi.datatypes.generated.Uint256) Test(org.junit.Test)

Example 48 with Function

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

the class TableTest method remove.

public void remove(String name, BigInteger item_id, TransactionSucCallback callback) {
    final Function function = new Function(FUNC_REMOVE, Arrays.<Type>asList(new org.fisco.bcos.web3j.abi.datatypes.Utf8String(name), new org.fisco.bcos.web3j.abi.datatypes.generated.Int256(item_id)), Collections.<TypeReference<?>>emptyList());
    asyncExecuteTransaction(function, callback);
}
Also used : Function(org.fisco.bcos.web3j.abi.datatypes.Function) Utf8String(org.fisco.bcos.web3j.abi.datatypes.Utf8String) Int256(org.fisco.bcos.web3j.abi.datatypes.generated.Int256)

Example 49 with Function

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

the class RevertResolverTest method hasRevertMessageSMTest.

@Test
public void hasRevertMessageSMTest() throws IOException {
    EncryptType.setEncryptType(EncryptType.SM2_TYPE);
    String revertMessage = "RevertMessage";
    Function revertFunction = newFunction("Error", revertMessage);
    String revertABI = FunctionEncoder.encode(revertFunction);
    Function testFunction = newFunction("testFunc", revertMessage);
    String testABI = FunctionEncoder.encode(testFunction);
    assertFalse(RevertResolver.hasRevertMessage(null, null));
    assertFalse(RevertResolver.hasRevertMessage("", null));
    assertFalse(RevertResolver.hasRevertMessage(null, ""));
    assertFalse(RevertResolver.hasRevertMessage("", ""));
    assertFalse(RevertResolver.hasRevertMessage("0x0", ""));
    assertFalse(RevertResolver.hasRevertMessage("0x0", ""));
    assertFalse(RevertResolver.hasRevertMessage("0x0", revertABI));
    assertTrue(RevertResolver.hasRevertMessage("0x1", revertABI));
    assertFalse(RevertResolver.hasRevertMessage(null, revertABI));
    assertFalse(RevertResolver.hasRevertMessage("0x0", testABI));
    assertFalse(RevertResolver.hasRevertMessage("0x1", testABI));
    assertFalse(RevertResolver.hasRevertMessage(null, testABI));
    EncryptType.setEncryptType(EncryptType.ECDSA_TYPE);
}
Also used : Function(org.fisco.bcos.web3j.abi.datatypes.Function) Utf8String(org.fisco.bcos.web3j.abi.datatypes.Utf8String) Test(org.junit.Test)

Example 50 with Function

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

the class RevertResolverTest method hasRevertMessageTest.

@Test
public void hasRevertMessageTest() throws IOException {
    String revertMessage = "RevertMessage";
    Function revertFunction = newFunction("Error", revertMessage);
    String revertABI = FunctionEncoder.encode(revertFunction);
    Function testFunction = newFunction("testFunc", revertMessage);
    String testABI = FunctionEncoder.encode(testFunction);
    assertFalse(RevertResolver.hasRevertMessage(null, null));
    assertFalse(RevertResolver.hasRevertMessage("", null));
    assertFalse(RevertResolver.hasRevertMessage(null, ""));
    assertFalse(RevertResolver.hasRevertMessage("", ""));
    assertFalse(RevertResolver.hasRevertMessage("0x0", ""));
    assertFalse(RevertResolver.hasRevertMessage("0x0", ""));
    assertFalse(RevertResolver.hasRevertMessage("0x0", revertABI));
    assertTrue(RevertResolver.hasRevertMessage("0x1", revertABI));
    assertFalse(RevertResolver.hasRevertMessage(null, revertABI));
    assertFalse(RevertResolver.hasRevertMessage("0x0", testABI));
    assertFalse(RevertResolver.hasRevertMessage("0x1", testABI));
    assertFalse(RevertResolver.hasRevertMessage(null, testABI));
}
Also used : Function(org.fisco.bcos.web3j.abi.datatypes.Function) Utf8String(org.fisco.bcos.web3j.abi.datatypes.Utf8String) Test(org.junit.Test)

Aggregations

Function (org.fisco.bcos.web3j.abi.datatypes.Function)108 Utf8String (org.fisco.bcos.web3j.abi.datatypes.Utf8String)59 Type (org.fisco.bcos.web3j.abi.datatypes.Type)41 TypeReference (org.fisco.bcos.web3j.abi.TypeReference)38 Tuple1 (org.fisco.bcos.web3j.tuples.generated.Tuple1)26 Int256 (org.fisco.bcos.web3j.abi.datatypes.generated.Int256)22 Address (org.fisco.bcos.web3j.abi.datatypes.Address)19 Uint256 (org.fisco.bcos.web3j.abi.datatypes.generated.Uint256)16 Test (org.junit.Test)15 EncryptType (org.fisco.bcos.web3j.crypto.EncryptType)11 Bytes32 (org.fisco.bcos.web3j.abi.datatypes.generated.Bytes32)8 NamedType (org.fisco.bcos.web3j.protocol.core.methods.response.AbiDefinition.NamedType)8 Bool (org.fisco.bcos.web3j.abi.datatypes.Bool)6 DynamicBytes (org.fisco.bcos.web3j.abi.datatypes.DynamicBytes)6 Tuple2 (org.fisco.bcos.web3j.tuples.generated.Tuple2)6 CollectionType (com.fasterxml.jackson.databind.type.CollectionType)2 ArrayList (java.util.ArrayList)2 AbiDefinition (org.fisco.bcos.web3j.protocol.core.methods.response.AbiDefinition)2 TransactionReceipt (org.fisco.bcos.web3j.protocol.core.methods.response.TransactionReceipt)2 DynamicArray (org.fisco.bcos.web3j.abi.datatypes.DynamicArray)1