示例#1
0
    def test_account(self):
        account1 = Account()
        self.assertIsNotNone(account1)
        self.assertIsNone(account1.address)
        self.assertTrue(account1.icx == 0)
        self.assertFalse(account1.locked)
        self.assertFalse(account1.c_rep)

        account1.address = create_address()

        account1.deposit(100)
        self.assertEqual(100, account1.icx)

        account1.withdraw(100)
        self.assertEqual(0, account1.icx)

        # wrong value
        self.assertRaises(InvalidParamsException, account1.deposit, -10)

        # 0 transfer is possible
        old = account1.icx
        account1.deposit(0)
        self.assertEqual(old, account1.icx)

        self.assertRaises(InvalidParamsException, account1.withdraw, -11234)
        self.assertRaises(OutOfBalanceException, account1.withdraw, 1)

        old = account1.icx
        account1.withdraw(0)
        self.assertEqual(old, account1.icx)
示例#2
0
    def test_get_put_account(self):
        context = self.context
        account = Account()
        account.address = create_address(AddressPrefix.EOA)
        account.deposit(10**19)

        self.storage.put_account(context, account.address, account)

        account2 = self.storage.get_account(context, account.address)
        self.assertEqual(account, account2)
示例#3
0
    def test_get_put_account(self):
        context = self.context
        account = Account()
        account.deposit(10**19)

        for address in self.addresses:
            account.address = address
            self.storage.put_account(context, account.address, account)

            account2 = self.storage.get_account(context, account.address)
            self.assertEqual(account, account2)
示例#4
0
    def test_delete_account(self):
        context = self.context
        account = Account()
        account.address = create_address(AddressPrefix.EOA)
        self.storage.put_account(context, account.address, account)

        ret = self.storage.is_address_present(context, account.address)
        self.assertTrue(ret)

        self.storage.delete_account(context, account.address)

        ret = self.storage.is_address_present(context, self.address)
        self.assertFalse(ret)
示例#5
0
    def test_delete_account(self):
        context = self.context
        account = Account()

        for address in self.addresses:
            account.address = address
            self.storage.put_account(context, account.address, account)

            ret = self.storage.is_address_present(context, account.address)
            self.assertTrue(ret)

            self.storage.delete_account(context, account.address)

            ret = self.storage.is_address_present(context, account.address)
            self.assertFalse(ret)