示例#1
0
        public void TestAddCreateTransaction()
        {
            using (var lServerAccess = new ServerAccess.PandoraWalletServiceAccess("localhost", 20159, false))
                if (lServerAccess.Logon("*****@*****.**", "davinci", "test"))
                {
                    var lControl  = CurrencyControl.GetCurrencyControl();
                    var lRootSeed = lControl.GenerateRootSeed("*****@*****.**", "davinci", "test");
                    var lAdvocacy = lControl.GetCryptoCurrency(1, "");
                    lAdvocacy.RootSeed = lRootSeed;
                    lServerAccess.AddMonitoredAccount(1, lAdvocacy.GetAddress(10));
                    var lTransaction = new CurrencyTransaction();
                    var s            = lServerAccess.GetTransactionRecords(1, 0);
                    var lTxList      = Newtonsoft.Json.JsonConvert.DeserializeObject <TransactionRecord[]>(s, new Pandora.Client.ClientLib.PandoraJsonConverter());
                    var lTx          = lTxList[0];
                    lTransaction.AddInput(lTx.Outputs[0]);
                    lTransaction.AddOutput(lTx.Outputs[0].Amount - 1000, "mzqD8sEGXfRMvcnNnkoGn6wyMN9AGUxaAB");
                    lTransaction.CurrencyId = 1;
                    lTransaction.TxFee      = 1000;
                    var lTxData = lServerAccess.CreateTransaction(lTransaction);

                    lTxData = lAdvocacy.SignTransaction(lTxData, lTransaction);

                    //lServerAccess.SendTransaction(1, lTxData);
                    lServerAccess.Logoff();
                }
                else
                {
                    throw new Exception("Basic Logon and log off failed.");
                }
        }
示例#2
0
 public void TestAddGetRemoveCurrencyAccount()
 {
     using (var lServerAccess = new ServerAccess.PandoraWalletServiceAccess("localhost", 20159, false))
         if (lServerAccess.Logon("*****@*****.**", "davinci", "test"))
         {
             var lControl  = CurrencyControl.GetCurrencyControl();
             var lRootSeed = lControl.GenerateRootSeed("*****@*****.**", "davinci", "test");
             var lAdvocacy = lControl.GetCryptoCurrency(1, "");
             lAdvocacy.RootSeed = lRootSeed;
             lServerAccess.AddMonitoredAccount(1, lAdvocacy.GetAddress(10));
             lServerAccess.AddMonitoredAccount(1, lAdvocacy.GetAddress(11));
             var lList = Newtonsoft.Json.JsonConvert.DeserializeObject <CurrencyAccount[]>(lServerAccess.GetMonitoredAcccounts(1, 0));
             foreach (var lItem in lList)
             {
                 Assert.IsTrue(lServerAccess.RemoveMonitoredAcccounts(lItem.Id));
             }
             lList = Newtonsoft.Json.JsonConvert.DeserializeObject <CurrencyAccount[]>(lServerAccess.GetMonitoredAcccounts(1, 0));
             Assert.IsTrue(lList.Length == 0, "Not all accounts were removed.");
             lServerAccess.Logoff();
         }
         else
         {
             throw new Exception("Basic Logon and log off failed.");
         }
 }
示例#3
0
 public void TestGetBlockHeight()
 {
     using (var lServerAccess = new ServerAccess.PandoraWalletServiceAccess("localhost", 20159, false))
         if (lServerAccess.Logon("*****@*****.**", "test", "test"))
         {
             var lVal = lServerAccess.GetBlockHeight(1);
             Assert.IsTrue(lVal > 0);
         }
 }
示例#4
0
 public void TestLogon()
 {
     using (var lServerAccess = new ServerAccess.PandoraWalletServiceAccess("localhost", 20159, false))
         if (lServerAccess.Logon("*****@*****.**", "Dj", "test"))
         {
             return;//lServerAccess.Logoff();
         }
         else
         {
             throw new Exception("Basic Logon and log off failed.");
         }
 }
示例#5
0
 public void TestGetCurrencyIcon()
 {
     using (var lServerAccess = new ServerAccess.PandoraWalletServiceAccess("localhost", 20159, false))
         if (lServerAccess.Logon("*****@*****.**", "Dj", "test"))
         {
             var lList = Newtonsoft.Json.JsonConvert.DeserializeObject <byte[]>(lServerAccess.GetCurrencyIcon(1));
             Assert.AreEqual(lList.Length > 0, true);
             using (MemoryStream lStream = new MemoryStream(lList))
                 new System.Drawing.Icon(lStream, 64, 64);
             lServerAccess.Logoff();
         }
         else
         {
             throw new Exception("Basic Logon and log off failed.");
         }
 }
