Exemplo n.º 1
0
        public void TestVerifyPassword()
        {
            bool result = uut.VerifyPassword("123");

            Assert.AreEqual(true, result);
            Assert.ThrowsException <ArgumentNullException>(() => uut.CreateAccount(keyPair.PrivateKey));
            uut.Unlock("123");
            uut.CreateAccount(keyPair.PrivateKey);
            result = uut.Contains(testScriptHash);
            Assert.AreEqual(true, result);
            result = uut.VerifyPassword("123");
            Assert.AreEqual(true, result);
            uut.DeleteAccount(testScriptHash);
            Assert.AreEqual(false, uut.Contains(testScriptHash));
            JObject wallet = new JObject();

            wallet["name"]     = "name";
            wallet["version"]  = new Version().ToString();
            wallet["scrypt"]   = new ScryptParameters(0, 0, 0).ToJson();
            wallet["accounts"] = new JArray();
            wallet["extra"]    = new JObject();
            uut     = new NEP6Wallet(wallet);
            nep2key = keyPair.Export("123", 0, 0, 0);
            uut.Import(nep2key, "123", 0, 0, 0);
            Assert.IsFalse(uut.VerifyPassword("1"));
            Assert.IsTrue(uut.VerifyPassword("123"));
        }
Exemplo n.º 2
0
        public void TestVerifyPassword()
        {
            bool result = uut.VerifyPassword("123");

            Assert.AreEqual(true, result);
            uut.CreateAccount(keyPair.PrivateKey);
            result = uut.Contains(testScriptHash);
            Assert.AreEqual(true, result);
            result = uut.VerifyPassword("123");
            Assert.AreEqual(true, result);
            uut.DeleteAccount(testScriptHash);
            Assert.AreEqual(false, uut.Contains(testScriptHash));
            JObject wallet = new();

            wallet["name"]     = "name";
            wallet["version"]  = new Version("1.0").ToString();
            wallet["scrypt"]   = new ScryptParameters(2, 1, 1).ToJson();
            wallet["accounts"] = new JArray();
            wallet["extra"]    = new JObject();
            uut     = new NEP6Wallet(null, "123", ProtocolSettings.Default, wallet);
            nep2key = keyPair.Export("123", ProtocolSettings.Default.AddressVersion, 2, 1, 1);
            uut.Import(nep2key, "123", 2, 1, 1);
            Assert.IsFalse(uut.VerifyPassword("1"));
            Assert.IsTrue(uut.VerifyPassword("123"));
        }
Exemplo n.º 3
0
        public void TestChangePassword()
        {
            JObject wallet = new();

            wallet["name"]     = "name";
            wallet["version"]  = new Version("1.0").ToString();
            wallet["scrypt"]   = new ScryptParameters(2, 1, 1).ToJson();
            wallet["accounts"] = new JArray();
            wallet["extra"]    = new JObject();
            File.WriteAllText(wPath, wallet.ToString());
            uut = new NEP6Wallet(wPath, "123", ProtocolSettings.Default);
            uut.CreateAccount(keyPair.PrivateKey);
            uut.ChangePassword("456", "123").Should().BeFalse();
            uut.ChangePassword("123", "456").Should().BeTrue();
            uut.VerifyPassword("456").Should().BeTrue();
            uut.ChangePassword("456", "123").Should().BeTrue();
        }
Exemplo n.º 4
0
        public void TestChangePassword()
        {
            JObject wallet = new JObject();

            wallet["name"]     = "name";
            wallet["version"]  = new System.Version("3.0").ToString();
            wallet["scrypt"]   = new ScryptParameters(0, 0, 0).ToJson();
            wallet["accounts"] = new JArray();
            wallet["extra"]    = new JObject();
            File.WriteAllText(wPath, wallet.ToString());
            uut = new NEP6Wallet(wPath);
            uut.Unlock("123");
            uut.CreateAccount(keyPair.PrivateKey);
            uut.ChangePassword("456", "123").Should().BeFalse();
            uut.ChangePassword("123", "456").Should().BeTrue();
            uut.VerifyPassword("456").Should().BeTrue();
            uut.ChangePassword("456", "123").Should().BeTrue();
            uut.Lock();
        }