def test_change_state(self):
        lucky_one = fresh_account()

        print()
        # Deploy contract and old tokenstate
        _old_tokenstate, _ = attempt_deploy(self.compiled, 'TokenState',
                                            MASTER, [MASTER, MASTER])
        old_tokenstate = TokenStateInterface(_old_tokenstate, 'TokenState')
        _token, _ = attempt_deploy(self.compiled, 'ExternStateToken', MASTER, [
            self.proxy.address, old_tokenstate.contract.address, "Test Token",
            "TEST", 1000 * UNIT, 18, MASTER
        ])
        token = ExternStateTokenInterface(_token, 'ExternStateToken')
        mine_txs([
            self.proxy.functions.setTarget(token.contract.address).transact(
                {"from": MASTER})
        ])

        old_tokenstate.setAssociatedContract(MASTER, token.contract.address)
        self.assertEqual(token.balanceOf(lucky_one), 0)
        self.assertEqual(old_tokenstate.balanceOf(lucky_one), 0)

        # Deploy new tokenstate and swap it out with the existing one.
        _new_tokenstate, _ = attempt_deploy(self.compiled, 'TokenState',
                                            MASTER, [MASTER, MASTER])
        new_tokenstate = TokenStateInterface(_new_tokenstate, 'TokenState')
        new_tokenstate.setBalanceOf(MASTER, lucky_one, UNIT)
        new_tokenstate.setAssociatedContract(MASTER, token.contract.address)
        token.setTokenState(MASTER, new_tokenstate.contract.address)

        self.assertEqual(token.tokenState(), new_tokenstate.contract.address)
        self.assertEqual(token.balanceOf(lucky_one), UNIT)
        self.assertEqual(new_tokenstate.balanceOf(lucky_one), UNIT)
예제 #2
0
    def deploy_contracts(cls):
        sources = [
            'tests/contracts/PublicEST.sol', 'contracts/ExternStateToken.sol',
            'contracts/TokenState.sol', 'contracts/Proxy.sol'
        ]

        compiled, cls.event_maps = cls.compileAndMapEvents(sources)

        proxy_contract, _ = attempt_deploy(compiled, "Proxy", MASTER, [MASTER])

        tokenstate, _ = attempt_deploy(compiled, 'TokenState', MASTER,
                                       [MASTER, MASTER])

        token_contract, construction_txr = attempt_deploy(
            compiled, 'PublicEST', MASTER, [
                proxy_contract.address, "Test Token", "TEST", 1000 * UNIT,
                tokenstate.address, MASTER
            ])

        token_abi = compiled['PublicEST']['abi']
        token_event_dict = generate_topic_event_map(token_abi)

        proxied_token = W3.eth.contract(address=proxy_contract.address,
                                        abi=token_abi)

        mine_txs([
            tokenstate.functions.setBalanceOf(MASTER, 1000 * UNIT).transact(
                {'from': MASTER}),
            tokenstate.functions.setAssociatedContract(
                token_contract.address).transact({'from': MASTER}),
            proxy_contract.functions.setTarget(
                token_contract.address).transact({'from': MASTER})
        ])
        return proxy_contract, proxied_token, compiled, token_contract, token_abi, token_event_dict, tokenstate
예제 #3
0
    def test_balance_after_swap(self):
        sender = self.initial_beneficiary

        receiver = fresh_account()
        receiver_balance = self.feetoken.balanceOf(receiver)
        self.assertEqual(receiver_balance, 0)

        value = 10 * UNIT
        amountReceived = self.feetoken.amountReceived(value)
        fee = value - amountReceived
        tx_receipt = self.feetoken.transfer(sender, receiver, value)

        self.assertEqual(self.feetoken.balanceOf(receiver),
                         receiver_balance + amountReceived)

        self.proxy.setTarget(MASTER, self.feetoken_contract_2.address)
        self.feestate.setAssociatedContract(MASTER,
                                            self.feetoken_contract_2.address)

        mine_txs([
            self.feetoken_contract_2.functions.setTokenState(
                self.feestate.contract.address).transact({'from': MASTER})
        ])

        self.assertEqual(self.feetoken.balanceOf(receiver),
                         receiver_balance + amountReceived)
