diff --git a/Firestore/core/src/firebase/firestore/remote/datastore.h b/Firestore/core/src/firebase/firestore/remote/datastore.h index 6f9c2f806d3..93bc03e5179 100644 --- a/Firestore/core/src/firebase/firestore/remote/datastore.h +++ b/Firestore/core/src/firebase/firestore/remote/datastore.h @@ -105,14 +105,14 @@ class Datastore : public std::enable_shared_from_this { void PollGrpcQueue(); void CommitMutationsWithCredentials(const auth::Token& token, - const grpc::ByteBuffer& message, + NSArray* mutations, FSTVoidErrorBlock completion); void OnCommitMutationsResponse(const util::StatusOr& result, FSTVoidErrorBlock completion); void LookupDocumentsWithCredentials( const auth::Token& token, - const grpc::ByteBuffer& message, + const std::vector& keys, FSTVoidMaybeDocumentArrayErrorBlock completion); void OnLookupDocumentsResponse( const util::StatusOr>& result, diff --git a/Firestore/core/src/firebase/firestore/remote/datastore.mm b/Firestore/core/src/firebase/firestore/remote/datastore.mm index 5fea1ee7b98..fc0f3453389 100644 --- a/Firestore/core/src/firebase/firestore/remote/datastore.mm +++ b/Firestore/core/src/firebase/firestore/remote/datastore.mm @@ -148,23 +148,23 @@ void LogGrpcCallFinished(absl::string_view rpc_name, void Datastore::CommitMutations(NSArray* mutations, FSTVoidErrorBlock completion) { - grpc::ByteBuffer message = serializer_bridge_.ToByteBuffer( - serializer_bridge_.CreateCommitRequest(mutations)); - ResumeRpcWithCredentials( - [this, message, completion](const StatusOr& maybe_credentials) { + [this, mutations, completion](const StatusOr& maybe_credentials) { if (!maybe_credentials.ok()) { completion(util::MakeNSError(maybe_credentials.status())); return; } - CommitMutationsWithCredentials(maybe_credentials.ValueOrDie(), message, - completion); + CommitMutationsWithCredentials(maybe_credentials.ValueOrDie(), + mutations, completion); }); } void Datastore::CommitMutationsWithCredentials(const Token& token, - const grpc::ByteBuffer& message, + NSArray* mutations, FSTVoidErrorBlock completion) { + grpc::ByteBuffer message = serializer_bridge_.ToByteBuffer( + serializer_bridge_.CreateCommitRequest(mutations)); + std::unique_ptr call_owning = grpc_connection_.CreateUnaryCall( kRpcNameCommit, token, std::move(message)); GrpcUnaryCall* call = call_owning.get(); @@ -193,24 +193,24 @@ void LogGrpcCallFinished(absl::string_view rpc_name, void Datastore::LookupDocuments( const std::vector& keys, FSTVoidMaybeDocumentArrayErrorBlock completion) { - grpc::ByteBuffer message = serializer_bridge_.ToByteBuffer( - serializer_bridge_.CreateLookupRequest(keys)); - ResumeRpcWithCredentials( - [this, message, completion](const StatusOr& maybe_credentials) { + [this, keys, completion](const StatusOr& maybe_credentials) { if (!maybe_credentials.ok()) { completion(nil, util::MakeNSError(maybe_credentials.status())); return; } - LookupDocumentsWithCredentials(maybe_credentials.ValueOrDie(), message, + LookupDocumentsWithCredentials(maybe_credentials.ValueOrDie(), keys, completion); }); } void Datastore::LookupDocumentsWithCredentials( const Token& token, - const grpc::ByteBuffer& message, + const std::vector& keys, FSTVoidMaybeDocumentArrayErrorBlock completion) { + grpc::ByteBuffer message = serializer_bridge_.ToByteBuffer( + serializer_bridge_.CreateLookupRequest(keys)); + std::unique_ptr call_owning = grpc_connection_.CreateStreamingReader(kRpcNameLookup, token, std::move(message)); diff --git a/Firestore/core/test/firebase/firestore/remote/datastore_test.mm b/Firestore/core/test/firebase/firestore/remote/datastore_test.mm index 25434d1049e..13504678179 100644 --- a/Firestore/core/test/firebase/firestore/remote/datastore_test.mm +++ b/Firestore/core/test/firebase/firestore/remote/datastore_test.mm @@ -146,10 +146,7 @@ void Shutdown() { EXPECT_NO_THROW(credentials.InvokeGetToken()); } -// TODO(varconst): this test currently fails due to a gRPC issue, see here -// https://github.com/firebase/firebase-ios-sdk/pull/1935#discussion_r224900667 -// for details. Reenable when/if possible. -TEST_F(DatastoreTest, DISABLED_AuthOutlivesDatastore) { +TEST_F(DatastoreTest, AuthOutlivesDatastore) { credentials.DelayGetToken(); worker_queue.EnqueueBlocking([&] {