TypeEncoder { static <T extends Type> String encodeDynamicArray(DynamicArray<T> value) { int size = value.getValue().size(); String encodedLength = encode(new Uint(BigInteger.valueOf(size))); String encodedValues = encodeArrayValues(value); StringBuilder result = new StringBuilder(); result.append(encodedLength); result.append(encodedValues); return result.toString(); } private  TypeEncoder(); @SuppressWarnings("unchecked") static String encode(Type parameter);  }
@Test public void testDynamicArray() { DynamicArray<Uint> array = new DynamicArray<Uint>( new Uint(BigInteger.ONE), new Uint(BigInteger.valueOf(2)), new Uint(BigInteger.valueOf(3)) ); assertThat( TypeEncoder.encodeDynamicArray(array), is("0000000000000000000000000000000000000000000000000000000000000003" + "0000000000000000000000000000000000000000000000000000000000000001" + "0000000000000000000000000000000000000000000000000000000000000002" + "0000000000000000000000000000000000000000000000000000000000000003" )); }
@Test public void testDynamicArray() { DynamicArray<Uint> array = new DynamicArray<>( new Uint(BigInteger.ONE), new Uint(BigInteger.valueOf(2)), new Uint(BigInteger.valueOf(3)) ); assertThat( TypeEncoder.encodeDynamicArray(array), is("0000000000000000000000000000000000000000000000000000000000000003" + "0000000000000000000000000000000000000000000000000000000000000001" + "0000000000000000000000000000000000000000000000000000000000000002" + "0000000000000000000000000000000000000000000000000000000000000003" )); }
@Test public void testEmptyArray() { @SuppressWarnings("unchecked") DynamicArray<Uint> array = DynamicArray.empty("uint"); assertThat( TypeEncoder.encodeDynamicArray(array), is("0000000000000000000000000000000000000000000000000000000000000000") ); }