Exemple #1
0
        public async Task AddNode_Test()
        {
            var node   = GenerateTestNodes(1).First();
            var result = await _nodeManager.AddOrUpdateNodeAsync(node);

            result.ShouldBeTrue();

            var data = node.ToDiagnosticString();

            data.ShouldContain("endpoint");
            data.ShouldContain(node.Pubkey.ToHex().Substring(0, 45));

            //add duplicate one
            var result1 = await _nodeManager.AddOrUpdateNodeAsync(node);

            result1.ShouldBeFalse();
        }
Exemple #2
0
        public async Task GetNodes_Test()
        {
            var context = BuildServerCallContext();
            var result  = await _serverService.GetNodes(null, context);

            result.ShouldBe(new NodeList());

            var node = new NodeInfo
            {
                Endpoint = "127.0.0.1:2001",
                Pubkey   = ByteString.CopyFromUtf8("pubkey1")
            };
            await _nodeManager.AddOrUpdateNodeAsync(node);

            var request = new NodesRequest
            {
                MaxCount = 1
            };

            result = await _serverService.GetNodes(request, context);

            result.Nodes.Count.ShouldBe(1);
            result.Nodes[0].ShouldBe(node);
        }
Exemple #3
0
 public async Task AddNodeAsync(NodeInfo nodeInfo)
 {
     await _nodeManager.AddOrUpdateNodeAsync(nodeInfo);
 }