def test_balance(self): with patch('cc.tasks.AuthServiceProxy', self.mock): tasks.query_transactions('DOGE') wallet = Wallet.objects.get(id=self.wallet.id) self.assertEqual(wallet.balance, Decimal('576.1649163'))
def test_deposit_from_z(self): zaddress = self.coin.z_getnewaddress('sprout') unspent = [u for u in self.coin.listunspent() if u['amount'] > 6][0] amount = unspent['amount'] operation1 = self.coin.z_sendmany(unspent['address'], [{ 'address': zaddress, 'amount': amount }], 1, 0) self.wait_for_operation(operation1) self.coin.generate(6) wallet_before = Wallet.objects.create(currency=self.currency) address = wallet_before.get_address().address operation2 = self.coin.z_sendmany(zaddress, [{ 'address': address, "amount": amount }], 1, 0) self.wait_for_operation(operation2) self.coin.generate(1) tasks.query_transactions('tzec') wallet_after1 = Wallet.objects.get(id=wallet_before.id) self.assertEqual(wallet_after1.balance, Decimal('0')) self.assertEqual(wallet_after1.holded, Decimal('0')) self.assertGreaterEqual(wallet_after1.unconfirmed, amount) # FIXME should be assertEqual self.coin.generate(1) tasks.query_transactions('tzec') wallet_after2 = Wallet.objects.get(id=wallet_before.id) self.assertEqual(wallet_after2.balance, amount) self.assertEqual(wallet_after2.holded, Decimal('0')) self.assertGreaterEqual(wallet_after2.unconfirmed, Decimal('0')) # FIXME should be assertEqual
def test_deposit_from_z(self): zaddress = self.coin.z_getnewaddress('sprout') unspent = [u for u in self.coin.listunspent() if u['amount'] > 6][0] amount = unspent['amount'] operation1 = self.coin.z_sendmany(unspent['address'], [{'address': zaddress, 'amount': amount}], 1, 0) self.wait_for_operation(operation1) self.coin.generate(6) wallet_before = Wallet.objects.create(currency=self.currency) address = wallet_before.get_address().address operation2 = self.coin.z_sendmany(zaddress, [{'address': address, "amount": amount}], 1, 0) self.wait_for_operation(operation2) self.coin.generate(1) tasks.query_transactions('tzec') wallet_after1 = Wallet.objects.get(id=wallet_before.id) self.assertEqual(wallet_after1.balance, Decimal('0')) self.assertEqual(wallet_after1.holded, Decimal('0')) self.assertGreaterEqual(wallet_after1.unconfirmed, amount) # FIXME should be assertEqual self.coin.generate(1) tasks.query_transactions('tzec') wallet_after2 = Wallet.objects.get(id=wallet_before.id) self.assertEqual(wallet_after2.balance, amount) self.assertEqual(wallet_after2.holded, Decimal('0')) self.assertGreaterEqual(wallet_after2.unconfirmed, Decimal('0')) # FIXME should be assertEqual
def test_deposit(self): wallet_before = Wallet.objects.create(currency=self.currency) address = wallet_before.get_address().address self.coin.sendtoaddress(address, Decimal('1')) self.coin.generate(1) tasks.query_transactions('tdsh') wallet_after1 = Wallet.objects.get(id=wallet_before.id) self.assertEqual(wallet_after1.balance, Decimal('0')) self.assertEqual(wallet_after1.holded, Decimal('0')) self.assertEqual(wallet_after1.unconfirmed, Decimal('1')) self.coin.generate(1) tasks.query_transactions('tdsh') wallet_after2 = Wallet.objects.get(id=wallet_before.id) self.assertEqual(wallet_after2.balance, Decimal('1')) self.assertEqual(wallet_after2.holded, Decimal('0')) self.assertEqual(wallet_after2.unconfirmed, Decimal('0'))
def test_deposit(self): wallet_before = Wallet.objects.create(currency=self.currency) address = wallet_before.get_address().address self.coin.sendtoaddress(address, Decimal('1')) self.coin.generate(1) tasks.query_transactions('tdsh') wallet_after1 = Wallet.objects.get(id=wallet_before.id) self.assertEqual(wallet_after1.balance, Decimal('0')) self.assertEqual(wallet_after1.holded, Decimal('0')) self.assertEqual(wallet_after1.unconfirmed, Decimal('1')) self.coin.generate(1) tasks.query_transactions('tdsh') wallet_after2 = Wallet.objects.get(id=wallet_before.id) self.assertEqual(wallet_after2.balance, Decimal('1')) self.assertEqual(wallet_after2.holded, Decimal('0')) self.assertEqual(wallet_after2.unconfirmed, Decimal('0'))
def check_deposit(request): query_transactions() request.user.user_ext.wallet.recalc_balance(True) return redirect('wallet-details')