Exemple #1
0
 def test_wallet_total_amount(self):
     wallet = Wallet(100)
     self.assertEqual(wallet._total_amount(), 100)
     wallet.add_amount(200)
     self.assertEqual(wallet._total_amount(), 300)
     wallet.spend_amount(50)
     self.assertEqual(wallet._total_amount(), 250)
Exemple #2
0
def main(ctx, **kwargs):
    state = kwargs

    # load wallet from mnemonic for specified child
    try:
        wallet = Wallet.from_json(state.get('secret'),
                                  state.get('wallet_child'))
    except:
        raise click.UsageError(
            'unable to initialize wallet, ensure that secrets.json is set correctly.'
        )

    state.update({
        'wallet': {
            'address': wallet.address,
            'private_key': wallet.private_key
        }
    })

    state.update({'platform': defaults.get('platform')})

    # add a little padding
    print('')

    # fund bounty
    handler(state)
Exemple #3
0
 def test_wallet_amount_spent_variable_shows_correct_result(self):
     wallet = Wallet()
     wallet.add_amount(100)
     wallet.spend_amount(50)
     self.assertEqual(wallet.AMOUNT_SPENT, 50)
Exemple #4
0
 def test_wallet_amount_added_variable_shows_correct_result(self):
     wallet = Wallet()
     wallet.add_amount(100)
     self.assertEqual(wallet.AMOUNT_ADDED, 100)
Exemple #5
0
 def test_default_initial_amount(self):
     wallet = Wallet()
     self.assertEqual(wallet.amount, 0)
Exemple #6
0
 def test_wallet_spend_amount_raises_type_error_exception(self):
     wallet = Wallet(100)
     with self.assertRaises(TypeError):
         wallet.spend_amount("2")
Exemple #7
0
 def test_wallet_spend_amount(self):
     wallet = Wallet(100)
     result = wallet.spend_amount(50)
     self.assertEqual(result, 50)
Exemple #8
0
 def test_wallet_spend_amount_raises_insufficientamount_exception(self):
     wallet = Wallet(100)
     with self.assertRaises(exceptions.InsufficientAmount):
         wallet.spend_amount(200)
Exemple #9
0
 def test_wallet_add_amount_raises_type_error_exception(self):
     wallet = Wallet()
     with self.assertRaises(TypeError):
         wallet.add_amount("1")
Exemple #10
0
 def test_wallet_add_amount_raises_negativeamount_exception(self):
     wallet = Wallet()
     with self.assertRaises(exceptions.NegativeAmount):
         wallet.add_amount(-100)
Exemple #11
0
 def test_wallet_add_amount(self):
     wallet = Wallet(100)
     result = wallet.add_amount(100)
     self.assertEqual(result, 200)
Exemple #12
0
 def test_setting_initial_amount_raises_negativeamount_exception(self):
     with self.assertRaises(exceptions.NegativeAmount):
         Wallet(-2)
Exemple #13
0
 def test_setting_initial_amount_raises_type_error_exception(self):
     with self.assertRaises(TypeError):
         Wallet("1")
Exemple #14
0
 def test_setting_initial_amount(self):
     wallet = Wallet(100)
     self.assertEqual(wallet.amount, 100)
Exemple #15
0
from utils.wallet import Wallet
from heading import header

wallet = Wallet()

print(header)
CHOICE = """1. Add amount
2. Spend amount
3. view total amount
0. Quit
: """
choice = int(input(CHOICE))

while choice != 0:
    if choice in [1, 2, 3]:
        if choice == 1:
            amount = int(input("Enter an amount: "))
            wallet.add_amount(amount)
            print("Amount added. \n")
        elif choice == 2:
            amount = int(input("Enter an amount: "))
            wallet.spend_amount(amount)
            print("Amount deducted. \n")
        elif choice == 3:
            print(
                "\nRemaining amount: {} | Amount added: {} | Amount Spent: {}\n"
                .format(wallet.get_total_amount(), wallet.AMOUNT_ADDED,
                        wallet.AMOUNT_SPENT))
        choice = int(input(CHOICE))
    else:
        print("Invalid option.")