Exemplo n.º 1
0
        public void WithdrawVakacoin()
        {
            var walletRepository =
                _vakapayRepositoryFactory.GetWalletRepository(_vakapayRepositoryFactory.GetOldConnection());
            var userRepo = _vakapayRepositoryFactory.GetUserRepository(_vakapayRepositoryFactory.GetOldConnection());
            var wallet   = walletRepository.FindByUserAndNetwork(
                userRepo.FindByEmailAddress("*****@*****.**").Id,
                CryptoCurrency.VAKA);

            var res = _walletBusiness.Withdraw(wallet, "useraaaaaaab", (decimal)0.0001, 0);

            Assert.AreEqual(res.Status, Status.STATUS_SUCCESS);
        }
Exemplo n.º 2
0
        public void InitFakeAddressAndCoin()
        {
            var repositoryConfig = new RepositoryConfiguration
            {
                ConnectionString = AppSettingHelper.GetDbConnection()
            };

            //Create user active for test
            var persistenceFactory = new VakapayRepositoryMysqlPersistenceFactory(repositoryConfig);
            var connection         = persistenceFactory.GetDbConnection();
            var userRepo           = persistenceFactory.GetUserRepository(connection);
            var walletRepo         = persistenceFactory.GetWalletRepository(connection);


            //fake userId
            for (int i = 1; i < 10; i++)
            {
                var ins = userRepo.Insert(
                    new User()
                {
                    Id     = i.ToString(),
                    Status = "Active"
                }
                    );
                Assert.AreEqual(Status.STATUS_SUCCESS, ins.Status);
            }

            //create wallet without address
            for (int i = 1; i < 10; i++)
            {
                CreateAllWalletForUser(i.ToString());
            }

            //insert address into WalletDb
            // and insert to ethereumAddress
            for (int i = 1; i < 10; i++)
            {
                var prepareWallet = walletRepo.FindByUserAndNetwork(i.ToString(), CryptoCurrency.ETH);
                CreateNewAddressAsync(prepareWallet.Id);
            }

            //send coin from rootAddress to new address
            for (int i = 1; i < 10; i++)
            {
                var prepareWallet = walletRepo.FindByUserAndNetwork(i.ToString(), CryptoCurrency.ETH);
                //Todo update prepareWallet.Address
                //				InsertPendingTxsToWithdraw("46b4594c-a45a-400d-86ce-9a7869d61180", prepareWallet.Address);
            }
        }
Exemplo n.º 3
0
        public void CreateRadomPendingTxsToWithdraw()
        {
            var repositoryConfig = new RepositoryConfiguration()
            {
                ConnectionString = AppSettingHelper.GetDbConnection()
            };

            var persistence = new VakapayRepositoryMysqlPersistenceFactory(repositoryConfig);

            _walletBusiness =
                new Vakapay.WalletBusiness.WalletBusiness(persistence);


            var connection = persistence.GetDbConnection();
            var walletRepo = persistence.GetWalletRepository(connection);

            ReturnObject resultTest = null;

            for (int i = 0; i < 1000; i++)
            {
                var rndFrom    = new Random().Next(1, 10);
                var rndTo      = new Random().Next(1, 10);
                var fromWallet = walletRepo.FindByUserAndNetwork(rndFrom.ToString(), CryptoCurrency.ETH);

                while (rndFrom == rndTo)
                {
                    rndTo = new Random().Next(1, 10);
                }

                var toWalletAddr = walletRepo.FindByUserAndNetwork(rndTo.ToString(), CryptoCurrency.ETH);
                // TODO
                //				resultTest = _walletBusiness.Withdraw(fromWallet, toWalletAddr.Address, 1);
            }

            Console.WriteLine(JsonHelper.SerializeObject(resultTest));
            Assert.AreEqual(Status.STATUS_SUCCESS, resultTest.Status);
        }