use of org.aion.precompiled.PrecompiledTransactionResult in project aion by aionnetwork.
the class TotalCurrencyContractTest method TestGetTotalAmount.
// <------------------------------------------------------------------------------------------->
@Test
public void TestGetTotalAmount() {
System.out.println("Running TestGetTotalAmount.");
// input == chainID
byte[] payload = new byte[] { 0 };
PrecompiledTransactionResult res = tcc.execute(payload, COST);
System.out.println("Contract result: " + res.toString());
assertTrue(res.getStatus().isSuccess());
assertEquals(0L, res.getEnergyRemaining());
}
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 non-negative.
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 TestUpdateAndGetTotalAmount.
@Test
public void TestUpdateAndGetTotalAmount() {
System.out.println("Running TestUpdateAndGetTotalAmount.");
byte[] input = constructUpdateInput((byte) 0x0, (byte) 0x0);
PrecompiledTransactionResult res = tcc.execute(input, COST);
assertTrue(res.getStatus().isSuccess());
assertEquals(0L, res.getEnergyRemaining());
tcc = new TotalCurrencyContract(state, ADDR, new AionAddress(ownerKey.getAddress()));
input = new byte[] { (byte) 0x0 };
res = tcc.execute(input, COST);
assertTrue(res.getStatus().isSuccess());
assertEquals(AMT, new BigInteger(1, res.getReturnData()));
}
use of org.aion.precompiled.PrecompiledTransactionResult in project aion by aionnetwork.
the class TotalCurrencyContractTest method TestBadSignum.
@Test
public void TestBadSignum() {
System.out.println("Running TestBadSigum.");
// only 0, 1 are valid.
byte[] input = constructUpdateInput((byte) 0x0, (byte) 0x2);
PrecompiledTransactionResult res = tcc.execute(input, COST);
assertEquals("FAILURE", res.getStatus().causeOfError);
assertEquals(0L, res.getEnergyRemaining());
}
use of org.aion.precompiled.PrecompiledTransactionResult in project aion by aionnetwork.
the class TotalCurrencyContractTest method TestUpdateTotalAmount.
@Test
public void TestUpdateTotalAmount() {
System.out.println("Running TestUpdateTotalAmount.");
byte[] input = constructUpdateInput((byte) 0x0, (byte) 0x0);
PrecompiledTransactionResult res = tcc.execute(input, COST);
assertTrue(res.getStatus().isSuccess());
assertEquals(0L, res.getEnergyRemaining());
}
Aggregations