<commit_before>﻿using Microsoft.VisualStudio.TestTools.UnitTesting;
using Newtonsoft.Json.Linq;
using System;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Ipfs.Api
{
 
    [TestClass]
    public class DhtTest
    {
        const string marsId = "QmSoLMeWqB7YGVLJN3pNLQpmmEk35v6wYtsMGLzSr5QBU3";
        const string marsPublicKey = "<KEY>;
        const string helloWorldID = "QmT78zSuBmuS4z925WZfrqQ1qHaJ56DQaTfyMUF7F8ff5o";

        [TestMethod]
        public async Task FindPeer()
        {
            var ipfs = new IpfsClient();
            var mars = await ipfs.Dht.FindPeerAsync(marsId);
            Assert.AreEqual(marsPublicKey, mars.PublicKey);
        }

        [TestMethod]
        public async Task FindProviders()
        {
            var ipfs = new IpfsClient();
            var providers = await ipfs.Dht.FindProvidersAsync(helloWorldID);
            Assert.IsFalse(providers.Take(3).Contains(""));
        }

    }
}<commit_msg>test(dht): FindPeer is too brittle,  IFPS server is not deterministic<commit_after>﻿using Microsoft.VisualStudio.TestTools.UnitTesting;
using Newtonsoft.Json.Linq;
using System;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Ipfs.Api
{
 
    [TestClass]
    public class DhtTest
    {
        const string marsId = "<KEY>";
        const string marsPublicKey = "<KEY>;
        const string helloWorldID = "QmT78zSuBmuS4z925WZfrqQ1qHaJ56DQaTfyMUF7F8ff5o";

        [TestMethod]
        public async Task FindPeer()
        {
            var ipfs = new IpfsClient();
            var mars = await ipfs.Dht.FindPeerAsync(marsId);
            Assert.AreEqual(marsId, mars.Id);

            // Sometimes the public key is not returned!
            if (!string.IsNullOrEmpty(mars.PublicKey))
                Assert.AreEqual(marsPublicKey, mars.PublicKey);
        }

        [TestMethod]
        public async Task FindProviders()
        {
            var ipfs = new IpfsClient();
            var providers = await ipfs.Dht.FindProvidersAsync(helloWorldID);
            Assert.IsFalse(providers.Take(3).Contains(""));
        }

    }
}
{'fraction_non_alphanumeric': 0.09328358208955224, 'fraction_numerical': 0.015391791044776119, 'mean_word_length': 2.470873786407767, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2194181', 'n_tokens_mistral': 707, 'n_tokens_neox': 681, 'n_words': 138}