public void Test_Echo() { var client = new ipfsClient (); client.Init (); var echo = new ipfsEcho (); Console.WriteLine(echo.Echo ("Hello world!")); }
public void Test_ExtractHashAfterPublish() { var hash = "QmeBPLVyvWcnGk3n6c5vapXzbkMH3ZQQiwhnnfTRdcSGMr"; var outputLine = "Published to " + hash + ": QmT78zSuBmuS4z925WZfrqQ1qHaJ56DQaTfyMUF7F8ff5o"; var client = new ipfsClient (); var extractedHash = client.ExtractHashAfterPublish (outputLine); Assert.AreEqual (hash, extractedHash); }
public void Test_ExtractHashAfterAddFolder() { var hash = "QmQzCQn4puG4qu8PVysxZmscmQ5vT1ZXpqo7f58Uh9QfyY"; var output = "added QmNRCQWfgze6AbBCaT1rkrkV5tJ2aP4oTNPb5JZcXYywve ipfs-data/TestSubFolder/file.txt\nadded QmdwbpwH3Z3gFcpkJg11fzpwe7PjNq9bEgNveWyDk4pqwY ipfs-data/TestSubFolder\nadded " + hash + " ipfs-data\n\n\t\t\t11 B +Inf % 0\u001b[2K\n\t\t\t\t\u001b[2K\n\t\t\t\t\t\u001b[2K\n\n"; var client = new ipfsClient (); var extractedHash = client.ExtractHashAfterAddFolder (output); Assert.AreEqual (hash, extractedHash); }
public void Test_ExtractHashAfterAddFile() { var hash = "QmQzCQn4puG4qu8PVysxZmscmQ5vT1ZXpqo7f58Uh9QfyY"; var outputLine = "added " + hash + " file.txt"; var client = new ipfsClient (); var extractedHash = client.ExtractHashAfterAddFile (outputLine); Assert.AreEqual (hash, extractedHash); }
public override void Execute() { Console.WriteLine ("Current directory:"); Console.WriteLine (Environment.CurrentDirectory); var exampleFolderName = "example"; var exampleFolderPath = Path.Combine(Environment.CurrentDirectory, exampleFolderName); Console.WriteLine ("Example folder:"); Console.WriteLine (exampleFolderPath); Directory.CreateDirectory (exampleFolderPath); var exampleFileName = "file.txt"; var exampleFilePath = Path.Combine(exampleFolderPath, exampleFileName); Console.WriteLine ("Example file:"); Console.WriteLine (exampleFilePath); var text = "Hello world"; File.WriteAllText (exampleFilePath, text); var ipfs = new ipfsClient (); ipfs.Init (); using (var daemon = ipfs.StartDaemon ()) { Thread.Sleep (5000); var hash = ipfs.AddFolder (exampleFolderPath); new ipfsFileChecker().CheckTestFile ("ipfs", hash, exampleFileName, text); } }
public string EchoBasic(string text) { var originalDirectory = Environment.CurrentDirectory; var tmpDir = Path.GetFullPath (".tmp"); if (!Directory.Exists (tmpDir)) Directory.CreateDirectory (tmpDir); var uniqueTmpDir = Path.Combine (tmpDir, Guid.NewGuid ().ToString ()); Directory.CreateDirectory (uniqueTmpDir); Directory.SetCurrentDirectory (uniqueTmpDir); var tmpFileName = "file.txt"; var tmpFile = Path.Combine (uniqueTmpDir, tmpFileName); File.WriteAllText (tmpFile, text); var client = new ipfsClient (); var hash = client.AddFile (tmpFileName); Directory.SetCurrentDirectory (originalDirectory); Directory.Delete (uniqueTmpDir, true); return hash; }