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());
}
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());
}
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());
}
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()));
}
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());
}
Aggregations