Search in sources :

Example 71 with AccountState

use of org.aion.base.AccountState in project aion by aionnetwork.

the class OpsRPCImplTest method setup.

@Before
public void setup() {
    emptyPowBlock = MiningBlock.newEmptyBlock();
    emptyPowBlock.setMainChain();
    AionTxReceipt receipt = new AionTxReceipt();
    ECKey ecKey = ECKeyFac.inst().create();
    receipt.setError("");
    receipt.setExecutionResult(HashUtil.h256(BigInteger.ONE.toByteArray()));
    List<Log> infos = new ArrayList<>();
    receipt.setLogs(infos);
    receipt.setPostTxState(HashUtil.h256(BigInteger.ONE.toByteArray()));
    txInfo = AionTxInfo.newInstanceWithInternalTransactions(receipt, ByteArrayWrapper.wrap(HashUtil.h256(BigInteger.ZERO.toByteArray())), 0, Collections.emptyList());
    txInfo.getReceipt().setTransaction(AionTransaction.create(ecKey, BigInteger.ZERO.toByteArray(), new AionAddress(ecKey.getAddress()), BigInteger.ZERO.toByteArray(), BigInteger.ZERO.toByteArray(), 10, 10, (byte) 0b1, HashUtil.h256(BigInteger.ZERO.toByteArray())));
    transactionHash = ByteArray.wrap(txInfo.getReceipt().getTransaction().getTransactionHash());
    txList.add(txInfo.getReceipt().getTransaction());
    StakingBlockHeader.Builder builder = StakingBlockHeader.Builder.newInstance().withDefaultCoinbase().withDefaultDifficulty().withDefaultExtraData().withDefaultLogsBloom().withDefaultParentHash().withDefaultReceiptTrieRoot().withDefaultSeed().withDefaultSignature().withDefaultSigningPublicKey().withDefaultStateRoot().withDefaultTxTrieRoot();
    emptyPosBlock = new StakingBlock(builder.build(), txList);
    doReturn(BigInteger.ONE).when(holder).calculateReward(any());
    doReturn(emptyPowBlock).when(holder).getBlockByNumber(1);
    doReturn(emptyPosBlock).when(holder).getBlockByNumber(2);
    doReturn(emptyPosBlock).when(holder).getBlockByHash(emptyPosBlock.getHash());
    doReturn(emptyPowBlock).when(holder).getBlockByHash(emptyPowBlock.getHash());
    doReturn(emptyPowBlock).when(holder).getBestBlock();
    doReturn(txInfo).when(holder).getTransactionInfo(any());
    doReturn(emptyPosBlock).when(holder).getBlockByHash(eq(ByteArrayWrapper.wrap(HashUtil.h256(BigInteger.ZERO.toByteArray())).toBytes()));
    doReturn(BigInteger.ONE).when(holder).getTotalDifficultyByHash(any());
    doReturn(new AccountState(BigInteger.TEN, BigInteger.TEN)).when(holder).getAccountState(any());
}
Also used : AionAddress(org.aion.types.AionAddress) Log(org.aion.types.Log) StakingBlockHeader(org.aion.zero.impl.types.StakingBlockHeader) ArrayList(java.util.ArrayList) ECKey(org.aion.crypto.ECKey) AionTxReceipt(org.aion.base.AionTxReceipt) AccountState(org.aion.base.AccountState) StakingBlock(org.aion.zero.impl.types.StakingBlock) Before(org.junit.Before)

Aggregations

AccountState (org.aion.base.AccountState)71 AionAddress (org.aion.types.AionAddress)54 Test (org.junit.Test)46 AionTransaction (org.aion.base.AionTransaction)40 RepositoryCache (org.aion.base.db.RepositoryCache)38 AionTxExecSummary (org.aion.base.AionTxExecSummary)37 Block (org.aion.zero.impl.types.Block)21 ImportResult (org.aion.zero.impl.core.ImportResult)20 BigInteger (java.math.BigInteger)18 InternalTransaction (org.aion.types.InternalTransaction)17 AionBlockchainImpl.getPostExecutionWorkForGeneratePreBlock (org.aion.zero.impl.blockchain.AionBlockchainImpl.getPostExecutionWorkForGeneratePreBlock)16 AionTxReceipt (org.aion.base.AionTxReceipt)11 AionBlockSummary (org.aion.zero.impl.types.AionBlockSummary)10 ArrayList (java.util.ArrayList)8 InternalVmType (org.aion.base.InternalVmType)5 IOException (java.io.IOException)4 HashMap (java.util.HashMap)4 Map (java.util.Map)4 JSONObject (org.json.JSONObject)4 Hex.toHexString (org.aion.util.conversions.Hex.toHexString)3