org.web3j.abi.datatypes.generated.Bytes1 Java Examples

The following examples show how to use org.web3j.abi.datatypes.generated.Bytes1. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TypeDecoderTest.java    From client-sdk-java with Apache License 2.0 6 votes vote down vote up
@Test
public void testStaticBytes() {
    Bytes6 staticBytes = new Bytes6(new byte[] { 0, 1, 2, 3, 4, 5 });
    assertThat(TypeDecoder.decodeBytes(
            "0001020304050000000000000000000000000000000000000000000000000000", Bytes6.class),
            is(staticBytes));

    Bytes empty = new Bytes1(new byte[] { 0 });
    assertThat(TypeDecoder.decodeBytes(
            "0000000000000000000000000000000000000000000000000000000000000000", Bytes1.class),
            is(empty));

    Bytes dave = new Bytes4("dave".getBytes());
    assertThat(TypeDecoder.decodeBytes(
            "6461766500000000000000000000000000000000000000000000000000000000", Bytes4.class),
            is(dave));
}
 
Example #2
Source File: TypeDecoderTest.java    From etherscan-explorer with GNU General Public License v3.0 6 votes vote down vote up
@Test
public void testStaticBytes() {
    Bytes6 staticBytes = new Bytes6(new byte[] { 0, 1, 2, 3, 4, 5 });
    assertThat(TypeDecoder.decodeBytes(
            "0001020304050000000000000000000000000000000000000000000000000000", Bytes6.class),
            is(staticBytes));

    Bytes empty = new Bytes1(new byte[] { 0 });
    assertThat(TypeDecoder.decodeBytes(
            "0000000000000000000000000000000000000000000000000000000000000000", Bytes1.class),
            is(empty));

    Bytes dave = new Bytes4("dave".getBytes());
    assertThat(TypeDecoder.decodeBytes(
            "6461766500000000000000000000000000000000000000000000000000000000", Bytes4.class),
            is(dave));
}
 
Example #3
Source File: TypeEncoderTest.java    From web3j with Apache License 2.0 6 votes vote down vote up
@Test
public void testStaticBytes() {
    Bytes staticBytes = new Bytes6(new byte[] {0, 1, 2, 3, 4, 5});
    assertEquals(
            TypeEncoder.encodeBytes(staticBytes),
            ("0001020304050000000000000000000000000000000000000000000000000000"));

    Bytes empty = new Bytes1(new byte[] {0});
    assertEquals(
            TypeEncoder.encodeBytes(empty),
            ("0000000000000000000000000000000000000000000000000000000000000000"));

    Bytes ones = new Bytes1(new byte[] {127});
    assertEquals(
            TypeEncoder.encodeBytes(ones),
            ("7f00000000000000000000000000000000000000000000000000000000000000"));

    Bytes dave = new Bytes4("dave".getBytes());
    assertEquals(
            TypeEncoder.encodeBytes(dave),
            ("6461766500000000000000000000000000000000000000000000000000000000"));
}
 
Example #4
Source File: TypeDecoderTest.java    From web3j with Apache License 2.0 6 votes vote down vote up
@Test
public void testStaticBytes() throws Exception {
    byte[] testbytes = new byte[] {0, 1, 2, 3, 4, 5};
    Bytes6 staticBytes = new Bytes6(testbytes);
    assertEquals(
            TypeDecoder.decodeBytes(
                    "0001020304050000000000000000000000000000000000000000000000000000",
                    Bytes6.class),
            (staticBytes));

    Bytes empty = new Bytes1(new byte[] {0});
    assertEquals(
            TypeDecoder.decodeBytes(
                    "0000000000000000000000000000000000000000000000000000000000000000",
                    Bytes1.class),
            (empty));

    Bytes dave = new Bytes4("dave".getBytes());
    assertEquals(
            TypeDecoder.decodeBytes(
                    "6461766500000000000000000000000000000000000000000000000000000000",
                    Bytes4.class),
            (dave));

    assertEquals(TypeDecoder.instantiateType("bytes6", testbytes), (new Bytes6(testbytes)));
}
 
Example #5
Source File: TypeEncoderTest.java    From client-sdk-java with Apache License 2.0 5 votes vote down vote up
@Test
public void testStaticBytes() {
    Bytes staticBytes = new Bytes6(new byte[] { 0, 1, 2, 3, 4, 5 });
    assertThat(TypeEncoder.encodeBytes(staticBytes),
            is("0001020304050000000000000000000000000000000000000000000000000000"));

    Bytes empty = new Bytes1(new byte[] { 0 });
    assertThat(TypeEncoder.encodeBytes(empty),
            is("0000000000000000000000000000000000000000000000000000000000000000"));

    Bytes dave = new Bytes4("dave".getBytes());
    assertThat(TypeEncoder.encodeBytes(dave),
            is("6461766500000000000000000000000000000000000000000000000000000000"));
}
 
Example #6
Source File: TypeEncoderTest.java    From etherscan-explorer with GNU General Public License v3.0 5 votes vote down vote up
@Test
public void testStaticBytes() {
    Bytes staticBytes = new Bytes6(new byte[] { 0, 1, 2, 3, 4, 5 });
    assertThat(TypeEncoder.encodeBytes(staticBytes),
            is("0001020304050000000000000000000000000000000000000000000000000000"));

    Bytes empty = new Bytes1(new byte[] { 0 });
    assertThat(TypeEncoder.encodeBytes(empty),
            is("0000000000000000000000000000000000000000000000000000000000000000"));

    Bytes dave = new Bytes4("dave".getBytes());
    assertThat(TypeEncoder.encodeBytes(dave),
            is("6461766500000000000000000000000000000000000000000000000000000000"));
}
 
Example #7
Source File: EventEmitter.java    From eventeum with Apache License 2.0 5 votes vote down vote up
public RemoteFunctionCall<TransactionReceipt> emitEventAdditionalTypes(BigInteger uint16Value, BigInteger int64Value, byte[] byteValue) {
    final Function function = new Function(
            FUNC_EMITEVENTADDITIONALTYPES, 
            Arrays.<Type>asList(new org.web3j.abi.datatypes.generated.Uint16(uint16Value), 
            new org.web3j.abi.datatypes.generated.Int64(int64Value), 
            new org.web3j.abi.datatypes.generated.Bytes1(byteValue)), 
            Collections.<TypeReference<?>>emptyList());
    return executeRemoteCallTransaction(function);
}
 
Example #8
Source File: Byte.java    From web3j with Apache License 2.0 4 votes vote down vote up
@Override
public Type toSolidityType() {
    return new Bytes1(new byte[] {getValue()});
}