Search in sources :

Example 1 with IntType

use of org.aion.solidity.SolidityType.IntType in project aion by aionnetwork.

the class SolidityTypeTest method testInt.

@Test
public void testInt() throws Exception {
    BigInteger bi = new BigInteger(1, Hex.decode("ffffffffffffffffffffffff"));
    byte[] params = new IntType("int96").encode(bi);
    System.out.println(Hex.toHexString(params));
    AionTransaction tx = createTransaction(ByteUtil.merge(Hex.decode("6761755c"), params));
    MiningBlock block = createDummyBlock();
    RepositoryCache repo = createRepository(tx);
    AionTxReceipt receipt = executeTransaction(tx, block, repo).getReceipt();
    System.out.println(receipt);
    assertArrayEquals(Hex.decode("00000000ffffffffffffffffffffffff"), receipt.getTransactionOutput());
    assertEquals(bi, new IntType("int96").decode(receipt.getTransactionOutput()));
}
Also used : BigInteger(java.math.BigInteger) RepositoryCache(org.aion.base.db.RepositoryCache) AionTransaction(org.aion.base.AionTransaction) AionTxReceipt(org.aion.base.AionTxReceipt) MiningBlock(org.aion.zero.impl.types.MiningBlock) IntType(org.aion.solidity.SolidityType.IntType) Test(org.junit.Test)

Aggregations

BigInteger (java.math.BigInteger)1 AionTransaction (org.aion.base.AionTransaction)1 AionTxReceipt (org.aion.base.AionTxReceipt)1 RepositoryCache (org.aion.base.db.RepositoryCache)1 IntType (org.aion.solidity.SolidityType.IntType)1 MiningBlock (org.aion.zero.impl.types.MiningBlock)1 Test (org.junit.Test)1