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