use of org.ethereum.rpc.exception.RskJsonRpcRequestException in project rskj by rsksmart.
the class Web3InformationRetrieverTest method getTransactions_stateNotFound.
@Test
public void getTransactions_stateNotFound() {
Block block = mock(Block.class);
BlockHeader header = mock(BlockHeader.class);
when(block.getHeader()).thenReturn(header);
Keccak256 blockHash = new Keccak256(new byte[32]);
when(block.getHash()).thenReturn(blockHash);
when(blockchain.getBlockByNumber(4)).thenReturn(block);
RskJsonRpcRequestException e = TestUtils.assertThrows(RskJsonRpcRequestException.class, () -> target.getInformationProvider("0x4"));
assertEquals("State not found for block with hash " + blockHash.toString(), e.getMessage());
}
use of org.ethereum.rpc.exception.RskJsonRpcRequestException in project rskj by rsksmart.
the class EthModuleTest method sendTransaction_invalidSenderAccount_throwsRskJsonRpcRequestException.
@Test
public void sendTransaction_invalidSenderAccount_throwsRskJsonRpcRequestException() {
// Given
Constants constants = Constants.regtest();
Wallet wallet = new Wallet(new HashMapDB());
TransactionPool transactionPoolMock = mock(TransactionPool.class);
TransactionGateway transactionGatewayMock = mock(TransactionGateway.class);
CallArguments argsMock = mock(CallArguments.class);
RskAddress addressFrom = new RskAddress(new ECKey().getAddress());
// Address not in wallet
doReturn(addressFrom.toJsonString()).when(argsMock).getFrom();
EthModuleTransactionBase ethModuleTransaction = new EthModuleTransactionBase(constants, wallet, transactionPoolMock, transactionGatewayMock);
// Then
try {
ethModuleTransaction.sendTransaction(argsMock);
fail("RskJsonRpcRequestException should be thrown");
} catch (RskJsonRpcRequestException ex) {
verify(argsMock, times(2)).getFrom();
assertEquals("Could not find account for address: " + addressFrom.toJsonString(), ex.getMessage());
}
}
use of org.ethereum.rpc.exception.RskJsonRpcRequestException in project rskj by rsksmart.
the class ExecutionFoundBlockRetrieverTest method getByNumberInvalidBlockNumberHex.
@Test
public void getByNumberInvalidBlockNumberHex() {
when(blockchain.getBlockByNumber(123)).thenReturn(null);
RskJsonRpcRequestException e = TestUtils.assertThrows(RskJsonRpcRequestException.class, () -> retriever.retrieveExecutionBlock("0x7B"));
Assert.assertEquals(INVALID_PARAM_ERROR_CODE, (int) e.getCode());
}
use of org.ethereum.rpc.exception.RskJsonRpcRequestException in project rskj by rsksmart.
the class ExecutionFoundBlockRetrieverTest method getByNumberInvalidDec.
@Test
public void getByNumberInvalidDec() {
RskJsonRpcRequestException e = TestUtils.assertThrows(RskJsonRpcRequestException.class, () -> retriever.retrieveExecutionBlock("zz"));
Assert.assertEquals(INVALID_PARAM_ERROR_CODE, (int) e.getCode());
verify(blockchain, never()).getBlockByNumber(any(long.class));
}
use of org.ethereum.rpc.exception.RskJsonRpcRequestException in project rskj by rsksmart.
the class ExecutionFoundBlockRetrieverTest method getOtherThanPendingLatestOrNumberThrows.
@Test
public void getOtherThanPendingLatestOrNumberThrows() {
RskJsonRpcRequestException e = TestUtils.assertThrows(RskJsonRpcRequestException.class, () -> retriever.retrieveExecutionBlock("other"));
Assert.assertEquals(INVALID_PARAM_ERROR_CODE, (int) e.getCode());
}
Aggregations