use of org.aion.solidity.SolidityType.StaticArrayType in project aion by aionnetwork.
the class SolidityTypeTest method testStaticArray2.
@Test
public void testStaticArray2() throws Exception {
List<byte[]> x = new ArrayList<>();
x.add(Hex.decode("1122334455667788112233445566778811223344"));
x.add(Hex.decode("2122334455667788112233445566778811223344"));
x.add(Hex.decode("3122334455667788112233445566778811223344"));
SolidityType type = new StaticArrayType("bytes20[3]");
byte[] params = type.encode(x);
System.out.println(Hex.toHexString(params));
AionTransaction tx = createTransaction(ByteUtil.merge(Hex.decode("e4bef5c9"), params));
MiningBlock block = createDummyBlock();
RepositoryCache repo = createRepository(tx);
AionTxReceipt receipt = executeTransaction(tx, block, repo).getReceipt();
System.out.println(receipt);
assertArrayEquals(params, receipt.getTransactionOutput());
Object[] decoded = (Object[]) type.decode(receipt.getTransactionOutput());
for (Object d : decoded) {
System.out.println(Hex.toHexString((byte[]) d));
}
}
use of org.aion.solidity.SolidityType.StaticArrayType in project aion by aionnetwork.
the class SolidityTypeTest method testStaticArray1.
@Test
public void testStaticArray1() throws Exception {
List<BigInteger> x = new ArrayList<>();
x.add(BigInteger.valueOf(1L));
x.add(BigInteger.valueOf(2L));
x.add(BigInteger.valueOf(3L));
SolidityType type = new StaticArrayType("uint16[3]");
byte[] params = type.encode(x);
System.out.println(Hex.toHexString(params));
AionTransaction tx = createTransaction(ByteUtil.merge(Hex.decode("97e934e2"), params));
MiningBlock block = createDummyBlock();
RepositoryCache repo = createRepository(tx);
AionTxReceipt receipt = executeTransaction(tx, block, repo).getReceipt();
System.out.println(receipt);
assertArrayEquals(params, receipt.getTransactionOutput());
Object[] decoded = (Object[]) type.decode(receipt.getTransactionOutput());
for (Object d : decoded) {
System.out.println(d);
}
}
Aggregations