Search in sources :

Example 31 with PrecompiledTransactionResult

use of org.aion.precompiled.PrecompiledTransactionResult in project aion by aionnetwork.

the class TotalCurrencyContractTest method TestGetTotalAmountInsufficientNrg.

@Test
public void TestGetTotalAmountInsufficientNrg() {
    System.out.println("Running TestGetTotalAmountInsufficientNrg");
    byte[] payload = new byte[] { 0 };
    PrecompiledTransactionResult res = tcc.execute(payload, COST - 1);
    assertEquals("OUT_OF_NRG", res.getStatus().causeOfError);
    assertEquals(0, res.getEnergyRemaining());
}
Also used : PrecompiledTransactionResult(org.aion.precompiled.PrecompiledTransactionResult) Test(org.junit.Test)

Example 32 with PrecompiledTransactionResult

use of org.aion.precompiled.PrecompiledTransactionResult in project aion by aionnetwork.

the class TotalCurrencyContractTest method TestGetTotalInsufficientNrg.

@Test
public void TestGetTotalInsufficientNrg() {
    System.out.println("Running TestUpdateTotalInsufficientNrg.");
    PrecompiledTransactionResult res = tcc.execute(new byte[] { (byte) 0x0 }, COST - 1);
    assertEquals("OUT_OF_NRG", res.getStatus().causeOfError);
    assertEquals(0L, res.getEnergyRemaining());
}
Also used : PrecompiledTransactionResult(org.aion.precompiled.PrecompiledTransactionResult) Test(org.junit.Test)

Example 33 with PrecompiledTransactionResult

use of org.aion.precompiled.PrecompiledTransactionResult in project aion by aionnetwork.

the class TotalCurrencyContractTest method TestGetTotalAmountEmptyPayload.

@Test
public void TestGetTotalAmountEmptyPayload() {
    System.out.println("Running TestGetTotalAmountEmptyPayload.");
    // zero size input
    byte[] payload = new byte[0];
    PrecompiledTransactionResult res = tcc.execute(payload, COST);
    System.out.println("Contract result: " + res.toString());
    assertTrue(res.getStatus().isFailed());
}
Also used : PrecompiledTransactionResult(org.aion.precompiled.PrecompiledTransactionResult) Test(org.junit.Test)

Example 34 with PrecompiledTransactionResult

use of org.aion.precompiled.PrecompiledTransactionResult in project aion by aionnetwork.

the class TotalCurrencyContractTest method TestSubtractTotalAmountBelowZero.

@Test
public void TestSubtractTotalAmountBelowZero() {
    System.out.println("Running TestSubtractTotalAmountBelowZero.");
    // 0x1 == subtract
    byte[] input = constructUpdateInput((byte) 0x0, (byte) 0x1);
    PrecompiledTransactionResult res = tcc.execute(input, COST);
    assertEquals("FAILURE", res.getStatus().causeOfError);
    assertEquals(0L, res.getEnergyRemaining());
    // Verify total amount is zero.
    res = tcc.execute(new byte[] { (byte) 0x0 }, COST);
    assertEquals(BigInteger.ZERO, new BigInteger(1, res.getReturnData()));
}
Also used : PrecompiledTransactionResult(org.aion.precompiled.PrecompiledTransactionResult) BigInteger(java.math.BigInteger) Test(org.junit.Test)

Example 35 with PrecompiledTransactionResult

use of org.aion.precompiled.PrecompiledTransactionResult in project aion by aionnetwork.

the class TotalCurrencyContractTest method TestUpdateTotalIncorrectSigSize.

@Test
public void TestUpdateTotalIncorrectSigSize() {
    System.out.println("Running TestUpdateTotalIncorrectSigSize.");
    byte[] input = Arrays.copyOfRange(constructUpdateInput((byte) 0x0, (byte) 0x0), 0, // cut sig short.
    100);
    PrecompiledTransactionResult res = tcc.execute(input, COST);
    assertEquals("FAILURE", res.getStatus().causeOfError);
    assertEquals(0L, res.getEnergyRemaining());
}
Also used : PrecompiledTransactionResult(org.aion.precompiled.PrecompiledTransactionResult) Test(org.junit.Test)

Aggregations

PrecompiledTransactionResult (org.aion.precompiled.PrecompiledTransactionResult)114 Test (org.junit.Test)103 PrecompiledTransactionContext (org.aion.precompiled.type.PrecompiledTransactionContext)39 AionAddress (org.aion.types.AionAddress)36 TokenBridgeContract (org.aion.precompiled.contracts.ATB.TokenBridgeContract)26 ECKey (org.aion.crypto.ECKey)25 AbiEncoder (org.aion.precompiled.encoding.AbiEncoder)25 AddressFVM (org.aion.precompiled.encoding.AddressFVM)25 AbiEncoder (org.aion.zero.impl.precompiled.encoding.AbiEncoder)25 AddressFVM (org.aion.zero.impl.precompiled.encoding.AddressFVM)25 BigInteger (java.math.BigInteger)24 ListFVM (org.aion.precompiled.encoding.ListFVM)23 ListFVM (org.aion.zero.impl.precompiled.encoding.ListFVM)23 BridgeTransfer (org.aion.precompiled.contracts.ATB.BridgeTransfer)16 ContractFactory (org.aion.precompiled.ContractFactory)12 Uint128FVM (org.aion.precompiled.encoding.Uint128FVM)11 Uint128FVM (org.aion.zero.impl.precompiled.encoding.Uint128FVM)11 PrecompiledContract (org.aion.precompiled.type.PrecompiledContract)10 InternalTransaction (org.aion.types.InternalTransaction)7 Log (org.aion.types.Log)6