use of org.ethereum.rpc.exception.RskJsonRpcRequestException in project rskj by rsksmart.
the class Web3InformationRetrieverTest method getState_blockNotFound.
@Test
public void getState_blockNotFound() {
RskJsonRpcRequestException e = TestUtils.assertThrows(RskJsonRpcRequestException.class, () -> target.getInformationProvider("0x4"));
assertEquals("Block 0x4 not found", e.getMessage());
}
use of org.ethereum.rpc.exception.RskJsonRpcRequestException in project rskj by rsksmart.
the class Web3ImplTest method unlockAccountInvalidDuration.
@Test
public void unlockAccountInvalidDuration() {
Web3Impl web3 = createWeb3();
String addr = web3.personal_newAccount("passphrase1");
web3.personal_lockAccount(addr);
RskJsonRpcRequestException e = TestUtils.assertThrows(RskJsonRpcRequestException.class, () -> web3.personal_unlockAccount(addr, "passphrase1", "K"));
assertEquals(-32602, (int) e.getCode());
}
use of org.ethereum.rpc.exception.RskJsonRpcRequestException in project rskj by rsksmart.
the class Web3ImplScoringTest method addBannedAddressWithInvalidMask.
@Test
public void addBannedAddressWithInvalidMask() {
PeerScoringManager peerScoringManager = createPeerScoringManager();
Web3Impl web3 = createWeb3(peerScoringManager);
RskJsonRpcRequestException ex = TestUtils.assertThrows(RskJsonRpcRequestException.class, () -> web3.sco_banAddress("192.168.56.1/a"));
Assert.assertEquals("invalid banned address 192.168.56.1/a", ex.getMessage());
}
use of org.ethereum.rpc.exception.RskJsonRpcRequestException in project rskj by rsksmart.
the class Web3ImplScoringTest method banningLocalIPv4AddressThrowsException.
@Test
public void banningLocalIPv4AddressThrowsException() throws UnknownHostException {
PeerScoringManager peerScoringManager = createPeerScoringManager();
Web3Impl web3 = createWeb3(peerScoringManager);
// generate a random local IPv4 address
InetAddress address = generateLocalIPAddressV4();
Assert.assertTrue(peerScoringManager.hasGoodReputation(address));
RskJsonRpcRequestException e = TestUtils.assertThrows(RskJsonRpcRequestException.class, () -> {
web3.sco_banAddress(address.getHostAddress());
});
Assert.assertEquals(-32602, (int) e.getCode());
}
use of org.ethereum.rpc.exception.RskJsonRpcRequestException in project rskj by rsksmart.
the class Web3ImplUnitTest method eth_getUncleCountByBlockHash_blockNotFound.
@Test
public void eth_getUncleCountByBlockHash_blockNotFound() {
String hash = "0x4A54";
byte[] bytesHash = TypeConverter.stringHexToByteArray(hash);
when(blockchain.getBlockByHash(eq(bytesHash))).thenReturn(null);
RskJsonRpcRequestException exception = TestUtils.assertThrows(RskJsonRpcRequestException.class, () -> target.eth_getUncleCountByBlockHash(hash));
assertEquals(-32600, (int) exception.getCode());
}
Aggregations