Ejemplo n.º 1
0
        public void TestLock()
        {
            Assert.ThrowsException <ArgumentNullException>(() => uut.CreateAccount(keyPair.PrivateKey));
            uut.Unlock("123");
            uut.CreateAccount(keyPair.PrivateKey);
            bool result = uut.Contains(testScriptHash);

            Assert.AreEqual(true, result);
            uut.DeleteAccount(testScriptHash);
            uut.Lock();
            Assert.ThrowsException <ArgumentNullException>(() => uut.CreateAccount(keyPair.PrivateKey));
        }
Ejemplo n.º 2
0
 public void TestChangePassword()
 {
     _account = new NEP6Account(_wallet, _hash, _nep2);
     _account.ChangePasswordPrepare("b", "Satoshi").Should().BeTrue();
     _account.ChangePasswordCommit();
     _account.Contract = new Contract();
     _wallet.Unlock("Satoshi");
     _account.ChangePasswordPrepare("b", "Satoshi").Should().BeFalse();
     _account.ChangePasswordPrepare("Satoshi", "b").Should().BeTrue();
     _account.ChangePasswordCommit();
     _account.VerifyPassword("b").Should().BeTrue();
     _account.ChangePasswordPrepare("b", "Satoshi").Should().BeTrue();
     _account.ChangePasswordCommit();
     _account.ChangePasswordPrepare("Satoshi", "b").Should().BeTrue();
     _account.ChangePasswordRoolback();
     _account.VerifyPassword("Satoshi").Should().BeTrue();
     _wallet.Lock();
 }
Ejemplo 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, ProtocolSettings.Default);
            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();
        }