示例#6
0
 public void TestGetTransactionRecords()
 {
     using (var lServerAccess = new ServerAccess.PandoraWalletServiceAccess("localhost", 20159, false))
         if (lServerAccess.Logon("*****@*****.**", "test", "test"))
         {
             var s          = lServerAccess.GetTransactionRecords(1, 0);
             var lTXRecList = Newtonsoft.Json.JsonConvert.DeserializeObject <TransactionRecord[]>(s, FJsonConverter);
             Assert.IsTrue(lTXRecList.Length > 0, "No transaction records found.");
             Assert.IsTrue(lTXRecList[0].TransactionRecordId != 0, "Deserialization may have failed.");
             lServerAccess.Logoff();
         }
         else
         {
             throw new Exception("Basic Logon and log off failed.");
         }
 }
示例#7
0
        public void TestNoUserStatus()
        {
            var lServerAccess = new ServerAccess.PandoraWalletServiceAccess("localhost", 20159, false);

            if (lServerAccess.Logon("*****@*****.**", "Dj", "test"))
            {
                var s     = lServerAccess.GetUserStatus();
                var lStat = Newtonsoft.Json.JsonConvert.DeserializeObject <UserStatus>(s, FJsonConverter);
                Assert.AreEqual(lStat.Active, false);
                Assert.AreEqual(lStat.ExtendedInfo, "User has no status.");
                Assert.IsTrue(lStat.StatusDate > DateTime.Parse("2018-06-21"));
            }
            else
            {
                throw new Exception("Basic Logon and log off failed.");
            }
        }
示例#8
0
        public void TestGetCurrencyStatusList()
        {
            using (var lServerAccess = new ServerAccess.PandoraWalletServiceAccess("localhost", 20159, false))
            {
                if (lServerAccess.Logon("*****@*****.**", "Dj", "test"))
                {
                    CurrencyStatusItem[] lList = null;
                    string s = lServerAccess.GetCurrencyStatusList(1, 0);
                    lList = Newtonsoft.Json.JsonConvert.DeserializeObject <CurrencyStatusItem[]>(s, FJsonConverter);
                    var lLength = lList.Length;
                    Assert.AreEqual(lLength > 0, true);
                    Assert.AreEqual(lList[0].StatusId, 1);
                    Assert.AreEqual((ulong)1, lList[0].CurrencyId);
                    Assert.AreEqual(lList[0].BlockHeight, (ulong)0);
                    Assert.AreEqual(lList[0].Status, CurrencyStatus.Active);
                    Assert.AreEqual(lList[0].ExtendedInfo, "The coin is working fine with 3 servers running with consensus.");
                    Assert.IsTrue(lList[0].StatusTime > DateTime.Parse("2018-06-1"));

                    s       = lServerAccess.GetCurrencyStatusList(2, 0);
                    lList   = Newtonsoft.Json.JsonConvert.DeserializeObject <CurrencyStatusItem[]>(s, FJsonConverter);
                    lLength = lList.Length;
                    Assert.AreEqual(lLength > 0, true);
                    Assert.AreEqual(lList[0].StatusId, 2);
                    Assert.AreEqual(lList[0].CurrencyId, (ulong)2);
                    Assert.AreEqual(lList[0].BlockHeight, (ulong)0);
                    Assert.AreEqual(lList[0].Status, CurrencyStatus.Maintenance);
                    Assert.AreEqual(lList[0].ExtendedInfo, "The servers are under maintaince and should be back up soon.");
                    Assert.IsTrue(lList[0].StatusTime > DateTime.Parse("2018-06-1"));

                    s       = lServerAccess.GetCurrencyStatusList(3, 0);
                    lList   = Newtonsoft.Json.JsonConvert.DeserializeObject <CurrencyStatusItem[]>(s, FJsonConverter);
                    lLength = lList.Length;
                    Assert.AreEqual(lLength > 0, true);
                    Assert.AreEqual(3, lList[0].StatusId);
                    Assert.AreEqual(lList[0].CurrencyId, (ulong)3);
                    Assert.AreEqual(lList[0].BlockHeight, (ulong)0);
                    Assert.AreEqual(lList[0].Status, CurrencyStatus.Disabled);
                    Assert.AreEqual(lList[0].ExtendedInfo, "Coin may not come back up.");
                    Assert.IsTrue(lList[0].StatusTime > DateTime.Parse("2018-06-1"));
                }
                else
                {
                    throw new Exception("Basic Logon and log off failed.");
                }
            }
        }
