use of org.ethereum.rpc.exception.RskJsonRpcRequestException in project rskj by rsksmart.
the class ExecutionFoundBlockRetrieverTest method getByNumberInvalidHex.
@Test
public void getByNumberInvalidHex() {
RskJsonRpcRequestException e = TestUtils.assertThrows(RskJsonRpcRequestException.class, () -> retriever.retrieveExecutionBlock("0xzz"));
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 Web3InformationRetrieverTest method getBlock_invalidIdentifier.
@Test
public void getBlock_invalidIdentifier() {
RskJsonRpcRequestException e = TestUtils.assertThrows(RskJsonRpcRequestException.class, () -> target.getBlock("pending2"));
assertEquals(INVALID_PARAM_ERROR_CODE, (int) e.getCode());
}
use of org.ethereum.rpc.exception.RskJsonRpcRequestException in project rskj by rsksmart.
the class Web3InformationRetrieverTest method getTransactions_blockNotFound.
@Test
public void getTransactions_blockNotFound() {
RskJsonRpcRequestException e = TestUtils.assertThrows(RskJsonRpcRequestException.class, () -> target.getTransactions("0x3"));
assertEquals(-32600, (int) e.getCode());
}
use of org.ethereum.rpc.exception.RskJsonRpcRequestException in project rskj by rsksmart.
the class NestedContractsTest method testNested_interfaceCall_require.
/**
* ------------------------ **
* TESTS
** ------------------------ *
*/
@Test
public void testNested_interfaceCall_require() throws FileNotFoundException, DslProcessorException {
processor.processCommands(DslParser.fromResource("dsl/contract_call/contract_nested_interface_calls.txt"));
assertFalse(world.getTransactionReceiptByName("tx04").isSuccessful());
assertTrue(world.getTransactionReceiptByName("tx05").isSuccessful());
// Assert state: RevertReason.a
assertEquals(DataWord.valueOf(11), getStorageValue(TX_CONTRACTRR, BLOCK_CONTRACT_CREATE, DataWord.ZERO));
assertEquals(DataWord.valueOf(11), getStorageValue(TX_CONTRACTRR, BLOCK_TRANSACTION_FAIL, DataWord.ZERO));
assertEquals(DataWord.valueOf(2), getStorageValue(TX_CONTRACTRR, BLOCK_TRANSACTION_SUCCESS, DataWord.ZERO));
// Assert state: ContractB.a
assertEquals(DataWord.valueOf(11), getStorageValue(TX_CONTRACTB, BLOCK_CONTRACT_CREATE, DataWord.ONE));
assertEquals(DataWord.valueOf(11), getStorageValue(TX_CONTRACTB, BLOCK_TRANSACTION_FAIL, DataWord.ONE));
assertEquals(DataWord.valueOf(2), getStorageValue(TX_CONTRACTB, BLOCK_TRANSACTION_SUCCESS, DataWord.ONE));
// Assert state: ContractA.a
assertEquals(DataWord.valueOf(11), getStorageValue(TX_CONTRACTA, BLOCK_CONTRACT_CREATE, DataWord.ONE));
assertEquals(DataWord.valueOf(11), getStorageValue(TX_CONTRACTA, BLOCK_TRANSACTION_FAIL, DataWord.ONE));
assertEquals(DataWord.valueOf(2), getStorageValue(TX_CONTRACTA, BLOCK_TRANSACTION_SUCCESS, DataWord.ONE));
// Failed Call ContractA.buy(0) -> 0 > 0
final String contractA = getContractAddressString(TX_CONTRACTA);
CallArguments args = buildArgs(contractA, Hex.toHexString(BUY_FUNCTION.encode(0)));
try {
ethModule.call(args, "latest");
fail();
} catch (RskJsonRpcRequestException e) {
assertThat(e.getMessage(), Matchers.containsString("Negative value"));
}
// Success Call -> 2 > 0
args = buildArgs(contractA, Hex.toHexString(BUY_FUNCTION.encode(2)));
final String call = ethModule.call(args, "latest");
// assertEquals("0x" + DataWord.valueOf(2).toString(), call);
}
Aggregations