Search in sources :

Example 1 with MinerStats

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);
}
Also used : MinerStatsConverter(org.aion.rpc.types.RPCTypesConverter.MinerStatsConverter) AddressParams(org.aion.rpc.types.RPCTypes.AddressParams) MinerStats(org.aion.rpc.types.RPCTypes.MinerStats) Test(org.junit.Test)

Example 2 with MinerStats

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());
}
Also used : MinerStats(org.aion.rpc.types.RPCTypes.MinerStats) Before(org.junit.Before)

Aggregations

MinerStats (org.aion.rpc.types.RPCTypes.MinerStats)2 AddressParams (org.aion.rpc.types.RPCTypes.AddressParams)1 MinerStatsConverter (org.aion.rpc.types.RPCTypesConverter.MinerStatsConverter)1 Before (org.junit.Before)1 Test (org.junit.Test)1