Search in sources :

Example 1 with StringType

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

the class SolidityTypeTest method testString2.

@Test
public void testString2() throws Exception {
    String x = "hello, world!hello, world!hello, world!hello, world!hello, world!hello, world!";
    SolidityType type = new StringType();
    byte[] params = ByteUtil.merge(Hex.decode("00000000000000000000000000000010"), type.encode(x));
    System.out.println(Hex.toHexString(params));
    AionTransaction tx = createTransaction(ByteUtil.merge(Hex.decode("61cb5a01"), params));
    MiningBlock block = createDummyBlock();
    RepositoryCache repo = createRepository(tx);
    AionTxReceipt receipt = executeTransaction(tx, block, repo).getReceipt();
    System.out.println(receipt);
    assertArrayEquals(params, receipt.getTransactionOutput());
    assertEquals(x, type.decode(receipt.getTransactionOutput(), 16));
}
Also used : StringType(org.aion.solidity.SolidityType.StringType) RepositoryCache(org.aion.base.db.RepositoryCache) AionTransaction(org.aion.base.AionTransaction) SolidityType(org.aion.solidity.SolidityType) AionTxReceipt(org.aion.base.AionTxReceipt) MiningBlock(org.aion.zero.impl.types.MiningBlock) Test(org.junit.Test)

Example 2 with StringType

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

the class SolidityTypeTest method testString1.

@Test
public void testString1() throws Exception {
    String x = "hello, world!";
    SolidityType type = new StringType();
    byte[] params = ByteUtil.merge(Hex.decode("00000000000000000000000000000010"), type.encode(x));
    System.out.println(Hex.toHexString(params));
    AionTransaction tx = createTransaction(ByteUtil.merge(Hex.decode("61cb5a01"), params));
    MiningBlock block = createDummyBlock();
    RepositoryCache repo = createRepository(tx);
    AionTxReceipt receipt = executeTransaction(tx, block, repo).getReceipt();
    System.out.println(receipt);
    assertArrayEquals(params, receipt.getTransactionOutput());
    assertEquals(x, type.decode(receipt.getTransactionOutput(), 16));
}
Also used : StringType(org.aion.solidity.SolidityType.StringType) RepositoryCache(org.aion.base.db.RepositoryCache) AionTransaction(org.aion.base.AionTransaction) SolidityType(org.aion.solidity.SolidityType) AionTxReceipt(org.aion.base.AionTxReceipt) MiningBlock(org.aion.zero.impl.types.MiningBlock) Test(org.junit.Test)

Aggregations

AionTransaction (org.aion.base.AionTransaction)2 AionTxReceipt (org.aion.base.AionTxReceipt)2 RepositoryCache (org.aion.base.db.RepositoryCache)2 SolidityType (org.aion.solidity.SolidityType)2 StringType (org.aion.solidity.SolidityType.StringType)2 MiningBlock (org.aion.zero.impl.types.MiningBlock)2 Test (org.junit.Test)2