示例#1
0
 def test_endow_contract_sender(self):
     amount = 50 * UNIT
     alice = fresh_account()
     self.assertReverts(self.endow, self.havven_real.address, alice, amount)
     self.assertEqual(self.balanceOf(alice), 0)
示例#2
0
 def test_double_withdraw_fee(self):
     alice = fresh_account()
     self.withdrawFeeEntitlement(alice)
     self.assertReverts(self.withdrawFeeEntitlement, alice)
示例#3
0
 def test_endow_more_than_supply(self):
     amount = self.totalSupply() * 2
     alice = fresh_account()
     self.assertReverts(self.endow, MASTER, alice, amount)
     self.assertEqual(self.balanceOf(alice), 0)
示例#4
0
 def test_endow_invalid_sender(self):
     amount = 50 * UNIT
     alice = fresh_account()
     self.assertReverts(self.endow, alice, alice, amount)
     self.assertEqual(self.balanceOf(alice), 0)
示例#5
0
 def test_invalidSetEscrow(self):
     alice = fresh_account()
     self.assertReverts(self.setEscrow, alice, alice)
示例#6
0
 def test_setEscrow(self):
     alice = fresh_account()
     self.setEscrow(MASTER, alice)
     self.assertEqual(self.get_escrow(), alice)
示例#7
0
 def test_invalidSetNomin(self):
     alice = fresh_account()
     self.assertReverts(self.setNomin, alice, alice)
示例#8
0
 def test_setNomin(self):
     alice = fresh_account()
     self.setNomin(MASTER, alice)
     self.assertEqual(self.get_nomin(), alice)
    def test_transferFrom(self):
        approver = MASTER
        spender, receiver = fresh_accounts(2)

        approver_balance = self.token.balanceOf(approver)
        spender_balance = self.token.balanceOf(spender)
        receiver_balance = self.token.balanceOf(receiver)

        value = 10 * UNIT
        total_supply = self.token.totalSupply()

        # This fails because there has been no approval yet
        self.assertReverts(self.token.transferFrom, spender, approver,
                           receiver, value)

        tx_receipt = self.token.approve(approver, spender, 2 * value)
        # Check event is emitted properly.
        self.assertEqual(
            get_event_data_from_log(self.token_event_dict,
                                    tx_receipt.logs[0])['event'], "Approval")
        self.assertEqual(self.token.allowance(approver, spender), 2 * value)

        self.assertReverts(self.token.transferFrom, spender, approver,
                           receiver, 2 * value + 1)
        tx_receipt = self.token.transferFrom(spender, approver, receiver,
                                             value)
        # Check event is emitted properly.
        self.assertEqual(
            get_event_data_from_log(self.token_event_dict,
                                    tx_receipt.logs[0])['event'], "Transfer")

        self.assertEqual(self.token.balanceOf(approver),
                         approver_balance - value)
        self.assertEqual(self.token.balanceOf(spender), spender_balance)
        self.assertEqual(self.token.balanceOf(receiver),
                         receiver_balance + value)
        self.assertEqual(self.token.allowance(approver, spender), value)
        self.assertEqual(self.token.totalSupply(), total_supply)

        # Empty the account
        tx_receipt = self.token.transferFrom(spender, approver, receiver,
                                             value)
        # Check event is emitted properly.
        self.assertEqual(
            get_event_data_from_log(self.token_event_dict,
                                    tx_receipt.logs[0])['event'], "Transfer")

        approver = fresh_account()
        # This account has no tokens
        approver_balance = self.token.balanceOf(approver)
        self.assertEqual(approver_balance, 0)
        self.assertEqual(self.token.allowance(approver, spender), 0)

        tx_receipt = self.token.approve(approver, spender, value)
        # Check event is emitted properly.
        self.assertEqual(
            get_event_data_from_log(self.token_event_dict,
                                    tx_receipt.logs[0])['event'], "Approval")
        self.assertEqual(self.token.allowance(approver, spender), value)

        # This should fail because the approver has no tokens.
        self.assertReverts(self.token.transferFrom, spender, approver,
                           receiver, value)