|
|
|
@ -83,9 +83,9 @@ public class EthEstimateGasTest { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void shouldReturnGasEstimateWhenTransientTransactionProcessorReturnsResult() { |
|
|
|
|
public void shouldReturnGasEstimateWhenTransientTransactionProcessorReturnsResultSuccess() { |
|
|
|
|
final JsonRpcRequestContext request = ethEstimateGasRequest(callParameter()); |
|
|
|
|
mockTransientProcessorResultGasEstimate(1L); |
|
|
|
|
mockTransientProcessorResultGasEstimate(1L, true); |
|
|
|
|
|
|
|
|
|
final JsonRpcResponse expectedResponse = new JsonRpcSuccessResponse(null, Quantity.create(1L)); |
|
|
|
|
|
|
|
|
@ -93,11 +93,25 @@ public class EthEstimateGasTest { |
|
|
|
|
.isEqualToComparingFieldByField(expectedResponse); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void mockTransientProcessorResultGasEstimate(final long gasEstimate) { |
|
|
|
|
@Test |
|
|
|
|
public void shouldReturnGasEstimateErrorWhenTransientTransactionProcessorReturnsResultFailure() { |
|
|
|
|
final JsonRpcRequestContext request = ethEstimateGasRequest(callParameter()); |
|
|
|
|
mockTransientProcessorResultGasEstimate(1L, false); |
|
|
|
|
|
|
|
|
|
final JsonRpcResponse expectedResponse = |
|
|
|
|
new JsonRpcErrorResponse(null, JsonRpcError.INTERNAL_ERROR); |
|
|
|
|
|
|
|
|
|
Assertions.assertThat(method.response(request)) |
|
|
|
|
.isEqualToComparingFieldByField(expectedResponse); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void mockTransientProcessorResultGasEstimate( |
|
|
|
|
final long gasEstimate, final boolean isSuccessful) { |
|
|
|
|
final TransactionSimulatorResult result = mock(TransactionSimulatorResult.class); |
|
|
|
|
when(result.getGasEstimate()).thenReturn(gasEstimate); |
|
|
|
|
when(transactionSimulator.process(eq(modifiedCallParameter()), eq(1L))) |
|
|
|
|
.thenReturn(Optional.of(result)); |
|
|
|
|
when(result.isSuccessful()).thenReturn(isSuccessful); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private JsonCallParameter callParameter() { |
|
|
|
|