public void TestFromJson() { JObject json = new JObject(); json["address"] = "ARxgjcH2K1yeW5f5ryuRQNaBzSa9TZzmVS"; json["key"] = null; json["label"] = null; json["isDefault"] = true; json["lock"] = false; json["contract"] = null; json["extra"] = null; NEP6Account account = NEP6Account.FromJson(json, _wallet); account.ScriptHash.Should().Be("ARxgjcH2K1yeW5f5ryuRQNaBzSa9TZzmVS".ToScriptHash()); account.Label.Should().BeNull(); account.IsDefault.Should().BeTrue(); account.Lock.Should().BeFalse(); account.Contract.Should().BeNull(); account.Extra.Should().BeNull(); account.GetKey().Should().BeNull(); json["key"] = "6PYRjVE1gAbCRyv81FTiFz62cxuPGw91vMjN4yPa68bnoqJtioreTznezn"; json["label"] = "label"; account = NEP6Account.FromJson(json, _wallet); account.Label.Should().Be("label"); account.HasKey.Should().BeTrue(); }
public void TestGetKey() { _account.GetKey().Should().BeNull(); _wallet.Unlock("Satoshi"); _account = new NEP6Account(_wallet, _hash, _nep2); _account.GetKey().Should().Be(_keyPair); }
public void TestSetup() { _wallet = TestUtils.GenerateTestWallet(); byte[] array1 = { 0x01 }; _hash = new UInt160(Crypto.Default.Hash160(array1)); _account = new NEP6Account(_wallet, _hash); }
public void TestFromJson() { JObject json = new(); json["address"] = "NdtB8RXRmJ7Nhw1FPTm7E6HoDZGnDw37nf"; json["key"] = null; json["label"] = null; json["isDefault"] = true; json["lock"] = false; json["contract"] = null; json["extra"] = null; NEP6Account account = NEP6Account.FromJson(json, _wallet); account.ScriptHash.Should().Be("NdtB8RXRmJ7Nhw1FPTm7E6HoDZGnDw37nf".ToScriptHash(ProtocolSettings.Default.AddressVersion)); account.Label.Should().BeNull(); account.IsDefault.Should().BeTrue(); account.Lock.Should().BeFalse(); account.Contract.Should().BeNull(); account.Extra.Should().BeNull(); account.GetKey().Should().BeNull(); json["key"] = "6PYRjVE1gAbCRyv81FTiFz62cxuPGw91vMjN4yPa68bnoqJtioreTznezn"; json["label"] = "label"; account = NEP6Account.FromJson(json, _wallet); account.Label.Should().Be("label"); account.HasKey.Should().BeTrue(); }
public void TestGetKey() { account.GetKey().Should().BeNull(); wallet.Unlock("Satoshi"); account = new NEP6Account(wallet, hash, nep2); account.GetKey().Should().Be(keyPair); }
public void TestImportScriptHashWalletIsNotOpened() { var mockWalletManager = GetAWalletManagerWithoutAnWallet(); // Act NEP6Account walletAccount1 = (NEP6Account)mockWalletManager.CreateAccount(_defaultPassword); mockWalletManager = new Nep6WalletManager(new FileWrapper(), new JsonConverterWrapper()); NEP6Account walletAccount2 = (NEP6Account)mockWalletManager.ImportScriptHash(walletAccount1.ScriptHash); }
public void TestConstructorWithKeyPair() { var wallet = TestUtils.GenerateTestWallet(); byte[] array1 = { 0x01 }; var hash = new UInt160(Crypto.Default.Hash160(array1)); string password = "******"; NEP6Account account = new NEP6Account(wallet, hash, _keyPair, password); account.ScriptHash.Should().Be(hash); account.Decrypted.Should().BeTrue(); account.HasKey.Should().BeTrue(); }
public void TestImportScriptHash() { var mockWalletManager = GetAWalletManagerWithAnWallet(); // Act NEP6Account walletAccount1 = (NEP6Account)mockWalletManager.CreateAndAddAccount(_defaultPassword); NEP6Account walletAccount2 = (NEP6Account)mockWalletManager.ImportScriptHash(walletAccount1.ScriptHash); // Assert Assert.IsNotNull(walletAccount2); Assert.AreEqual(walletAccount1.ScriptHash, walletAccount2.ScriptHash); Assert.AreEqual(walletAccount1.Address, walletAccount2.Address); Assert.IsTrue(mockWalletManager.Wallet.Accounts.Length == 1); }
public void TestChangePassword() { _account = new NEP6Account(_wallet, _hash, _nep2); _account.ChangePasswordPrepare("b", "Satoshi").Should().BeTrue(); _account.ChangePasswordCommit(); _account.Contract = new Contract(); _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(); }
public void TestImportScriptHashEmpty() { var mockWalletManager = GetAWalletManagerWithAnWallet(); // Act var contract = new Contract() { Code = new Code { ScriptHash = UInt160.Zero } }; IWalletAccount walletAccount1 = new NEP6Account(contract); mockWalletManager.ImportScriptHash(walletAccount1.Contract.ScriptHash); }
public void TestImportScriptHash() { var mockWalletManager = GetAWalletManagerWithAnWallet(); // Act NEP6Account walletAccount1 = (NEP6Account)mockWalletManager.CreateAccount(_defaultPassword); NEP6Account walletAccount2 = (NEP6Account)mockWalletManager.ImportScriptHash(walletAccount1.ScriptHash); // Assert Assert.IsNotNull(walletAccount2); Assert.AreEqual(walletAccount1.ScriptHash, walletAccount2.ScriptHash); //TODO: Check & improve //Assert.IsFalse(String.IsNullOrEmpty(walletAccount2.Address)); Assert.IsTrue(mockWalletManager.Wallet.Accounts.Count == 1); }
public void TestVerifyPassword() { _account = new NEP6Account(_wallet, _hash, _nep2); _account.VerifyPassword("Satoshi").Should().BeTrue(); _account.VerifyPassword("b").Should().BeFalse(); }
public void TestGetKeyWithString() { account.GetKey("Satoshi").Should().BeNull(); account = new NEP6Account(wallet, hash, nep2); account.GetKey("Satoshi").Should().Be(keyPair); }