@Test
public void testHandleWithNextRequestSuccess() throws Throwable {

  runOnOtherThread(new Runnable() {
    @Override
    public void run() {
      try {
        // given
        final Context context = EmptyContext.getInstance()
            .withValue(GRPC_VALUE_CHAIN_ID_HASH_HOLDER, new ChainIdHashHolder());
        ContextHolder.attach(context);
        final InvalidChainIdHashHandler failoverHandler = new InvalidChainIdHashHandler();
        final ChainIdHash chainIdHash = ChainIdHash.of(BytesValue.EMPTY);
        final BlockchainMethods mockBlockchainMethods = mock(BlockchainMethods.class);
        final RequestMethod<BlockchainStatus> blockchainStatusRequestMethod = TestRequestMethod
            .success(BlockchainStatus.newBuilder().chainIdHash(chainIdHash).build());
        when(mockBlockchainMethods.getBlockchainStatus())
            .thenReturn(blockchainStatusRequestMethod);
        failoverHandler.blockchainMethods = mockBlockchainMethods;
        // then
        final Object expected = randomUUID().toString();
        final Invocation<Object> invocation = new TestInvocation<>(
            TestRequestMethod.success(expected));
        final Exception error = new CommitException(types.Rpc.CommitStatus.TX_INTERNAL_ERROR,
            "invalid chain id hash");
        final Response<Object> response = Response.fail(error);
        final Response<Object> handled = failoverHandler.handle(invocation, response);
        assertEquals(expected, handled.getValue());
      } finally {
        ContextHolder.remove();
      }
    }
  });
}