use of org.aion.rpc.types.RPCTypes.MinerStats in project aion by aionnetwork.
the class MiningRPCImplTest method testGetMinerStatsMock.
@Test
public void testGetMinerStatsMock() {
MinerStats minerStats = execute(buildRequest("getMinerStatistics", AddressParamsConverter.encode(new AddressParams(AddressConverter.decode("0xa0c5bf6c4779bf8c2e0a3ff71353d09b066db2b5876ee2345efb836510b3126b")))), MinerStatsConverter::decode);
assertNotNull(minerStats);
assertEquals("1", minerStats.minerHashrate);
assertEquals("1", minerStats.minerHashrateShare);
assertEquals("1", minerStats.networkHashRate);
}
use of org.aion.rpc.types.RPCTypes.MinerStats in project aion by aionnetwork.
the class MiningRPCImplTest method setup.
@Before
public void setup() {
ChainHolder chainHolder = mock(ChainHolder.class);
MinerStatisticsCalculator minerStatisticsCalculator = mock(MinerStatisticsCalculator.class);
doReturn(new MinerStats(BigInteger.ONE.toString(), BigInteger.ONE.toString(), BigInteger.ONE.toString())).when(minerStatisticsCalculator).getStats(any());
rpcMethods = new RPCMethods(chainHolder, minerStatisticsCalculator);
// Set up mocks
doReturn(true).when(chainHolder).canSeal(blockThatCanBeSealed.toBytes());
doReturn(true).when(chainHolder).canSeal(blockThatCannotBeSealed.toBytes());
doReturn(false).when(chainHolder).canSeal(blockThatDoesNotExistInCache.toBytes());
doReturn(true).when(chainHolder).canSeal(blockThatWillThrow.toBytes());
doReturn(true).when(chainHolder).submitBlock(nonce.toBytes(), equihashSolution.toBytes(), blockThatCanBeSealed.toBytes());
doReturn(false).when(chainHolder).submitBlock(nonce.toBytes(), equihashSolution.toBytes(), blockThatCannotBeSealed.toBytes());
doThrow(RuntimeException.class).when(chainHolder).submitBlock(nonce.toBytes(), equihashSolution.toBytes(), blockThatWillThrow.toBytes());
}
Aggregations