def setUpClass(cls): cls.havven_proxy, cls.proxied_havven, cls.nomin_proxy, cls.proxied_nomin, cls.nomin_contract, cls.havven_contract, cls.nomin_state = cls.deployContracts( ) cls.nomin_event_dict = cls.event_maps['Nomin'] cls.nomin = PublicNominInterface(cls.proxied_nomin, "Nomin") cls.havven = HavvenInterface(cls.proxied_havven, "Havven") cls.unproxied_nomin = PublicNominInterface(cls.nomin_contract, "UnproxiedNomin") cls.nomin.setFeeAuthority(MASTER, cls.havven_contract.address) cls.sd_duration = 4 * 7 * 24 * 60 * 60
def setUpClass(cls): cls.havven_proxy, cls.proxied_havven, cls.nomin_proxy, cls.proxied_nomin, cls.havven_contract, cls.nomin_contract = cls.deployContracts( ) cls.event_map = cls.event_maps['Havven'] cls.havven = PublicHavvenInterface(cls.proxied_havven, "Havven") cls.nomin = PublicNominInterface(cls.proxied_nomin, "Nomin") fast_forward(weeks=102)
def setUpClass(cls): cls.havven_proxy, cls.proxied_havven, cls.havven_token_state, cls.nomin_proxy, cls.proxied_nomin, cls.havven_contract, \ cls.nomin_contract, cls.escrow_contract, cls.construction_block, \ cls.escrow_event_dict, cls.havven_event_dict = cls.deployContracts() cls.event_map = cls.event_maps['HavvenEscrow'] cls.havven = PublicHavvenInterface(cls.proxied_havven, "Havven") cls.nomin = PublicNominInterface(cls.proxied_nomin, "Nomin") cls.escrow = PublicHavvenEscrowInterface(cls.escrow_contract, "HavvenEscrow")
def setUpClass(cls): cls.initial_price = UNIT // 2 cls.havven_proxy, cls.proxied_havven, cls.nomin_proxy, cls.proxied_nomin, cls.havven_contract, cls.nomin_contract, cls.escrow_contract = cls.deployContracts( ) cls.havven = PublicHavvenInterface(cls.proxied_havven, "Havven") cls.nomin = PublicNominInterface(cls.proxied_nomin, "Nomin") cls.escrow = PublicHavvenEscrowInterface(cls.escrow_contract, "HavvenEscrow") cls.havven.setIssuanceRatio(MASTER, UNIT // 20) fast_forward(weeks=102)
def setUpClass(cls): cls.havven_proxy, cls.proxied_havven, cls.nomin_proxy, cls.proxied_nomin, cls.havven_contract, cls.nomin_contract, cls.fake_court_contract, cls.escrow_contract = cls.deployContracts( ) cls.havven = PublicHavvenInterface(cls.proxied_havven, "Havven") cls.nomin = PublicNominInterface(cls.proxied_nomin, "Nomin") cls.escrow = PublicHavvenEscrowInterface(cls.escrow_contract, "HavvenEscrow") fast_forward(weeks=102) cls.fake_court = FakeCourtInterface(cls.fake_court_contract, "FakeCourt") cls.fake_court.setNomin(MASTER, cls.nomin_contract.address)
def setUpClass(cls): addresses = fresh_accounts(6) cls.participantAddresses = addresses[2:] cls.contractOwner = MASTER cls.oracleAddress = addresses[0] cls.fundsWallet = addresses[1] cls.usdToEthPrice = 500 * (10 ** 18) cls.usdToHavPrice = int(0.65 * (10 ** 18)) cls.priceStalePeriod = 3 * 60 * 60 cls.havven_proxy, cls.proxied_havven, cls.nomin_proxy, cls.proxied_nomin, cls.havven_contract, cls.nomin_contract, cls.nomin_abi, cls.issuanceControllerContract = cls.deployContracts() cls.issuanceController = IssuanceControllerInterface(cls.issuanceControllerContract, "IssuanceController") cls.havven = PublicHavvenInterface(cls.havven_contract, "Havven") cls.nomin = PublicNominInterface(cls.nomin_contract, "Nomin") cls.issuanceControllerEventDict = cls.event_maps['IssuanceController']
def setUpClass(cls): addresses = fresh_accounts(6) cls.participantAddresses = addresses[2:] cls.contractOwner = MASTER cls.oracleAddress = addresses[0] cls.fundsWallet = addresses[1] cls.usdToEthPrice = 500 * UNIT cls.usdToHavPrice = int(0.65 * UNIT) cls.priceStalePeriod = 3 * 60 * 60 cls.havven_proxy, cls.proxied_havven, cls.nomin_proxy, cls.proxied_nomin, cls.havven_contract, cls.nomin_contract, cls.nomin_abi, cls.issuanceControllerContract = cls.deployContracts( ) cls.issuanceController = IssuanceControllerInterface( cls.issuanceControllerContract, "IssuanceController") cls.havven = PublicHavvenInterface(cls.havven_contract, "Havven") cls.nomin = PublicNominInterface(cls.nomin_contract, "Nomin") cls.issuanceControllerEventDict = cls.event_maps['IssuanceController'] fast_forward( 1 ) # Give the contract constructor a second between its execution and execution of the other functions.
def setUpClass(cls): # to avoid overflowing in the negative direction (now - feePeriodDuration * 2) fast_forward(weeks=102) cls.havven_proxy, cls.proxied_havven, cls.nomin_proxy, cls.proxied_nomin, \ cls.havven_contract, cls.nomin_contract, cls.court_contract, \ cls.escrow_contract, cls.construction_block, cls.havven_event_dict = cls.deployContracts() cls.event_map = cls.event_maps['Havven'] cls.havven = PublicHavvenInterface(cls.proxied_havven, "Havven") cls.nomin = PublicNominInterface(cls.proxied_nomin, "Nomin") cls.unproxied_havven = PublicHavvenInterface(cls.havven_contract, "UnproxiedHavven") cls.initial_time = cls.havven.lastFeePeriodStartTime() cls.time_fast_forwarded = 0 cls.base_havven_price = UNIT cls.sd_duration = 4 * 7 * 24 * 60 * 60
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))