Search in sources :

Example 6 with RskJsonRpcRequestException

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());
}
Also used : RskJsonRpcRequestException(org.ethereum.rpc.exception.RskJsonRpcRequestException) Test(org.junit.Test)

Example 7 with RskJsonRpcRequestException

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());
}
Also used : RskJsonRpcRequestException(org.ethereum.rpc.exception.RskJsonRpcRequestException) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 8 with RskJsonRpcRequestException

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());
}
Also used : RskJsonRpcRequestException(org.ethereum.rpc.exception.RskJsonRpcRequestException) Test(org.junit.Test)

Example 9 with RskJsonRpcRequestException

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());
}
Also used : RskJsonRpcRequestException(org.ethereum.rpc.exception.RskJsonRpcRequestException) InetAddress(java.net.InetAddress) Test(org.junit.Test)

Example 10 with RskJsonRpcRequestException

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());
}
Also used : RskJsonRpcRequestException(org.ethereum.rpc.exception.RskJsonRpcRequestException) Test(org.junit.Test)

Aggregations

RskJsonRpcRequestException (org.ethereum.rpc.exception.RskJsonRpcRequestException)19 Test (org.junit.Test)19 CallArguments (org.ethereum.rpc.CallArguments)4 InetAddress (java.net.InetAddress)2 BridgeConstants (co.rsk.config.BridgeConstants)1 ReversibleTransactionExecutor (co.rsk.core.ReversibleTransactionExecutor)1 RskAddress (co.rsk.core.RskAddress)1 Wallet (co.rsk.core.Wallet)1 BlockResult (co.rsk.core.bc.BlockResult)1 Keccak256 (co.rsk.crypto.Keccak256)1 TransactionGateway (co.rsk.net.TransactionGateway)1 BridgeSupportFactory (co.rsk.peg.BridgeSupportFactory)1 ExecutionBlockRetriever (co.rsk.rpc.ExecutionBlockRetriever)1 World (co.rsk.test.World)1 DslParser (co.rsk.test.dsl.DslParser)1 WorldDslProcessor (co.rsk.test.dsl.WorldDslProcessor)1 Constants (org.ethereum.config.Constants)1 Block (org.ethereum.core.Block)1 Transaction (org.ethereum.core.Transaction)1 TransactionPool (org.ethereum.core.TransactionPool)1