public async Task Put_Informs_Bitswap() { _dfs = TestDfs.GetTestDfs(null, "sha2-256"); await _dfs.StartAsync(); try { var data = Guid.NewGuid().ToByteArray(); var cid = new Cid { Hash = MultiHash.ComputeHash(data) }; var cts = new CancellationTokenSource(); cts.CancelAfter(20000); var wantTask = _dfs.BitSwapApi.GetAsync(cid, cts.Token); var cid1 = await _dfs.BlockApi.PutAsync(data, cancel : cts.Token); Assert.AreEqual(cid, cid1); Assert.AreEqual(cid, wantTask.Result.Id); Assert.AreEqual(data.Length, wantTask.Result.Size); Assert.AreEqual(data, wantTask.Result.DataBytes); } finally { await _dfs.StopAsync(); } }
public async Task Can_Use_Private_Node() { using (var ipfs = TestDfs.GetTestDfs()) { ipfs.Options.Discovery.BootstrapPeers = new MultiAddress[0]; ipfs.Options.Swarm.PrivateNetworkKey = new PreSharedKey().Generate(); await _dfs1.StartAsync(); } }
public async Task Read_From_OtherNode() { using (var a = TestDfs.GetTestDfs()) { using (var b = TestDfs.GetTestDfs()) { using (var c = TestDfs.GetTestDfs()) { var psk = new PreSharedKey().Generate(); // Start bootstrap node. b.Options.Discovery.DisableMdns = true; b.Options.Swarm.MinConnections = 0; b.Options.Swarm.PrivateNetworkKey = psk; b.Options.Discovery.BootstrapPeers = new MultiAddress[0]; await b.StartAsync(); var bootstrapPeers = new[] { b.LocalPeer.Addresses.First() }; TestContext.WriteLine($"B is {b.LocalPeer}"); // Node that has the content. c.Options.Discovery.DisableMdns = true; c.Options.Swarm.MinConnections = 0; c.Options.Swarm.PrivateNetworkKey = psk; c.Options.Discovery.BootstrapPeers = bootstrapPeers; await c.StartAsync(); await c.SwarmApi.ConnectAsync(bootstrapPeers[0]); TestContext.WriteLine($"C is {c.LocalPeer}"); var fsn = await c.UnixFsApi.AddTextAsync("some content"); var cid = fsn.Id; // Node that reads the content. a.Options.Discovery.DisableMdns = true; a.Options.Swarm.MinConnections = 0; a.Options.Swarm.PrivateNetworkKey = psk; a.Options.Discovery.BootstrapPeers = bootstrapPeers; await a.StartAsync(); TestContext.WriteLine($"A is {a.LocalPeer}"); var cts = new CancellationTokenSource(TimeSpan.FromSeconds(30)); var content = await a.UnixFsApi.ReadAllTextAsync(cid, cts.Token); Assert.AreEqual("some content", content); } } } }
public void Init() { this.Setup(TestContext.CurrentContext); ContainerProvider.Container.Resolve <IHashProvider>(); var passwordReader = Substitute.For <IPasswordManager>(); passwordReader.RetrieveOrPromptAndAddPasswordToRegistry(Arg.Any <PasswordRegistryTypes>(), Arg.Any <string>()) .Returns(TestPasswordReader.BuildSecureStringPassword("abcd")); Substitute.For <ILogger>(); _dfs1 = TestDfs.GetTestDfs(); _dfs2 = TestDfs.GetTestDfs(); }
public void Init() { var fileSystem1 = Substitute.For <IFileSystem>(); fileSystem1.GetCatalystDataDir().Returns(new DirectoryInfo(Path.Combine(Environment.CurrentDirectory, $"dfs1-_{DateTime.Now:yyMMddHHmmssffff}"))); var fileSystem2 = Substitute.For <IFileSystem>(); fileSystem2.GetCatalystDataDir().Returns(new DirectoryInfo(Path.Combine(Environment.CurrentDirectory, $"dfs2-_{DateTime.Now:yyMMddHHmmssffff}"))); _dfsService = TestDfs.GetTestDfs(fileSystem1); _dfsServiceOther = TestDfs.GetTestDfs(fileSystem2); }
public void Init() { this.Setup(TestContext.CurrentContext); ContainerProvider.ConfigureContainerBuilder(true, true, true); var context = new FfiWrapper(); _endOfTestCancellationSource = new CancellationTokenSource(); var poaNodeDetails = Enumerable.Range(0, 3).Select(i => { var fileSystem = Substitute.For <IFileSystem>(); var path = Path.Combine(FileSystem.GetCatalystDataDir().FullName, $"producer{i}"); fileSystem.GetCatalystDataDir().Returns(new DirectoryInfo(path)); var privateKey = context.GeneratePrivateKey(); var publicKey = privateKey.GetPublicKey(); var nodeSettings = PeerSettingsHelper.TestPeerSettings(publicKey.Bytes, 2000 + i); var peerIdentifier = nodeSettings.PeerId; var name = $"producer{i.ToString()}"; var dfs = TestDfs.GetTestDfs(fileSystem); return(new { index = i, name, privateKey, nodeSettings, peerIdentifier, dfs, fileSystem }); } ).ToList(); var peerIdentifiers = poaNodeDetails.Select(n => n.peerIdentifier).ToList(); _nodes = new List <PoaTestNode>(); foreach (var nodeDetails in poaNodeDetails) { nodeDetails.dfs.Options.Discovery.BootstrapPeers = poaNodeDetails.Select(x => x.dfs.LocalPeer.Addresses.First()); var node = new PoaTestNode(nodeDetails.name, nodeDetails.privateKey, nodeDetails.nodeSettings, nodeDetails.dfs, peerIdentifiers.Except(new[] { nodeDetails.peerIdentifier }), nodeDetails.fileSystem); _nodes.Add(node); } }
public ObjectApiTest() { ipfs = TestDfs.GetTestDfs(null, "sha2-256"); }
public BlockApiTest() { _dfs = TestDfs.GetTestDfs(null, "sha2-256"); }
public async Task Can_Dispose() { using var node = TestDfs.GetTestDfs(); await node.StartAsync(); }
public BlockRepositoryApiTest() { ipfs = TestDfs.GetTestDfs(); }
public NameApiTest() { ipfs = TestDfs.GetTestDfs(null, "sha2-256"); }
public PinApiTest() { _dfs = TestDfs.GetTestDfs(); }
public DhtApiTest() { ipfs = TestDfs.GetTestDfs(); _locaId = ipfs.LocalPeer.Id; }
public PubSubApiTest() { ipfs = TestDfs.GetTestDfs(); }
public DagApiTest() { _dfs = TestDfs.GetTestDfs(null, "sha2-256"); }
public void Init() { ipfs = TestDfs.GetTestDfs(null, "sha2-256"); }
public StatsApiTest() { _dfs = TestDfs.GetTestDfs(); }
public MigrationManagerTest() { _dfs = TestDfs.GetTestDfs(); }
public BootstapApiTest() { ipfs = TestDfs.GetTestDfs(); }