Search in sources :

Example 41 with PrecompiledTransactionContext

use of org.aion.precompiled.type.PrecompiledTransactionContext in project aion by aionnetwork.

the class EDVerifyContractTest method shouldReturnSuccessTestingWith256.

@Test
public void shouldReturnSuccessTestingWith256() {
    byte[] input = setupInput();
    PrecompiledTransactionContext ctx = new PrecompiledTransactionContext(ContractInfo.ED_VERIFY.contractAddress, origin, caller, Collections.emptyList(), Collections.emptyList(), Collections.emptyList(), txHash, txHash, blockNumber, nrgLimit, depth);
    PrecompiledContract contract = new ContractFactory().getPrecompiledContract(ctx, externalStateForTests);
    assertNotNull(contract);
    PrecompiledTransactionResult result = contract.execute(input, 21000L);
    assertThat(result.getStatus().isSuccess());
    assertThat(Arrays.equals(result.getReturnData(), ownerAddr));
}
Also used : PrecompiledContract(org.aion.precompiled.type.PrecompiledContract) PrecompiledTransactionResult(org.aion.precompiled.PrecompiledTransactionResult) PrecompiledTransactionContext(org.aion.precompiled.type.PrecompiledTransactionContext) ContractFactory(org.aion.precompiled.ContractFactory) Test(org.junit.Test)

Example 42 with PrecompiledTransactionContext

use of org.aion.precompiled.type.PrecompiledTransactionContext in project aion by aionnetwork.

the class BridgeControllerOwnerTest method beforeEach.

@Before
public void beforeEach() {
    IExternalStateForPrecompiled worldState = ExternalStateForTests.usingDefaultRepository();
    this.connector = new BridgeStorageConnector(worldState, CONTRACT_ADDR);
    PrecompiledTransactionContext context = dummyContext();
    this.logs = context.getLogs();
    this.controller = new BridgeController(connector, this.logs, CONTRACT_ADDR, OWNER_ADDR);
}
Also used : IExternalStateForPrecompiled(org.aion.precompiled.type.IExternalStateForPrecompiled) PrecompiledTransactionContext(org.aion.precompiled.type.PrecompiledTransactionContext) Before(org.junit.Before)

Aggregations

PrecompiledTransactionContext (org.aion.precompiled.type.PrecompiledTransactionContext)42 PrecompiledTransactionResult (org.aion.precompiled.PrecompiledTransactionResult)39 Test (org.junit.Test)37 AionAddress (org.aion.types.AionAddress)28 BridgeTransfer (org.aion.precompiled.contracts.ATB.BridgeTransfer)14 ECKey (org.aion.crypto.ECKey)11 TokenBridgeContract (org.aion.precompiled.contracts.ATB.TokenBridgeContract)11 AbiEncoder (org.aion.precompiled.encoding.AbiEncoder)11 AddressFVM (org.aion.precompiled.encoding.AddressFVM)11 ListFVM (org.aion.precompiled.encoding.ListFVM)11 Uint128FVM (org.aion.precompiled.encoding.Uint128FVM)11 PrecompiledContract (org.aion.precompiled.type.PrecompiledContract)11 AbiEncoder (org.aion.zero.impl.precompiled.encoding.AbiEncoder)11 AddressFVM (org.aion.zero.impl.precompiled.encoding.AddressFVM)11 ListFVM (org.aion.zero.impl.precompiled.encoding.ListFVM)11 Uint128FVM (org.aion.zero.impl.precompiled.encoding.Uint128FVM)11 ContractFactory (org.aion.precompiled.ContractFactory)10 BigInteger (java.math.BigInteger)6 InternalTransaction (org.aion.types.InternalTransaction)6 Log (org.aion.types.Log)6