public void TestGetAccounts() { Dictionary <string, KeyPair> keys = new Dictionary <string, KeyPair>(); uut.Unlock("123"); byte[] privateKey = new byte[32]; using (RandomNumberGenerator rng = RandomNumberGenerator.Create()) { rng.GetBytes(privateKey); } KeyPair key = new KeyPair(privateKey); Neo.SmartContract.Contract contract = Neo.SmartContract.Contract.CreateSignatureContract(key.PublicKey); keys.Add(contract.Address, key); keys.Add(Neo.SmartContract.Contract.CreateSignatureContract(keyPair.PublicKey).Address, keyPair); uut.CreateAccount(key.PrivateKey); uut.CreateAccount(keyPair.PrivateKey); foreach (var account in uut.GetAccounts()) { if (!keys.TryGetValue(account.Address, out KeyPair k)) { Assert.Fail(); } } }
public void TestCreateAccountWithKeyPair() { Neo.SmartContract.Contract contract = Neo.SmartContract.Contract.CreateSignatureContract(keyPair.PublicKey); bool result = uut.Contains(testScriptHash); Assert.AreEqual(false, result); uut.CreateAccount(contract); result = uut.Contains(testScriptHash); Assert.AreEqual(true, result); uut.DeleteAccount(testScriptHash); result = uut.Contains(testScriptHash); Assert.AreEqual(false, result); uut.Unlock("123"); uut.CreateAccount(contract, keyPair); result = uut.Contains(testScriptHash); Assert.AreEqual(true, result); }