public override void Execute() { var tmpFileName = "file.txt"; var tmpFilePath = Path.GetFullPath(tmpFileName); var beforeText = Guid.NewGuid().ToString(); Console.WriteLine("Before text: " + beforeText); File.WriteAllText(tmpFilePath, beforeText); var ipfs = new ipfsClient(); ipfs.Init(); using (var daemon = ipfs.StartDaemon()) { Thread.Sleep(10000); var hash = ipfs.AddFile(tmpFileName); Console.WriteLine("IPFS Hash: " + hash); var peerId = ipfs.Publish(hash); Console.WriteLine("Peer ID: " + peerId); var fileChecker = new ipfsFileChecker(); fileChecker.CheckTestFile("ipns", peerId, beforeText); var afterText = Guid.NewGuid().ToString(); Console.WriteLine("After text: " + afterText); File.WriteAllText(tmpFilePath, afterText); Thread.Sleep(2000); hash = ipfs.AddFile(tmpFileName); Console.WriteLine("IPFS Hash: " + hash); peerId = ipfs.Publish(hash); Console.WriteLine("Peer ID: " + peerId); fileChecker.CheckTestFile("ipns", peerId, afterText); } }
public override void Execute() { var tmpFileName = "file.txt"; var tmpFilePath = Path.GetFullPath(tmpFileName); var beforeText = Guid.NewGuid().ToString(); Console.WriteLine ("Before text: " + beforeText); File.WriteAllText (tmpFilePath, beforeText); var ipfs = new ipfsClient (); ipfs.Init (); using (var daemon = ipfs.StartDaemon ()) { Thread.Sleep (10000); var hash = ipfs.AddFile (tmpFileName); Console.WriteLine ("IPFS Hash: " + hash); var peerId = ipfs.Publish (hash); Console.WriteLine ("Peer ID: " + peerId); var fileChecker = new ipfsFileChecker (); fileChecker.CheckTestFile ("ipns", peerId, beforeText); var afterText = Guid.NewGuid ().ToString (); Console.WriteLine ("After text: " + afterText); File.WriteAllText (tmpFilePath, afterText); Thread.Sleep (2000); hash = ipfs.AddFile (tmpFileName); Console.WriteLine ("IPFS Hash: " + hash); peerId = ipfs.Publish (hash); Console.WriteLine ("Peer ID: " + peerId); fileChecker.CheckTestFile ("ipns", peerId, afterText); } }
public override void Execute() { var managedClient = new ipfsManagedClient(); managedClient.IsVerbose = true; managedClient.Init(); var dataDir = managedClient.DataDirectory; var sourceDir = Path.GetFullPath("source"); Directory.CreateDirectory(sourceDir); var sourceFile = Path.Combine(sourceDir, "file.txt"); var contents = "Hello world"; File.WriteAllText(sourceFile, contents); var subFolderName = "TestSubFolder"; var testDirectory = Environment.CurrentDirectory; Directory.SetCurrentDirectory(sourceDir); var hash = managedClient.AddFile(sourceFile, subFolderName); Directory.SetCurrentDirectory(testDirectory); var peerId = managedClient.Publish(hash); var relativeFilePath = subFolderName + "/" + Path.GetFileName(sourceFile); var fileChecker = new ipfsFileChecker(); fileChecker.CheckTestFile("ipns", peerId, relativeFilePath, contents); }