public async Task BeginTransactionAsync() { Mock <Datastore.DatastoreClient> mockGrpcClient = new Mock <Datastore.DatastoreClient>(MockBehavior.Strict); BeginTransactionRequest expectedRequest = new BeginTransactionRequest { ProjectId = "projectId-1969970175", }; BeginTransactionResponse expectedResponse = new BeginTransactionResponse { Transaction = ByteString.CopyFromUtf8("-34"), }; mockGrpcClient.Setup(x => x.BeginTransactionAsync(expectedRequest, It.IsAny <CallOptions>())) .Returns(new Grpc.Core.AsyncUnaryCall <BeginTransactionResponse>(Task.FromResult(expectedResponse), null, null, null, null)); DatastoreClient client = new DatastoreClientImpl(mockGrpcClient.Object, null); string projectId = "projectId-1969970175"; BeginTransactionResponse response = await client.BeginTransactionAsync(projectId); Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public void NonRetriableRpcException() { ByteString token1 = ByteString.CopyFromUtf8("token1"); ByteString token2 = ByteString.CopyFromUtf8("token2"); var sequence = new TestSequence(); sequence.ExpectConnect(null, StreamInitializationCause.WatchStarting); sequence.ProvideResponse(WatchResponseResult.Continue); sequence.ProvideResponse(WatchResponseResult.StreamHealthy, token1); sequence.ProvideResponse(WatchResponseResult.StreamHealthy, token2); // This exception is not retriable. var exception = new RpcException(new Status(StatusCode.InvalidArgument, "This exception is permanent")); sequence.RpcException(exception); Task task = sequence.RunToStability(); Assert.Equal(TaskStatus.Faulted, task.Status); Assert.Equal(exception, task.Exception.InnerException); sequence.Verify(); }
public async Task BeginTransactionAsync() { Mock <Firestore.FirestoreClient> mockGrpcClient = new Mock <Firestore.FirestoreClient>(MockBehavior.Strict); BeginTransactionRequest expectedRequest = new BeginTransactionRequest { Database = new DatabaseRootName("[PROJECT]", "[DATABASE]").ToString(), }; BeginTransactionResponse expectedResponse = new BeginTransactionResponse { Transaction = ByteString.CopyFromUtf8("-34"), }; mockGrpcClient.Setup(x => x.BeginTransactionAsync(expectedRequest, It.IsAny <CallOptions>())) .Returns(new Grpc.Core.AsyncUnaryCall <BeginTransactionResponse>(Task.FromResult(expectedResponse), null, null, null, null)); FirestoreClient client = new FirestoreClientImpl(mockGrpcClient.Object, null); string formattedDatabase = new DatabaseRootName("[PROJECT]", "[DATABASE]").ToString(); BeginTransactionResponse response = await client.BeginTransactionAsync(formattedDatabase); Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public void ParseResume2() { Mock <ResumeService.ResumeServiceClient> mockGrpcClient = new Mock <ResumeService.ResumeServiceClient>(MockBehavior.Strict); ParseResumeRequest request = new ParseResumeRequest { Parent = new ProjectName("[PROJECT]").ToString(), Resume = ByteString.CopyFromUtf8("45"), }; ParseResumeResponse expectedResponse = new ParseResumeResponse { RawText = "rawText503586532", }; mockGrpcClient.Setup(x => x.ParseResume(request, It.IsAny <CallOptions>())) .Returns(expectedResponse); ResumeServiceClient client = new ResumeServiceClientImpl(mockGrpcClient.Object, null); ParseResumeResponse response = client.ParseResume(request); Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public async Task GetIamPolicyAsync2() { Mock <ContainerAnalysisV1Beta1.ContainerAnalysisV1Beta1Client> mockGrpcClient = new Mock <ContainerAnalysisV1Beta1.ContainerAnalysisV1Beta1Client>(MockBehavior.Strict); GetIamPolicyRequest request = new GetIamPolicyRequest { ResourceAsIamResourceNameOneof = IamResourceNameOneof.From(new NoteName("[PROJECT]", "[NOTE]")), }; Policy expectedResponse = new Policy { Version = 351608024, Etag = ByteString.CopyFromUtf8("21"), }; mockGrpcClient.Setup(x => x.GetIamPolicyAsync(request, It.IsAny <CallOptions>())) .Returns(new Grpc.Core.AsyncUnaryCall <Policy>(Task.FromResult(expectedResponse), null, null, null, null)); ContainerAnalysisV1Beta1Client client = new ContainerAnalysisV1Beta1ClientImpl(mockGrpcClient.Object, null); Policy response = await client.GetIamPolicyAsync(request); Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public override Task <StartResponse> Start(StartRequest request, ServerCallContext context) { Console.WriteLine("Start called."); mutex = new Mutex(); sequenceNumber = 0; latencies = new List <long>(); clientId = (new Random()).Next().ToString(); messageData = ByteString.CopyFromUtf8(new string('A', request.MessageSize)); batchSize = request.PublishBatchSize; Console.WriteLine("Initializing client."); try { client = Google.Cloud.PubSub.V1.SimplePublisher.CreateAsync(new Google.Cloud.PubSub.V1.TopicName(request.Project, request.Topic), null, new Google.Cloud.PubSub.V1.SimplePublisher.Settings { BatchingSettings = new Google.Api.Gax.BatchingSettings(batchSize, 9500000 /* 9.5 MB */, TimeSpan.FromMilliseconds(request.PublishBatchDuration.Seconds * 1000 + request.PublishBatchDuration.Nanos / 1000000.0)) }).Result; } catch (Exception e) { Console.WriteLine("Error initializing client: " + e.ToString()); } Console.WriteLine("Start returning."); return(Task.FromResult(new StartResponse())); }
public async Task ImportPrivateKeyAsync(Account account, string privateKeyWif, bool rescan, string passphrase) { if (privateKeyWif == null) { throw new ArgumentNullException(nameof(privateKeyWif)); } if (passphrase == null) { throw new ArgumentNullException(nameof(passphrase)); } var client = WalletService.NewClient(_channel); var request = new ImportPrivateKeyRequest { Account = account.AccountNumber, PrivateKeyWif = privateKeyWif, Rescan = rescan, Passphrase = ByteString.CopyFromUtf8(passphrase), // Poorly named: this outputs UTF8 from a UTF16 System.String }; await client.ImportPrivateKeyAsync(request, cancellationToken : _tokenSource.Token); }
public void EqualsMethodWithClear() { // preparation var instance = new TEKSignature(); instance.BatchNum = 99; instance.BatchSize = 99; instance.Signature = ByteString.CopyFromUtf8("Signature"); instance.SignatureInfo = new SignatureInfo(); var actual = instance.Clone(); // action assert actual.ClearBatchNum(); Assert.AreNotEqual(instance, actual); actual = instance.Clone(); actual.ClearBatchSize(); Assert.AreNotEqual(instance, actual); actual = instance.Clone(); actual.ClearSignature(); Assert.AreNotEqual(instance, actual); }
public void GetIamPolicy2() { Mock <ContainerAnalysis.ContainerAnalysisClient> mockGrpcClient = new Mock <ContainerAnalysis.ContainerAnalysisClient>(MockBehavior.Strict); GetIamPolicyRequest request = new GetIamPolicyRequest { ResourceAsResourceName = IamResourceNameOneof.From(new NoteName("[PROJECT]", "[NOTE]")), }; Policy expectedResponse = new Policy { Version = 351608024, Etag = ByteString.CopyFromUtf8("21"), }; mockGrpcClient.Setup(x => x.GetIamPolicy(request, It.IsAny <CallOptions>())) .Returns(expectedResponse); ContainerAnalysisClient client = new ContainerAnalysisClientImpl(mockGrpcClient.Object, null); Policy response = client.GetIamPolicy(request); Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public void ComputeThreatListDiff2() { Mock <WebRiskServiceV1Beta1.WebRiskServiceV1Beta1Client> mockGrpcClient = new Mock <WebRiskServiceV1Beta1.WebRiskServiceV1Beta1Client>(MockBehavior.Strict); ComputeThreatListDiffRequest request = new ComputeThreatListDiffRequest { ThreatType = ThreatType.Unspecified, Constraints = new ComputeThreatListDiffRequest.Types.Constraints(), }; ComputeThreatListDiffResponse expectedResponse = new ComputeThreatListDiffResponse { NewVersionToken = ByteString.CopyFromUtf8("115"), }; mockGrpcClient.Setup(x => x.ComputeThreatListDiff(request, It.IsAny <CallOptions>())) .Returns(expectedResponse); WebRiskServiceV1Beta1Client client = new WebRiskServiceV1Beta1ClientImpl(mockGrpcClient.Object, null); ComputeThreatListDiffResponse response = client.ComputeThreatListDiff(request); Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }
private PersistentPayload.Builder PersistentPayloadToProto(object payload) { if (TransportInformation != null) { Akka.Serialization.Serialization.CurrentTransportInformation = TransportInformation; } var serializer = system.Serialization.FindSerializerFor(payload); var builder = PersistentPayload.CreateBuilder(); if (serializer.IncludeManifest) { builder.SetPayloadManifest(ByteString.CopyFromUtf8(payload.GetType().FullName)); } builder .SetPayload(ByteString.CopyFrom(serializer.ToBinary(payload))) .SetSerializerId(serializer.Identifier); return(builder); }
public async Task GetIamPolicyAsync2() { Mock <BigtableTableAdmin.BigtableTableAdminClient> mockGrpcClient = new Mock <BigtableTableAdmin.BigtableTableAdminClient>(MockBehavior.Strict); GetIamPolicyRequest request = new GetIamPolicyRequest { Resource = new Google.Cloud.Bigtable.Common.V2.TableName("[PROJECT]", "[INSTANCE]", "[TABLE]").ToString(), }; Policy expectedResponse = new Policy { Version = 351608024, Etag = ByteString.CopyFromUtf8("etag3123477"), }; mockGrpcClient.Setup(x => x.GetIamPolicyAsync(request, It.IsAny <CallOptions>())) .Returns(new Grpc.Core.AsyncUnaryCall <Policy>(Task.FromResult(expectedResponse), null, null, null, null)); BigtableTableAdminClient client = new BigtableTableAdminClientImpl(mockGrpcClient.Object, null); Policy response = await client.GetIamPolicyAsync(request); Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public async Task SendDiscoveryJob_NodeExist_Test() { var oldNode = new NodeInfo { Endpoint = "192.168.100.100:8003", Pubkey = ByteString.CopyFromUtf8("OldPubkey") }; await _nodeManager.AddNodeAsync(oldNode); _discoveredNodeCacheProvider.Add(oldNode.Endpoint); var peer = _peerPool.FindPeerByPublicKey("PeerWithNormalNode"); await SendDiscoveryJobAsync(peer); var nodes = await _nodeManager.GetRandomNodesAsync(10); nodes.Nodes.Count.ShouldBe(1); nodes.Nodes[0].Endpoint.ShouldBe("192.168.100.100:8003"); nodes.Nodes[0].Pubkey.ShouldBe(ByteString.CopyFromUtf8("192.168.100.100:8003")); }
public async Task AddNode_And_GetNodes_Test() { var node = new NodeInfo { Endpoint = "192.168.197.1:8000", Pubkey = ByteString.CopyFromUtf8("test") }; await _peerDiscoveryService.AddNodeAsync(node); var result = await _nodeManager.GetRandomNodesAsync(10); result.Nodes.Count.ShouldBe(1); result.Nodes[0].ShouldBe(node); _discoveredNodeCacheProvider.TryTake(out var endpoint); endpoint.ShouldBe(node.Endpoint); _discoveredNodeCacheProvider.TryTake(out endpoint); endpoint.ShouldBeNull(); }
/// <summary>Snippet for Publish</summary> public void Publish_RequestObject() { // Snippet: Publish(PublishRequest,CallSettings) // Create client PublisherClient publisherClient = PublisherClient.Create(); // Initialize request argument(s) PublishRequest request = new PublishRequest { TopicAsTopicName = new TopicName("[PROJECT]", "[TOPIC]"), Messages = { new PubsubMessage { Data = ByteString.CopyFromUtf8(""), }, }, }; // Make the request PublishResponse response = publisherClient.Publish(request); // End snippet }
public async Task ImportScriptAsync(byte[] scriptBytes, bool rescan, int scanFrom, string passphrase) { if (scriptBytes == null) { throw new ArgumentNullException(nameof(scriptBytes)); } if (passphrase == null) { throw new ArgumentNullException(nameof(passphrase)); } var client = new WalletService.WalletServiceClient(_channel); var request = new ImportScriptRequest { Script = ByteString.CopyFrom(scriptBytes), Rescan = rescan, Passphrase = ByteString.CopyFromUtf8(passphrase), // Poorly named: this outputs UTF8 from a UTF16 System.String ScanFrom = scanFrom, }; await client.ImportScriptAsync(request, cancellationToken : _tokenSource.Token); }
static async Task Main(string[] args) { var channel = Grpc.Net.Client.GrpcChannel.ForAddress("http://localhost:50001"); var c = new MessageCall.MessageCallClient(channel); var api = c.DuplexStreamingServerMethod(); var buffer = new StreamBuffer(); buffer.Body = ByteString.CopyFromUtf8("1"); await api.RequestStream.WriteAsync(buffer); await api.RequestStream.CompleteAsync(); //var p = NetRpcManager.CreateClientProxy<IService>(new GrpcClientOptions //{ // Url = "http://localhost:50001" //}); //await p.Proxy.Call("hello world."); Console.Read(); }
public async Task BeginTransactionAsync2() { Mock <Spanner.SpannerClient> mockGrpcClient = new Mock <Spanner.SpannerClient>(MockBehavior.Strict); BeginTransactionRequest request = new BeginTransactionRequest { SessionAsSessionName = new SessionName("[PROJECT]", "[INSTANCE]", "[DATABASE]", "[SESSION]"), Options = new TransactionOptions(), }; Transaction expectedResponse = new Transaction { Id = ByteString.CopyFromUtf8("27"), }; mockGrpcClient.Setup(x => x.BeginTransactionAsync(request, It.IsAny <CallOptions>())) .Returns(new Grpc.Core.AsyncUnaryCall <Transaction>(Task.FromResult(expectedResponse), null, null, null, null)); SpannerClient client = new SpannerClientImpl(mockGrpcClient.Object, null); Transaction response = await client.BeginTransactionAsync(request); Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public async Task <Account> NextAccountAsync(string passphrase, string accountName) { if (passphrase == null) { throw new ArgumentNullException(nameof(passphrase)); } if (accountName == null) { throw new ArgumentNullException(nameof(accountName)); } var client = WalletService.NewClient(_channel); var request = new NextAccountRequest { Passphrase = ByteString.CopyFromUtf8(passphrase), AccountName = accountName, }; var resp = await client.NextAccountAsync(request, cancellationToken : _tokenSource.Token); return(new Account(resp.AccountNumber)); }
/// <summary> /// Watch指定的范围,并将响应传递给提供的方法。 /// </summary> /// <param name="paths">watch的范围集合</param> /// <param name="methods">处理watch响应的方法集合</param> /// <param name="cancellationToken">中止线程token</param> /// <param name="exceptionHandler">异常处理委托方法</param> public void WatchRange(string[] paths, Action <WatchEvent[]>[] methods, CancellationToken cancellationToken, Metadata headers = null, Action <Exception> exceptionHandler = null) { List <WatchRequest> requests = new List <WatchRequest>(); foreach (string path in paths) { WatchRequest request = new WatchRequest() { CreateRequest = new WatchCreateRequest() { Key = ByteString.CopyFromUtf8(path), RangeEnd = ByteString.CopyFromUtf8(EtcdUtil.GetRangeEnd(path)) } }; requests.Add(request); } Watch(requests.ToArray(), methods, headers, exceptionHandler); }
public async Task <FortDetailsResponse> GetFort(string fortId, double fortLat, double fortLng) { var customRequest = new Request.Types.FortDetailsRequest { Id = ByteString.CopyFromUtf8(fortId), Latitude = Utils.FloatAsUlong(fortLat), Longitude = Utils.FloatAsUlong(fortLng) }; var fortDetailRequest = RequestBuilder.GetRequest(_unknownAuth, CurrentLat, CurrentLng, CurrentAltitude, new Request.Types.Requests { Type = (int)RequestType.FORT_DETAILS, Message = customRequest.ToByteString() }); return (await _httpClient.PostProtoPayload <Request, FortDetailsResponse>($"https://{_apiUrl}/rpc", fortDetailRequest)); }
/// <summary>Snippet for PublishAsync</summary> public async Task PublishAsync() { // Snippet: PublishAsync(TopicName,IEnumerable<PubsubMessage>,CallSettings) // Additional: PublishAsync(TopicName,IEnumerable<PubsubMessage>,CancellationToken) // Create client PublisherClient publisherClient = await PublisherClient.CreateAsync(); // Initialize request argument(s) TopicName topic = new TopicName("[PROJECT]", "[TOPIC]"); IEnumerable <PubsubMessage> messages = new[] { new PubsubMessage { Data = ByteString.CopyFromUtf8(""), }, }; // Make the request PublishResponse response = await publisherClient.PublishAsync(topic, messages); // End snippet }
public void BeginTransaction() { Mock <Datastore.DatastoreClient> mockGrpcClient = new Mock <Datastore.DatastoreClient>(MockBehavior.Strict); BeginTransactionRequest expectedRequest = new BeginTransactionRequest { ProjectId = "projectId-1969970175", }; BeginTransactionResponse expectedResponse = new BeginTransactionResponse { Transaction = ByteString.CopyFromUtf8("-34"), }; mockGrpcClient.Setup(x => x.BeginTransaction(expectedRequest, It.IsAny <CallOptions>())) .Returns(expectedResponse); DatastoreClient client = new DatastoreClientImpl(mockGrpcClient.Object, null); string projectId = "projectId-1969970175"; BeginTransactionResponse response = client.BeginTransaction(projectId); Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public async Task RedactImageAsync() { Mock <DlpService.DlpServiceClient> mockGrpcClient = new Mock <DlpService.DlpServiceClient>(MockBehavior.Strict); RedactImageRequest request = new RedactImageRequest { ParentAsProjectName = new ProjectName("[PROJECT]"), }; RedactImageResponse expectedResponse = new RedactImageResponse { RedactedImage = ByteString.CopyFromUtf8("28"), ExtractedText = "extractedText998260012", }; mockGrpcClient.Setup(x => x.RedactImageAsync(request, It.IsAny <CallOptions>())) .Returns(new Grpc.Core.AsyncUnaryCall <RedactImageResponse>(Task.FromResult(expectedResponse), null, null, null, null)); DlpServiceClient client = new DlpServiceClientImpl(mockGrpcClient.Object, null); RedactImageResponse response = await client.RedactImageAsync(request); Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public void Pull() { string projectId = _fixture.ProjectId; string topicId = _fixture.CreateTopicId(); string subscriptionId = _fixture.CreateSubscriptionId(); PublisherClient publisher = PublisherClient.Create(); TopicName topicName = new TopicName(projectId, topicId); publisher.CreateTopic(topicName); PubsubMessage newMessage = new PubsubMessage { Data = ByteString.CopyFromUtf8("Simple text") }; SubscriberClient.Create().CreateSubscription(new SubscriptionName(projectId, subscriptionId), topicName, null, 60); publisher.Publish(topicName, new[] { newMessage }); // Snippet: Pull(*,*,*,*) SubscriberClient client = SubscriberClient.Create(); SubscriptionName subscriptionName = new SubscriptionName(projectId, subscriptionId); PullResponse pullResponse = client.Pull(subscriptionName, returnImmediately: false, maxMessages: 100); foreach (ReceivedMessage message in pullResponse.ReceivedMessages) { // Messages can contain any data. We'll assume that we know this // topic publishes UTF-8-encoded text. Console.WriteLine($"Message text: {message.Message.Data.ToStringUtf8()}"); } // Acknowledge the messages after pulling them, so we don't pull them // a second time later. The ackDeadlineSeconds parameter specified when // the subscription is created determines how quickly you need to acknowledge // successfully-pulled messages before they will be redelivered. var ackIds = pullResponse.ReceivedMessages.Select(rm => rm.AckId); client.Acknowledge(subscriptionName, ackIds); // End snippet }
public async Task test_txn_query_variables() { // Set schema var op = new Operation { Schema = "name: string @index(exact) ." }; await _client.AlterAsync(op); // Add data var json = new JObject(); json.Add("name", "Alice"); var mut = new Mutation { CommitNow = true, SetJson = ByteString.CopyFromUtf8(json.ToString()) }; await _client.NewTransaction().MutateAsync(mut); // Query string query = "query me($a: string) { me(func: eq(name, $a)) { name }}"; var vars = new Dictionary <string, string> { { "$a", "Alice" } }; var res = await _client.NewTransaction().QueryWithVarsAsync(query, vars); // Verify data as expected json = JObject.Parse(res.Json.ToStringUtf8()); Assert.IsTrue(json.ContainsKey("me")); var arr = json.GetValue("me") as JArray; var obj = arr[0] as JObject; var name = obj.Property("name").Value.ToString(); Assert.AreEqual("Alice", name); }
public void Setup() { // Create schema string schema = new StringBuilder() .AppendLine("first: string @index(term) .") .AppendLine("last: string @index(hash) .") .AppendLine("age: int @index(int) .") .ToString(); _client.Alter(new Operation { Schema = schema }); using (var txn = _client.NewTransaction()) { foreach (var f in _firsts) { foreach (var l in _lasts) { foreach (var a in _ages) { var nqs = new StringBuilder() .AppendLine($"_:acc <first> \"{f}\" .") .AppendLine($"_:acc <last> \"{l}\" .") .AppendLine($"_:acc <age> \"{a}\"^^<xs:int> .") .ToString(); var mut = new Mutation { SetNquads = ByteString.CopyFromUtf8(nqs) }; txn.Mutate(mut); } } } txn.Commit(); } }
public void TestInitAndInvoke() { ChaincodeBase cb = new Cb(); ChaincodeInput ci = new ChaincodeInput(); ci.Args.AddRange(new[] { ByteString.CopyFromUtf8("init"), ByteString.CopyFromUtf8("a"), ByteString.CopyFromUtf8("100") }); ByteString initPayload = ci.ToByteString(); ChaincodeMessage initMsg = MessageUtil.NewEventMessage(ChaincodeMessage.Types.Type.Init, "testChannel", "0", initPayload, null); List <IScenarioStep> scenario = new List <IScenarioStep>(); scenario.Add(new RegisterStep()); scenario.Add(new PutValueStep("100")); scenario.Add(new CompleteStep()); scenario.Add(new GetValueStep("100")); scenario.Add(new PutValueStep("120")); scenario.Add(new DelValueStep()); scenario.Add(new CompleteStep()); server = ChaincodeMockPeer.StartServer(scenario); cb.Start(new string[] { "-a", "127.0.0.1:7052", "-i", "testId" }); CheckScenarioStepEnded(server, 1, Timeout); server.Send(initMsg); CheckScenarioStepEnded(server, 3, Timeout); Assert.AreEqual(server.LastMessageSend.Type, ChaincodeMessage.Types.Type.Response); Assert.AreEqual(server.LastMessageRcvd.Type, ChaincodeMessage.Types.Type.Completed); Assert.AreEqual(Protos.Peer.ProposalResponsePackage.Response.Parser.ParseFrom(server.LastMessageRcvd.Payload).Message, "OK response1"); ci = new ChaincodeInput(); ci.Args.AddRange(new[] { ByteString.CopyFromUtf8("invoke"), ByteString.CopyFromUtf8("a"), ByteString.CopyFromUtf8("10") }); ByteString invokePayload = ci.ToByteString(); ChaincodeMessage invokeMsg = MessageUtil.NewEventMessage(ChaincodeMessage.Types.Type.Transaction, "testChannel", "0", invokePayload, null); server.Send(invokeMsg); CheckScenarioStepEnded(server, 7, Timeout); Assert.AreEqual(server.LastMessageSend.Type, ChaincodeMessage.Types.Type.Response); Assert.AreEqual(server.LastMessageRcvd.Type, ChaincodeMessage.Types.Type.Completed); Assert.AreEqual(Protos.Peer.ProposalResponsePackage.Response.Parser.ParseFrom(server.LastMessageRcvd.Payload).Message, "OK response2"); }
public async Task <List <Blake256Hash> > PurchaseTicketsAsync(Account account, Amount spendLimit, int reqConfs, Address votingAddress, uint ticketCount, Address poolAddress, decimal poolFees, uint expiry, Amount txFee, Amount ticketFee, string passphrase) { var votingAddressStr = ""; if (votingAddress != null) { votingAddressStr = votingAddress.ToString(); } var poolAddressStr = ""; if (poolAddress != null) { poolAddressStr = poolAddress.ToString(); } if (poolAddressStr == "") { poolFees = 0m; } var client = new WalletService.WalletServiceClient(_channel); var request = new PurchaseTicketsRequest { Passphrase = ByteString.CopyFromUtf8(passphrase), Account = account.AccountNumber, SpendLimit = spendLimit, RequiredConfirmations = (uint)reqConfs, TicketAddress = votingAddressStr, NumTickets = ticketCount, PoolAddress = poolAddressStr, PoolFees = (double)(poolFees * 100), Expiry = expiry, TxFee = txFee, TicketFee = ticketFee, }; var response = await client.PurchaseTicketsAsync(request, cancellationToken : _tokenSource.Token); return(response.TicketHashes.Select(h => new Blake256Hash(h.ToByteArray())).ToList()); }
public void AdminsCanSeeAllGameEvents() { // Submit 3 close game events, and 2 far game events. SubmitGameEventRequest request = new SubmitGameEventRequest() { EventData = new GameEventRequest() { EventData = ByteString.CopyFromUtf8("MyEventData"), OccursAtTick = 123, }, RoomId = gameId, }; client.SubmitGameEvent(request); client.SubmitGameEvent(request); client.SubmitGameEvent(request); request.EventData.OccursAtTick = 10467; client.SubmitGameEvent(request); client.SubmitGameEvent(request); SuperUser admin = authHelper.CreateSuperUser(); client.Login(new AuthorizationRequest() { Username = admin.DbUserModel.UserModel.Username, Password = admin.password, }); GetGameRoomEventsResponse eventResponse = client.GetGameRoomEvents(new GetGameRoomEventsRequest() { RoomId = gameId, }); Assert.AreEqual(eventResponse.Status.IsSuccess, true); // Admin should be able to see all 5 events! Assert.AreEqual(5, eventResponse.GameEvents.Count); }