void DeleteNode(IpfsEngine ipfs)
 {
     if (Directory.Exists(ipfs.Options.Repository.Folder))
     {
         Directory.Delete(ipfs.Options.Repository.Folder, true);
     }
 }
Esempio n. 2
0
        IpfsEngine CreateNode()
        {
            const string passphrase = "this is not a secure pass phrase";
            var          ipfs       = new IpfsEngine(passphrase.ToCharArray());

            ipfs.Options.Repository.Folder       = Path.Combine(Path.GetTempPath(), $"swarm-{nodeNumber++}");
            ipfs.Options.KeyChain.DefaultKeySize = 512;
            ipfs.Config.SetAsync(
                "Addresses.Swarm",
                JToken.FromObject(new string[] { "/ip4/0.0.0.0/tcp/4007" })
                ).Wait();

            return(ipfs);
        }
        async Task <IpfsEngine> CreateNode()
        {
            const string passphrase = "this is not a secure pass phrase";
            var          ipfs       = new IpfsEngine(passphrase.ToCharArray());

            ipfs.Options.Repository.Folder       = Path.Combine(Path.GetTempPath(), "ipfs-ed255129-test");
            ipfs.Options.KeyChain.DefaultKeyType = "ed25519";
            await ipfs.Config.SetAsync(
                "Addresses.Swarm",
                JToken.FromObject(new string[] { "/ip4/0.0.0.0/tcp/0" })
                );

            return(ipfs);
        }
Esempio n. 4
0
        public async Task Wrong_Passphrase()
        {
            var ipfs1 = TestFixture.Ipfs;
            await ipfs1.KeyChain();

            var ipfs2 = new IpfsEngine("the wrong pass phrase".ToCharArray())
            {
                Options = ipfs1.Options
            };

            ExceptionAssert.Throws <UnauthorizedAccessException>(() =>
            {
                var _ = ipfs2.KeyChain().Result;
            });
        }
Esempio n. 5
0
        public async Task SecureString_Passphrase()
        {
            var secret = "this is not a secure pass phrase";
            var ipfs   = new IpfsEngine(secret.ToCharArray());

            ipfs.Options = TestFixture.Ipfs.Options;
            await ipfs.KeyChain();

            var passphrase = new SecureString();

            foreach (var c in secret)
            {
                passphrase.AppendChar(c);
            }
            ipfs         = new IpfsEngine(passphrase);
            ipfs.Options = TestFixture.Ipfs.Options;
            await ipfs.KeyChain();
        }
        public async Task IpfsPass_Passphrase()
        {
            var secret = "this is not a secure pass phrase";
            var ipfs   = new IpfsEngine(secret.ToCharArray());

            ipfs.Options = TestFixture.Ipfs.Options;
            await ipfs.KeyChainAsync();

            Environment.SetEnvironmentVariable("IPFS_PASS", secret);
            try
            {
                ipfs         = new IpfsEngine();
                ipfs.Options = TestFixture.Ipfs.Options;
                await ipfs.KeyChainAsync();
            }
            finally
            {
                Environment.SetEnvironmentVariable("IPFS_PASS", null);
            }
        }
Esempio n. 7
0
        public void Can_Create()
        {
            var ipfs = new IpfsEngine("this is not a secure pass phrase".ToCharArray());

            Assert.IsNotNull(ipfs);
        }
 public void IpfsPass_Missing()
 {
     var _ = new IpfsEngine();
 }
Esempio n. 9
0
        public void Can_Create()
        {
            var ipfs = new IpfsEngine();

            Assert.IsNotNull(ipfs);
        }