Search in sources :

Example 6 with Transaction

use of org.aion.types.Transaction in project aion by aionnetwork.

the class InvokableTransactionTest method encodeDecodeContractCreateTest.

@Test
public void encodeDecodeContractCreateTest() {
    Transaction tx = Transaction.contractCreateTransaction(new AionAddress(key.getAddress()), new byte[0], BigInteger.ZERO, BigInteger.ZERO, new byte[0], 1L, 1L);
    AionAddress executor = AddressUtils.ZERO_ADDRESS;
    byte[] invokable = InvokableTxUtil.encodeInvokableTransaction(key, tx.nonce, tx.destinationAddress, tx.value, tx.copyOfTransactionData(), executor);
    InternalTransaction tx2 = InvokableTxUtil.decode(invokable, AddressUtils.ZERO_ADDRESS, 1L, 1L);
    assertNotNull(tx2);
    assertEquals(tx.destinationAddress, tx2.destination);
    assertEquals(tx.nonce, tx2.senderNonce);
    assertEquals(tx.value, tx2.value);
    assertArrayEquals(tx.copyOfTransactionData(), tx2.copyOfData());
}
Also used : AionAddress(org.aion.types.AionAddress) InternalTransaction(org.aion.types.InternalTransaction) Transaction(org.aion.types.Transaction) InternalTransaction(org.aion.types.InternalTransaction) Test(org.junit.Test)

Example 7 with Transaction

use of org.aion.types.Transaction in project aion by aionnetwork.

the class AvmTransactionExecutor method toAionTypesTransactions.

/**
 * Converts the specified transactions to equivalent aion_types transactions.
 *
 * @param transactions The transactions to convert.
 * @return the converted transactions.
 */
private static Transaction[] toAionTypesTransactions(AionTransaction[] transactions) {
    Transaction[] aionTypesTransactions = new Transaction[transactions.length];
    int index = 0;
    for (AionTransaction transaction : transactions) {
        aionTypesTransactions[index] = toAionTypesTransaction(transaction);
        index++;
    }
    return aionTypesTransactions;
}
Also used : Transaction(org.aion.types.Transaction) AionTransaction(org.aion.base.AionTransaction) AionTransaction(org.aion.base.AionTransaction)

Aggregations

Transaction (org.aion.types.Transaction)7 AionAddress (org.aion.types.AionAddress)6 Test (org.junit.Test)6 IAionVirtualMachine (org.aion.avm.stub.IAionVirtualMachine)3 IAvmExternalState (org.aion.avm.stub.IAvmExternalState)3 IAvmFutureResult (org.aion.avm.stub.IAvmFutureResult)3 RepositoryCache (org.aion.base.db.RepositoryCache)3 InternalTransaction (org.aion.types.InternalTransaction)3 TransactionResult (org.aion.types.TransactionResult)3 AionTransaction (org.aion.base.AionTransaction)1