Пример #1
0
        public async Task Account_Create_And_Open()
        {
            var keyPair = await _keyStore.CreateAccountKeyPairAsync("123");

            keyPair.ShouldNotBe(null);
            _keyStore.GetAccountsAsync().Result.Count.ShouldBeGreaterThanOrEqualTo(1);

            var address   = Address.FromPublicKey(keyPair.PublicKey);
            var addString = address.GetFormatted();

            address.ShouldNotBe(null);

            //Open account
            var errResult = await _keyStore.UnlockAccountAsync(addString, "12");

            errResult.ShouldBe(AccountError.WrongPassword);

            errResult = await _keyStore.UnlockAccountAsync(addString, "123");

            errResult.ShouldBe(AccountError.None);

            errResult = await _keyStore.UnlockAccountAsync(addString, "123");

            errResult.ShouldBe(AccountError.AccountAlreadyUnlocked);

            errResult = await _keyStore.UnlockAccountAsync(addString, "123");

            errResult.ShouldBe(AccountError.AccountAlreadyUnlocked);

            await Should.ThrowAsync <KeyStoreNotFoundException>(() => _keyStore.ReadKeyPairAsync(addString + "_fake", "123"));

            Directory.Delete(Path.Combine(_nodeEnvironmentService.GetAppDataPath(), "keys"), true);
            await Should.ThrowAsync <KeyStoreNotFoundException>(() => _keyStore.ReadKeyPairAsync(addString, "123"));
        }
Пример #2
0
        public void GetAppDataPath_Test()
        {
            var path = _nodeEnvironmentService.GetAppDataPath();

            path.ShouldNotBeNull();
            path.ShouldContain("aelf");
        }
Пример #3
0
        private void DeleteTestFolder()
        {
            var path = Path.Combine(_nodeEnvironmentService.GetAppDataPath(), "keys");

            if (Directory.Exists(path))
            {
                Directory.Delete(path, true);
            }
        }
Пример #4
0
 private string GetKeystoreDirectoryPath()
 {
     return(Path.Combine(_nodeEnvironmentService.GetAppDataPath(), KeyFolderName));
 }