示例#9
0
        public void TestGetCurrencyList()
        {
            using (var lServerAccess = new ServerAccess.PandoraWalletServiceAccess("localhost", 20159, false))
            {
                if (lServerAccess.Logon("*****@*****.**", "Dj", "test"))
                {
                    CurrencyItem[] lList = null;
                    string         s     = lServerAccess.GetCurrencyList(0);
                    lList = Newtonsoft.Json.JsonConvert.DeserializeObject <CurrencyItem[]>(s, FJsonConverter);
                    var lLength = lList.Length;
                    Assert.AreEqual(lLength > 0, true);
                    Assert.AreEqual(lList[0].Name, "Bitcoin");
                    Assert.AreEqual(lList[0].Ticker, "BTC");
                    Assert.AreEqual(lList[0].MinConfirmations, 6);
                    Assert.AreEqual(lList[0].Precision, 8);
                    Assert.AreEqual(lList[0].Id, 1);
                    Assert.IsTrue(lList[0].LiveDate > DateTime.Parse("2017-12-31"));

                    Assert.AreEqual(lList[1].Name, "Litecoin");
                    Assert.AreEqual(lList[1].Ticker, "LTC");
                    Assert.AreEqual(lList[1].MinConfirmations, 24);
                    Assert.AreEqual(lList[1].Precision, 8);
                    Assert.AreEqual(lList[1].Id, 2);
                    Assert.IsTrue(lList[1].LiveDate > DateTime.Parse("2017-12-31"));

                    Assert.AreEqual(lList[2].Name, "Dash");
                    Assert.AreEqual(lList[2].Ticker, "DASH");
                    Assert.AreEqual(lList[2].MinConfirmations, 6);
                    Assert.AreEqual(lList[2].Precision, 8);
                    Assert.AreEqual(3, lList[2].Id);
                    Assert.IsTrue(lList[2].LiveDate > DateTime.Parse("2017-12-31"));
                }
                else
                {
                    throw new Exception("Basic Logon and log off failed.");
                }
            }
        }
示例#10
0
        public void TestSendTransaction()
        {
            using (var lServerAccess = new ServerAccess.PandoraWalletServiceAccess("localhost", 20159, false))
                if (lServerAccess.Logon("*****@*****.**", "davinci", "test"))
                {
                    var lTransaction = new CurrencyTransaction();
                    lTransaction.CurrencyId = 3;
                    var lControl  = CurrencyControl.GetCurrencyControl();
                    var lRootSeed = lControl.GenerateRootSeed("*****@*****.**", "davinci", "test");
                    var lAdvocacy = lControl.GetCryptoCurrency(lTransaction.CurrencyId, "");
                    lAdvocacy.RootSeed = lRootSeed;
                    var lAddress = lAdvocacy.GetAddress(10);
                    lServerAccess.AddMonitoredAccount(lTransaction.CurrencyId, lAddress);

                    var s       = lServerAccess.GetTransactionRecords(lTransaction.CurrencyId, 0);
                    var lTxList = Newtonsoft.Json.JsonConvert.DeserializeObject <TransactionRecord[]>(s, new Pandora.Client.ClientLib.PandoraJsonConverter());
                    var lTx     = lTxList[0];
                    lTransaction.AddInput(lTx.Outputs[0]);
                    lTransaction.AddOutput(lTx.Outputs[0].Amount - 1000, "yPueC9mAxBj7yrPxj4M2vNY3rn4Yz3thrY");
                    lTransaction.TxFee = 1000;
                    var lTxData = lServerAccess.CreateTransaction(lTransaction);

                    lTxData = lAdvocacy.SignTransaction(lTxData, lTransaction);

                    var lHandle = lServerAccess.SendTransaction(lTransaction.CurrencyId, lTxData);
                    System.Threading.Thread.Sleep(5000);
                    if (lServerAccess.IsTransactionSent(lHandle))
                    {
                        var lTxId = lServerAccess.GetTransactionId(lHandle);
                    }
                    lServerAccess.Logoff();
                }
                else
                {
                    throw new Exception("Basic Logon and log off failed.");
                }
        }