예제 #4
0
    def deployContracts(cls):
        sources = ["tests/contracts/PublicNomin.sol", "tests/contracts/FakeCourt.sol", "contracts/Havven.sol"]

        compiled, cls.event_maps = cls.compileAndMapEvents(sources)

        havven_proxy, _ = attempt_deploy(compiled, 'Proxy', MASTER, [MASTER])
        nomin_proxy, _ = attempt_deploy(compiled, 'Proxy', MASTER, [MASTER])
        proxied_havven = W3.eth.contract(address=havven_proxy.address, abi=compiled['Havven']['abi'])
        proxied_nomin = W3.eth.contract(address=nomin_proxy.address, abi=compiled['PublicNomin']['abi'])

        nomin_state, txr = attempt_deploy(
            compiled, "TokenState", MASTER,
            [MASTER, MASTER]
        )
        nomin_contract, _ = attempt_deploy(
            compiled, 'PublicNomin', MASTER, [nomin_proxy.address, nomin_state.address, MASTER, 0, MASTER]
        )

        havven_contract, _ = attempt_deploy(
            compiled, "Havven", MASTER, [havven_proxy.address, ZERO_ADDRESS, MASTER, MASTER, UNIT//2, [], ZERO_ADDRESS]
        )

        fake_court, _ = attempt_deploy(compiled, 'FakeCourt', MASTER, [])

        mine_txs([
            nomin_state.functions.setAssociatedContract(nomin_contract.address).transact({'from': MASTER}),
            havven_proxy.functions.setTarget(havven_contract.address).transact({'from': MASTER}),
            nomin_proxy.functions.setTarget(nomin_contract.address).transact({'from': MASTER}),
            havven_contract.functions.setNomin(nomin_contract.address).transact({'from': MASTER}),
            nomin_contract.functions.setCourt(fake_court.address).transact({'from': MASTER}),
            nomin_contract.functions.setHavven(havven_contract.address).transact({'from': MASTER})
        ])

        return havven_proxy, proxied_havven, nomin_proxy, proxied_nomin, nomin_contract, havven_contract, fake_court, nomin_state
    def deployContracts(cls):
        sources = [
            "tests/contracts/PublicHavven.sol",
            "tests/contracts/PublicNomin.sol",
            "contracts/IssuanceController.sol"
        ]

        compiled, cls.event_maps = cls.compileAndMapEvents(sources)
        nomin_abi = compiled['PublicNomin']['abi']
        havven_abi = compiled['PublicHavven']['abi']
        issuance_controller_abi = compiled['IssuanceController']['abi']

        havven_proxy, _ = attempt_deploy(compiled, 'Proxy', MASTER, [MASTER])
        nomin_proxy, _ = attempt_deploy(compiled, 'Proxy', MASTER, [MASTER])
        proxied_havven = W3.eth.contract(address=havven_proxy.address,
                                         abi=havven_abi)
        proxied_nomin = W3.eth.contract(address=nomin_proxy.address,
                                        abi=nomin_abi)

        havven_tokenstate, _ = attempt_deploy(compiled, 'TokenState', MASTER,
                                              [MASTER, MASTER])
        nomin_tokenstate, _ = attempt_deploy(compiled, 'TokenState', MASTER,
                                             [MASTER, MASTER])
        havven_contract, hvn_txr = attempt_deploy(
            compiled, 'PublicHavven', MASTER, [
                havven_proxy.address, havven_tokenstate.address, MASTER,
                MASTER, UNIT // 2, [], ZERO_ADDRESS
            ])
        nomin_contract, nom_txr = attempt_deploy(
            compiled, 'PublicNomin', MASTER, [
                nomin_proxy.address, nomin_tokenstate.address,
                havven_contract.address, 0, MASTER
            ])

        mine_txs([
            havven_tokenstate.functions.setBalanceOf(
                havven_contract.address,
                100000000 * UNIT).transact({'from': MASTER}),
            havven_tokenstate.functions.setAssociatedContract(
                havven_contract.address).transact({'from': MASTER}),
            nomin_tokenstate.functions.setAssociatedContract(
                nomin_contract.address).transact({'from': MASTER}),
            havven_proxy.functions.setTarget(havven_contract.address).transact(
                {'from': MASTER}),
            nomin_proxy.functions.setTarget(nomin_contract.address).transact(
                {'from': MASTER}),
            havven_contract.functions.setNomin(
                nomin_contract.address).transact({'from': MASTER}),
        ])

        issuanceControllerContract, _ = attempt_deploy(
            compiled, 'IssuanceController', MASTER, [
                cls.contractOwner, cls.fundsWallet, havven_contract.address,
                nomin_contract.address, cls.oracleAddress, cls.usdToEthPrice,
                cls.usdToHavPrice
            ])

        return havven_proxy, proxied_havven, nomin_proxy, proxied_nomin, havven_contract, nomin_contract, nomin_abi, issuanceControllerContract
예제 #6
0
    def deployContracts(cls):
        sources = [
            "tests/contracts/PublicHavven.sol",
            "tests/contracts/PublicNomin.sol", "tests/contracts/FakeCourt.sol",
            "contracts/Havven.sol"
        ]
        print("Deployment initiated.\n")

        compiled, cls.event_maps = cls.compileAndMapEvents(sources)

        # Deploy contracts
        havven_proxy, _ = attempt_deploy(compiled, 'Proxy', MASTER, [MASTER])
        nomin_proxy, _ = attempt_deploy(compiled, 'Proxy', MASTER, [MASTER])
        proxied_havven = W3.eth.contract(address=havven_proxy.address,
                                         abi=compiled['PublicHavven']['abi'])
        proxied_nomin = W3.eth.contract(address=nomin_proxy.address,
                                        abi=compiled['PublicNomin']['abi'])
        havven_tokenstate, _ = attempt_deploy(compiled, 'TokenState', MASTER,
                                              [MASTER, MASTER])
        nomin_tokenstate, _ = attempt_deploy(compiled, 'TokenState', MASTER,
                                             [MASTER, MASTER])
        havven_contract, hvn_txr = attempt_deploy(
            compiled, 'PublicHavven', MASTER, [
                havven_proxy.address, havven_tokenstate.address, MASTER,
                MASTER, UNIT // 2, [], ZERO_ADDRESS
            ])
        nomin_contract, nom_txr = attempt_deploy(
            compiled, 'PublicNomin', MASTER, [
                nomin_proxy.address, nomin_tokenstate.address,
                havven_contract.address, 0, MASTER
            ])
        court_contract, court_txr = attempt_deploy(
            compiled, 'FakeCourt', MASTER,
            [havven_contract.address, nomin_contract.address, MASTER])

        # Hook up each of those contracts to each other
        mine_txs([
            havven_tokenstate.functions.setBalanceOf(
                havven_contract.address,
                100000000 * UNIT).transact({'from': MASTER}),
            havven_tokenstate.functions.setAssociatedContract(
                havven_contract.address).transact({'from': MASTER}),
            nomin_tokenstate.functions.setAssociatedContract(
                nomin_contract.address).transact({'from': MASTER}),
            havven_proxy.functions.setTarget(havven_contract.address).transact(
                {'from': MASTER}),
            nomin_proxy.functions.setTarget(nomin_contract.address).transact(
                {'from': MASTER}),
            havven_contract.functions.setNomin(
                nomin_contract.address).transact({'from': MASTER}),
            nomin_contract.functions.setCourt(court_contract.address).transact(
                {'from': MASTER})
        ])

        print("\nDeployment complete.\n")
        return havven_proxy, proxied_havven, nomin_proxy, proxied_nomin, havven_contract, nomin_contract, court_contract
예제 #7
0
def send_value(sender, recipient, value):
    return mine_txs([
        W3.eth.sendTransaction({
            'from': sender,
            'to': recipient,
            'value': value
        })
    ])
예제 #8
0
    def deployContracts():
        sources = [
            "tests/contracts/PublicFeeToken.sol", "contracts/FeeToken.sol",
            "contracts/TokenState.sol"
        ]
        compiled = compile_contracts(sources, remappings=['""=contracts'])
        feetoken_abi = compiled['PublicFeeToken']['abi']

        proxy, _ = attempt_deploy(compiled, "Proxy", MASTER, [MASTER])
        proxied_feetoken = W3.eth.contract(address=proxy.address,
                                           abi=feetoken_abi)

        feetoken_event_dict = generate_topic_event_map(feetoken_abi)

        feestate, txr = attempt_deploy(compiled, "TokenState", MASTER,
                                       [MASTER, MASTER])

        feetoken_contract_1, construction_txr_1 = attempt_deploy(
            compiled, "PublicFeeToken", MASTER, [
                proxy.address, feestate.address, "Test Fee Token", "FEE",
                1000 * UNIT, UNIT // 20, MASTER, MASTER
            ])

        feetoken_contract_2, construction_txr_2 = attempt_deploy(
            compiled, "PublicFeeToken", MASTER, [
                proxy.address, feestate.address, "Test Fee Token 2", "FEE",
                1000 * UNIT, UNIT // 20, MASTER, MASTER
            ])

        mine_txs([
            proxy.functions.setTarget(feetoken_contract_1.address).transact(
                {'from': MASTER}),
            feestate.functions.setBalanceOf(DUMMY, 1000 * UNIT).transact(
                {'from': MASTER}),
            feestate.functions.setAssociatedContract(
                feetoken_contract_1.address).transact({'from': MASTER}),
            feetoken_contract_1.functions.setTokenState(
                feestate.address).transact({'from': MASTER})
        ])

        return compiled, proxy, proxied_feetoken, feetoken_contract_1, feetoken_contract_2, feetoken_event_dict, feestate
예제 #9
0
    def test_swap(self):
        self.assertEqual(self.feetoken.name(), "Test Fee Token")
        self.assertEqual(self.feetoken.symbol(), "FEE")
        self.assertEqual(self.feetoken.totalSupply(), 0)
        self.assertEqual(self.feetoken.transferFeeRate(), UNIT // 20)
        self.assertEqual(self.feetoken.feeAuthority(), self.fee_authority)
        self.assertEqual(self.feetoken.tokenState(),
                         self.feestate.contract.address)
        self.assertEqual(self.feestate.associatedContract(),
                         self.feetoken_contract_1.address)

        self.proxy.setTarget(MASTER, self.feetoken_contract_2.address)
        self.feestate.setAssociatedContract(MASTER,
                                            self.feetoken_contract_2.address)
        mine_txs([
            self.feetoken_contract_2.functions.setTokenState(
                self.feestate.contract.address).transact({'from': MASTER})
        ])

        self.assertEqual(self.feetoken.name(), "Test Fee Token 2")
        self.assertEqual(self.feetoken.tokenState(),
                         self.feestate.contract.address)
        self.assertEqual(self.feestate.associatedContract(),
                         self.feetoken_contract_2.address)
예제 #10
0
    def deployContracts(cls):
        print("Deployment initiated.\n")

        sources = [
            "tests/contracts/PublicHavven.sol", "contracts/Nomin.sol",
            "contracts/HavvenEscrow.sol"
        ]

        compiled, cls.event_maps = cls.compileAndMapEvents(sources)

        # Deploy contracts
        havven_proxy, _ = attempt_deploy(compiled, 'Proxy', MASTER, [MASTER])
        nomin_proxy, _ = attempt_deploy(compiled, 'Proxy', MASTER, [MASTER])
        proxied_havven = W3.eth.contract(address=havven_proxy.address,
                                         abi=compiled['PublicHavven']['abi'])
        proxied_nomin = W3.eth.contract(address=nomin_proxy.address,
                                        abi=compiled['Nomin']['abi'])

        havven_tokenstate, _ = attempt_deploy(compiled, 'TokenState', MASTER,
                                              [MASTER, MASTER])
        nomin_tokenstate, _ = attempt_deploy(compiled, 'TokenState', MASTER,
                                             [MASTER, MASTER])
        havven_contract, hvn_txr = attempt_deploy(
            compiled, 'PublicHavven', MASTER, [
                havven_proxy.address, havven_tokenstate.address, MASTER,
                MASTER, cls.initial_price, [], ZERO_ADDRESS
            ])
        hvn_block = W3.eth.blockNumber
        nomin_contract, nom_txr = attempt_deploy(compiled, 'Nomin', MASTER, [
            nomin_proxy.address, nomin_tokenstate.address,
            havven_contract.address, 0, MASTER
        ])
        escrow_contract, escrow_txr = attempt_deploy(
            compiled, 'HavvenEscrow', MASTER,
            [MASTER, havven_contract.address])

        # Hook up each of those contracts to each other
        mine_txs([
            havven_tokenstate.functions.setBalanceOf(
                havven_contract.address,
                100000000 * UNIT).transact({'from': MASTER}),
            havven_tokenstate.functions.setAssociatedContract(
                havven_contract.address).transact({'from': MASTER}),
            nomin_tokenstate.functions.setAssociatedContract(
                nomin_contract.address).transact({'from': MASTER}),
            havven_proxy.functions.setTarget(havven_contract.address).transact(
                {'from': MASTER}),
            nomin_proxy.functions.setTarget(nomin_contract.address).transact(
                {'from': MASTER}),
            havven_contract.functions.setNomin(
                nomin_contract.address).transact({'from': MASTER}),
            nomin_contract.functions.setHavven(
                havven_contract.address).transact({'from': MASTER}),
            havven_contract.functions.setEscrow(
                escrow_contract.address).transact({'from': MASTER})
        ])

        havven_event_dict = generate_topic_event_map(
            compiled['PublicHavven']['abi'])

        print("\nDeployment complete.\n")
        return havven_proxy, proxied_havven, nomin_proxy, proxied_nomin, havven_contract, nomin_contract, escrow_contract, hvn_block, havven_event_dict
예제 #11
0
    def test_constructor_migration(self):
        # Ensure issuers list updates issued balances properly... update deploycontracts above.
        sources = [
            "tests/contracts/PublicHavven.sol", "contracts/Nomin.sol",
            "contracts/HavvenEscrow.sol"
        ]

        print()
        compiled, event_maps = self.compileAndMapEvents(sources)

        # Initial issued nomin balances
        #issuer_addresses = [f"0x{'0'*39}{i+1}" for i in range(10)]
        issuers_all = fresh_accounts(54)
        issuers = issuers_all[:2]
        issuer_balances = [77 * UNIT * i for i in range(10)]
        total_nomins = sum(issuer_balances)

        # Deploy contracts
        havven_proxy, _ = attempt_deploy(compiled, 'Proxy', MASTER, [MASTER])
        nomin_proxy, _ = attempt_deploy(compiled, 'Proxy', MASTER, [MASTER])
        proxied_havven = W3.eth.contract(address=havven_proxy.address,
                                         abi=compiled['PublicHavven']['abi'])
        proxied_nomin = W3.eth.contract(address=nomin_proxy.address,
                                        abi=compiled['Nomin']['abi'])

        havven_tokenstate, _ = attempt_deploy(compiled, 'TokenState', MASTER,
                                              [MASTER, MASTER])
        nomin_tokenstate, _ = attempt_deploy(compiled, 'TokenState', MASTER,
                                             [MASTER, MASTER])
        havven_contract, hvn_txr = attempt_deploy(
            compiled, 'PublicHavven', MASTER, [
                havven_proxy.address, havven_tokenstate.address, MASTER,
                MASTER, UNIT, [], ZERO_ADDRESS
            ])
        hvn_block = W3.eth.blockNumber
        nomin_contract, nom_txr = attempt_deploy(compiled, 'Nomin', MASTER, [
            nomin_proxy.address, nomin_tokenstate.address,
            havven_contract.address, 0, MASTER
        ])
        escrow_contract, escrow_txr = attempt_deploy(
            compiled, 'HavvenEscrow', MASTER,
            [MASTER, havven_contract.address])

        mine_txs([
            havven_tokenstate.functions.setBalanceOf(
                havven_contract.address,
                100000000 * UNIT).transact({'from': MASTER}),
            havven_tokenstate.functions.setAssociatedContract(
                havven_contract.address).transact({'from': MASTER}),
            nomin_tokenstate.functions.setAssociatedContract(
                nomin_contract.address).transact({'from': MASTER}),
            havven_proxy.functions.setTarget(havven_contract.address).transact(
                {'from': MASTER}),
            nomin_proxy.functions.setTarget(nomin_contract.address).transact(
                {'from': MASTER}),
            havven_contract.functions.setNomin(
                nomin_contract.address).transact({'from': MASTER}),
            nomin_contract.functions.setHavven(
                havven_contract.address).transact({'from': MASTER}),
            havven_contract.functions.setEscrow(
                escrow_contract.address).transact({'from': MASTER})
        ])

        havven_event_dict = generate_topic_event_map(
            compiled['PublicHavven']['abi'])

        havven = PublicHavvenInterface(proxied_havven, "Havven")
        nomin = PublicNominInterface(proxied_nomin, "Nomin")

        for i in range(len(issuers)):
            issuer = issuers[i]
            havven.endow(MASTER, issuer, 1000 * UNIT)
            havven.setIssuer(MASTER, issuer, True)
            mine_txs([
                havven_contract.functions.updatePrice(
                    UNIT,
                    block_time() + 1).transact({'from': MASTER})
            ])
            havven.issueNomins(issuer, i * 10 * UNIT)
            fast_forward(havven.feePeriodDuration() // 20)

        for i in range(len(issuers)):
            issuer = issuers[i]
            havven.endow(MASTER, issuer, 1000 * UNIT)
            havven.setIssuer(MASTER, issuer, True)
            mine_txs([
                havven_contract.functions.updatePrice(
                    UNIT,
                    block_time() + 1).transact({'from': MASTER})
            ])
            havven.issueNomins(issuer, (len(issuers) - 1 - i) * 5 * UNIT)
            fast_forward(havven.feePeriodDuration() // 15)

        new_havven_contract, txr = attempt_deploy(
            compiled, 'PublicHavven', MASTER, [
                havven_proxy.address, havven_tokenstate.address, MASTER,
                MASTER, UNIT, issuers_all, havven_contract.address
            ])
        new_havven = PublicHavvenInterface(new_havven_contract, "Havven")

        self.assertEqual(havven.totalIssuanceData(),
                         new_havven.totalIssuanceData())
        self.assertEqual(havven.feePeriodStartTime(),
                         new_havven.feePeriodStartTime())
        self.assertEqual(havven.lastFeePeriodStartTime(),
                         new_havven.lastFeePeriodStartTime())

        for issuer in issuers:
            self.assertEqual(havven.isIssuer(issuer),
                             new_havven.isIssuer(issuer))
            self.assertEqual(havven.issuanceData(issuer),
                             new_havven.issuanceData(issuer))
            self.assertEqual(havven.nominsIssued(issuer),
                             new_havven.nominsIssued(issuer))
    def test_swap_havven(self):
        alice, bob = fresh_accounts(2)
        self.havven.endow(MASTER, self.escrow.contract.address, 200 * UNIT)
        time = block_time()

        # Set up escrow schedules for alice and bob to test with.
        self.escrow.addRegularVestingSchedule(MASTER, alice,
                                              time + to_seconds(weeks=52),
                                              100 * UNIT, 4)
        self.escrow.addRegularVestingSchedule(MASTER, bob,
                                              time + to_seconds(weeks=52),
                                              100 * UNIT, 4)

        # Vest alice's first tranche as usual.
        fast_forward(to_seconds(weeks=13) + 10)
        self.escrow.vest(alice)
        self.assertEqual(self.havven.balanceOf(alice), 25 * UNIT)
        self.assertEqual(self.havven.balanceOf(self.escrow_contract.address),
                         175 * UNIT)

        print()
        # Deploy the new havven contract, with proxy and all.
        havven_proxy, _ = attempt_deploy(self.compiled, 'Proxy', MASTER,
                                         [MASTER])
        havven_contract, _ = attempt_deploy(
            self.compiled, 'PublicHavven', MASTER, [
                havven_proxy.address, self.havven_token_state.address, MASTER,
                MASTER, UNIT // 2, [], ZERO_ADDRESS
            ])
        proxied_havven = W3.eth.contract(
            address=havven_proxy.address,
            abi=self.compiled['PublicHavven']['abi'])
        new_havven = PublicHavvenInterface(proxied_havven, "Havven")

        # Connect the contracts together.
        mine_txs([
            self.havven_token_state.functions.setAssociatedContract(
                havven_contract.address).transact({'from': MASTER}),
            havven_proxy.functions.setTarget(havven_contract.address).transact(
                {'from': MASTER})
        ])
        new_havven.setEscrow(MASTER, self.escrow_contract.address)
        # This should work if the escrow is pointing at the havven proxy.
        self.escrow.setHavven(MASTER, proxied_havven.address)

        # Ensure that the new contract is properly up and running, but with the old state.
        self.assertEqual(new_havven.balanceOf(alice), 25 * UNIT)
        self.assertEqual(new_havven.balanceOf(bob), 0)

        tx = new_havven.transfer(alice, bob, 5 * UNIT)

        self.assertEqual(new_havven.balanceOf(alice), 20 * UNIT)
        self.assertEqual(new_havven.balanceOf(bob), 5 * UNIT)
        self.assertEqual(new_havven.balanceOf(self.escrow_contract.address),
                         175 * UNIT)

        # And the event emitted properly, from the proxy.
        self.assertEventEquals(self.havven_event_dict,
                               tx.logs[0],
                               'Transfer',
                               fields={
                                   'from': alice,
                                   'to': bob,
                                   'value': 5 * UNIT
                               },
                               location=havven_proxy.address)

        # Vest alice's second tranche, but this time on the new contract.
        fast_forward(to_seconds(weeks=13) + 10)
        tx = self.escrow.vest(alice)
        self.assertEventEquals(self.havven_event_dict,
                               tx.logs[0],
                               'Transfer',
                               fields={
                                   'from': self.escrow_contract.address,
                                   'to': alice,
                                   'value': 25 * UNIT
                               },
                               location=havven_proxy.address)
        self.assertEventEquals(self.escrow_event_dict,
                               tx.logs[1],
                               'Vested',
                               fields={
                                   'beneficiary': alice,
                                   'time': block_time(tx['blockNumber']),
                                   'value': 25 * UNIT
                               },
                               location=self.escrow_contract.address)
        self.assertEqual(new_havven.balanceOf(alice), 45 * UNIT)
        self.assertEqual(new_havven.balanceOf(bob), 5 * UNIT)
        self.assertEqual(new_havven.balanceOf(self.escrow_contract.address),
                         150 * UNIT)

        # The stuff should also work if the escrow is pointing at the underlying havven contract
        fast_forward(to_seconds(weeks=13) + 10)
        self.escrow.setHavven(MASTER, havven_contract.address)
        tx = self.escrow.vest(alice)
        self.assertEventEquals(self.havven_event_dict,
                               tx.logs[0],
                               'Transfer',
                               fields={
                                   'from': self.escrow_contract.address,
                                   'to': alice,
                                   'value': 25 * UNIT
                               },
                               location=havven_proxy.address)
        self.assertEventEquals(self.escrow_event_dict,
                               tx.logs[1],
                               'Vested',
                               fields={
                                   'beneficiary': alice,
                                   'time': block_time(tx['blockNumber']),
                                   'value': 25 * UNIT
                               },
                               location=self.escrow_contract.address)
        self.assertEqual(new_havven.balanceOf(alice), 70 * UNIT)
        self.assertEqual(new_havven.balanceOf(bob), 5 * UNIT)
        self.assertEqual(new_havven.balanceOf(self.escrow_contract.address),
                         125 * UNIT)

        self.escrow.setHavven(MASTER, proxied_havven.address)
        fast_forward(to_seconds(weeks=13) + 10)
        tx = self.escrow.vest(alice)
        self.assertEqual(new_havven.balanceOf(alice), 95 * UNIT)
        self.assertEqual(new_havven.balanceOf(bob), 5 * UNIT)
        self.assertEqual(new_havven.balanceOf(self.escrow_contract.address),
                         100 * UNIT)

        # Now verify that vesting still works for bob on the new contract, even though he missed some.
        tx = self.escrow.vest(bob)
        self.assertEventEquals(self.havven_event_dict,
                               tx.logs[0],
                               'Transfer',
                               fields={
                                   'from': self.escrow_contract.address,
                                   'to': bob,
                                   'value': 100 * UNIT
                               },
                               location=havven_proxy.address)
        self.assertEventEquals(self.escrow_event_dict,
                               tx.logs[1],
                               'Vested',
                               fields={
                                   'beneficiary': bob,
                                   'time': block_time(tx['blockNumber']),
                                   'value': 100 * UNIT
                               },
                               location=self.escrow_contract.address)
        self.assertEqual(new_havven.balanceOf(alice), 95 * UNIT)
        self.assertEqual(new_havven.balanceOf(bob), 105 * UNIT)
        self.assertEqual(new_havven.balanceOf(self.escrow_contract.address), 0)