@Test
    void errorFromClientInStream() throws Exception {
        final BiConsumer<Status, Metadata> checkException = (status, meta) -> {
            // the cause is wrapped by CANCELLED
            assertThat(status).isNotNull();
            assertThat(status.getCode()).isEqualTo(Code.CANCELLED);
            assertThat(meta).isNotNull();
            assertThat(meta.keys()).isEmpty();
            // but the status holds original cause
            assertThat(status.getCause()).isInstanceOfSatisfying(StatusRuntimeException.class, ex -> {
                assertThat(ex.getStatus()).isNotNull();
                assertThat(ex.getStatus().getCode()).isEqualTo(Code.DATA_LOSS);
                assertThat(ex.getStatus().getDescription()).isEqualTo("data loss!");
                assertThat(ex.getStatus().getCause()).isNull();
                assertThat(ex.getTrailers()).isNotNull();
                assertThat(ex.getTrailers().getAll(INT_32_VALUE_KEY))
                        .containsExactly(Int32Value.newBuilder().setValue(1).build());
                assertThat(ex.getTrailers().get(CUSTOM_VALUE_KEY)).isEqualTo("string");
            });
        };
        final StreamRecorder<SimpleResponse> response = StreamRecorder.create();
        final StreamObserver<SimpleRequest> request = unitTestAsyncStub.errorFromClient(response);
        // Sending request and receiving response is required to ensure connection before calling onError.
        request.onNext(REQUEST_MESSAGE);
        response.firstValue().get();
        request.onError(UnitTestServiceImpl.buildExceptionWithMeta());
        response.awaitCompletion();
        assertThat(response.getError()).isInstanceOfSatisfying(
                StatusRuntimeException.class, ex -> checkException.accept(ex.getStatus(), ex.getTrailers()));

        checkRequestLogError((headers, rpcReq, cause) -> {
            assertThat(rpcReq).isNotNull();
            assertThat(rpcReq.serviceName()).isEqualTo("armeria.grpc.testing.UnitTestService");
            assertThat(rpcReq.method()).isEqualTo("ErrorFromClient");
            assertThat(rpcReq.params()).containsExactly(REQUEST_MESSAGE);
            assertThat(cause).isInstanceOfSatisfying(
                    StatusRuntimeException.class, ex -> checkException.accept(ex.getStatus(),
                                                                              ex.getTrailers()));
        });
    }
Must be at least {@link #unaryPayloadLength()}, plus some to account for encoding overhead.
grpc/src/test/java/com/linecorp/armeria/client/grpc/GrpcClientTest.java