Exemplo n.º 1
0
        public override void Execute()
        {
            // Prepare for the test
            var tmpFileName = "file.txt";

            var tmpFile = Path.GetFullPath(tmpFileName);

            Console.WriteLine("Tmp file:");
            Console.WriteLine(tmpFile);

            var text = "Hello world";

            File.WriteAllText(tmpFile, text);

            // Start the test
            var ipfs = new ipfsClient();

            ipfs.Init();

            using (var daemon = ipfs.StartDaemon()) {
                // TODO: Fixture out a way to reduce this duration
                Thread.Sleep(5000);                  // Sleep to let the daemon start, otherwise an error may occur
                var hash = ipfs.AddFile(tmpFileName);
                new ipfsFileChecker().CheckTestFile("ipfs", hash, text);
            }
        }
        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()
        {
            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);
            }
        }