def test_buy_too_many_tokens(open_crowdsale: Contract, token: Contract, customer: str, beneficiary: str, web3: Web3): """One cannot out buy the maximum token allocation.""" buy_everything_amount = open_crowdsale.call().getPrice( ) * open_crowdsale.call().maxGoal() web3.eth.sendTransaction({ "from": customer, "to": open_crowdsale.address, "value": buy_everything_amount, "gas": 200000, }) events = token.pastEvents("Transfer").get() assert len(events) == 1 e = events[0] assert e["args"]["to"] == customer assert e["args"]["from"] == beneficiary assert e["args"]["value"] == open_crowdsale.call().maxGoal() # Cannot buy a single token more with pytest.raises(TransactionFailed): web3.eth.sendTransaction({ "from": customer, "to": open_crowdsale.address, "value": open_crowdsale.call().getPrice(), # Minimum value to buy one token "gas": 200000, })
def test_buy_tokens(open_crowdsale: Contract, token: Contract, customer: str, beneficiary: str, web3: Web3): """Sending ETH successfully buys tokens.""" web3.eth.sendTransaction({ "from": customer, "to": open_crowdsale.address, "value": to_wei(20, "ether"), "gas": 250000, }) # We get ERC-20 event events = token.pastEvents("Transfer").get() assert len(events) == 1 e = events[0] assert e["args"]["to"] == customer assert e["args"]["from"] == beneficiary assert e["args"]["value"] == 24000 # We get crowdsale event events = open_crowdsale.pastEvents("FundTransfer").get() assert len(events) == 1 e = events[0] assert e["args"]["backer"] == customer assert e["args"]["amount"] == to_wei(20, "ether") assert e["args"]["amountRaised"] == to_wei(20, "ether")
def test_early_whitelist_only_owner(chain: TestRPCChain, ico: Contract, customer: str, preico_starts_at, team_multisig, uncapped_token): """Only owner can early whitelist.""" time_travel(chain, preico_starts_at - 1) assert ico.call().getState() == CrowdsaleState.PreFunding with pytest.raises(TransactionFailed): ico.transact({"from": customer}).setEarlyParicipantWhitelist(customer, True)
def test_change_multisig_only_owner(chain: TestRPCChain, ico: Contract, customer: str, preico_starts_at, preico_ends_at, team_multisig): """Only own can change the multisig address.""" with pytest.raises(TransactionFailed): ico.transact({"from": customer}).setMultisig(customer)
def test_token_initialized(token: Contract, team_multisig: str, token_symbol: str, token_name: str, initial_supply: int): """Token is initialized with the parameters we want.""" assert token.call().symbol() == token_symbol assert token.call().name() == token_name assert token.call().totalSupply() == initial_supply
def sweep_account(private_key: str, faucet_address: str, token_contract: Contract, web3: Web3, wait_for_transaction): address = privkey_to_addr(private_key) log.info('Sweeping account {}'.format(address)) token_balance = token_contract.call().balanceOf(address) if token_balance > 0: tx = create_signed_contract_transaction( private_key, token_contract, 'transfer', [faucet_address, token_balance]) try: tx_hash = web3.eth.sendRawTransaction(tx) except ValueError as e: if e.args[0]['message'].startswith('Insufficient funds.'): pass else: raise else: wait_for_transaction(tx_hash) assert token_contract.call().balanceOf(address) == 0 balance = web3.eth.getBalance(address) if balance < POT_GAS_LIMIT * GAS_PRICE: return tx = create_signed_transaction(private_key, web3, to=faucet_address, value=balance - POT_GAS_LIMIT * GAS_PRICE, gas_limit=POT_GAS_LIMIT) tx_hash = web3.eth.sendRawTransaction(tx) wait_for_transaction(tx_hash) assert web3.eth.getBalance(address) == 0, ( 'Sweeping of account {} (private key {}) failed.'.format( address, private_key))
def test_cannot_mint(chain: TestRPCChain, web3: Web3, ico: Contract, uncapped_token: Contract, customer: str, preico_token_price, preico_starts_at, team_multisig): """Only crowdsale contract can mint new tokens.""" time_travel(chain, preico_starts_at + 1) with pytest.raises(TransactionFailed): uncapped_token.transact({"from": customer}).mint(customer, 1000)
def test_buy_early(chain: TestRPCChain, ico: Contract, customer: str, preico_starts_at, uncapped_token): """Cannot buy too early.""" time_travel(chain, preico_starts_at - 1) assert ico.call().getState() == CrowdsaleState.PreFunding with pytest.raises(TransactionFailed): ico.transact({"from": customer, "value": to_wei(1, "ether")}).buy()
def test_send_invoice(web3: Web3, registry_contract: Contract, sample_company: dict): """Test send invoice function.""" invoice_id = "00001" payload = "<xml></xml>" registry_contract.transact().sendInvoice("FI24303727", "FI23486648", invoice_id, payload)
def test_change_end_at_only_owner(chain: TestRPCChain, ico: Contract, customer: str, preico_starts_at, preico_ends_at, team_multisig): """Only own can change end date.""" new_early = preico_starts_at + 1*3600 with pytest.raises(TransactionFailed): ico.transact({"from": customer}).setEndsAt(new_early)
def test_malicious_transfer_agent_set(token: Contract, malicious_address): """Externals cannot whitelist transfer agents.""" with pytest.raises(TransactionFailed): token.transact({ "from": malicious_address }).setTransferAgent(malicious_address, True)
def failed_ico_ready_to_refund(chain: TestRPCChain, failed_ico: Contract, team_multisig) -> Contract: """An ICO that did not reach a goal, but has participants. The team has moved funds back from the multisig wallet on the crowdsale contract. Note that due to transaction fees you need to pay a minimal transaction cost out of your own pocket. """ failed_ico.transact({"from" : team_multisig, "value": failed_ico.call().weiRaised()}).loadRefund() return failed_ico
def test_token_rename(token: Contract, team_multisig, token_new_name, token_new_symbol): """We will update token's information here""" token.transact({"from": team_multisig}).setTokenInformation(token_new_name, token_new_symbol) assert token.call().name() == token_new_name assert token.call().symbol() == token_new_symbol
def test_buy_late_goal_reached(chain: TestRPCChain, uncapped_flatprice_goal_reached: Contract, customer: str, preico_ends_at): """Cannot buy after closing time when the goal was not reached.""" time_travel(chain, preico_ends_at + 1) assert uncapped_flatprice_goal_reached.call().getState() == CrowdsaleState.Success with pytest.raises(TransactionFailed): uncapped_flatprice_goal_reached.transact({"from": customer, "value": to_wei(1, "ether")}).buy()
def test_missing_address_record(web3: Web3, registry_contract: Contract, broken_company: dict): """Some bad input data.""" import_invoicing_address(registry_contract, broken_company) assert registry_contract.call().getInvoicingAddressCount("FI23486648") == 1 assert registry_contract.call().getInvoicingAddressByIndex( "FI23486648", 0) == "OVT:372348664835"
def test_buy_early_whitelisted(chain: TestRPCChain, ico: Contract, customer: str, preico_starts_at, team_multisig, uncapped_token): """Whitelisted participants can buy earliy.""" time_travel(chain, preico_starts_at - 1) assert ico.call().getState() == CrowdsaleState.PreFunding ico.transact({"from": team_multisig}).setEarlyParicipantWhitelist(customer, True) ico.transact({"from": customer, "value": to_wei(1, "ether")}).buy() assert uncapped_token.call().balanceOf(customer) > 0
def test_cannot_upgrade_too_many(released_token: Contract, upgrade_agent: Contract, team_multisig, customer): """We cannot upgrade more tokens than we have.""" released_token.transact({"from": team_multisig}).setUpgradeAgent(upgrade_agent.address) assert released_token.call().balanceOf(customer) == 10000 with pytest.raises(TransactionFailed): released_token.transact({"from": customer}).upgrade(20000)
def test_cannot_refund_twice(failed_ico_ready_to_refund: Contract, customer: str): """Customer can reclaim refund only once.""" assert failed_ico_ready_to_refund.call().getState() == CrowdsaleState.Refunding failed_ico_ready_to_refund.transact({"from": customer}).refund() with pytest.raises(TransactionFailed): failed_ico_ready_to_refund.transact({"from": customer}).refund()
def test_buy_dust(chain: TestRPCChain, web3: Web3, ico: Contract, uncapped_token: Contract, customer: str, preico_token_price, preico_starts_at, team_multisig): """Cannot buy with too small transaction.""" wei_value = 1 time_travel(chain, preico_starts_at + 1) with pytest.raises(TransactionFailed): ico.transact({"from": customer, "value": wei_value}).buy()
def test_change_upgrade_master(released_token: Contract, upgrade_agent: Contract, team_multisig, customer): """Owner can change the upgrade master.""" released_token.transact({"from": team_multisig}).setUpgradeMaster(customer) released_token.transact({ "from": customer }).setUpgradeAgent(upgrade_agent.address)
def test_malicious_set_upgrade_agent(released_token: Contract, upgrade_agent: Contract, malicious_address): """Only owner can set the upgrade agent can be set on a released token.""" with pytest.raises(TransactionFailed): released_token.transact({ "from": malicious_address }).setUpgradeAgent(upgrade_agent.address)
def test_unlock_early(chain, token: Contract, team_multisig: str, vault: Contract, unlock_time: int): """Early unlock fails.""" assert token.call().balanceOf(team_multisig) == 0 assert token.call().balanceOf(vault.address) == 1000000 time_travel(chain, unlock_time - 1) with pytest.raises(TransactionFailed): vault.transact({"from": team_multisig}).unlock()
def decimalize_token_amount(contract: Contract, amount: int) -> Decimal: """Convert raw fixed point token amount to decimal format. :param contract: ERC-20 token contract with decimals field :param amount: Raw token amount :return: The resultdroping :py:class:`decimal.Decimal` carries a correct decimal places. """ val = Decimal(amount) / Decimal(10 ** contract.call().decimals()) quantizer = Decimal(1) / Decimal(10 ** contract.call().decimals()) return val.quantize(quantizer)
def test_buy_fail_goal(chain: TestRPCChain, ico: Contract, customer: str, preico_starts_at, preico_ends_at, preico_funding_goal): """Goal is not reached if there is not enough investment.""" time_travel(chain, preico_starts_at + 1) wei_value = preico_funding_goal // 2 ico.transact({"from": customer, "value": wei_value}).buy() time_travel(chain, preico_ends_at + 1) assert ico.call().getState() == CrowdsaleState.Failure
def test_token_rename(token: Contract, team_multisig, token_new_name, token_new_symbol): """We will update token's information here""" token.transact({ "from": team_multisig }).setTokenInformation(token_new_name, token_new_symbol) assert token.call().name() == token_new_name assert token.call().symbol() == token_new_symbol
def test_finalize_success(chain: TesterChain, uncapped_flatprice_final: Contract, uncapped_token: Contract, team_multisig: str, customer: str, preico_starts_at, preico_ends_at, preico_funding_goal, default_finalize_agent): """Finalize releases the token.""" time_travel(chain, preico_starts_at + 1) wei_value = preico_funding_goal uncapped_flatprice_final.transact({ "from": customer, "value": wei_value }).buy() time_travel(chain, preico_ends_at + 1) assert uncapped_flatprice_final.call().getState() == CrowdsaleState.Success assert uncapped_flatprice_final.call().finalizeAgent( ) == chain.web3.toChecksumAddress(default_finalize_agent.address) # Release the tokens uncapped_flatprice_final.transact({"from": team_multisig}).finalize() assert uncapped_flatprice_final.call().getState( ) == CrowdsaleState.Finalized # Here we go assert uncapped_token.call().released() assert uncapped_token.call().mintingFinished()
def test_unlock(chain, token: Contract, team_multisig: str, vault: Contract, unlock_time: int): """Unlock tokens.""" assert token.call().balanceOf(team_multisig) == 0 assert token.call().balanceOf(vault.address) == 1000000 time_travel(chain, unlock_time + 1) vault.transact({"from": team_multisig}).unlock() assert token.call().balanceOf(team_multisig) == 1000000 assert token.call().balanceOf(vault.address) == 0
def test_bad_released(token: Contract, team_multisig: str, malicious_address: str, empty_address: str): """Only release agent can make token transferable.""" assert not token.call().released() with pytest.raises(TransactionFailed): token.transact({"from": malicious_address}).releaseTokenTransfer() # Even owner cannot release, need to go through release agent process with pytest.raises(TransactionFailed): token.transact({"from": team_multisig}).releaseTokenTransfer()
def test_import_company_with_multiple_addresses( web3: Web3, registry_contract: Contract, multiple_tieke_rows: List[dict]): """We can import a company with multiple addresses.""" for row in multiple_tieke_rows: import_invoicing_address(registry_contract, row) assert registry_contract.call().getInvoicingAddressCount("FI26597538") == 2 assert registry_contract.call().getInvoicingAddressByIndex( "FI26597538", 0) == "IBAN:FI6213763000140986" assert registry_contract.call().getInvoicingAddressByIndex( "FI26597538", 1) == "OVT:3726597538"
def test_cannot_upgrade_too_many(released_token: Contract, upgrade_agent: Contract, team_multisig, customer): """We cannot upgrade more tokens than we have.""" released_token.transact({ "from": team_multisig }).setUpgradeAgent(upgrade_agent.address) assert released_token.call().balanceOf(customer) == 10000 with pytest.raises(TransactionFailed): released_token.transact({"from": customer}).upgrade(20000)
def get_keeper_params(oracles_contract: Contract, multicall_contract: Contract) -> Parameters: """Returns keeper params for checking whether to submit the votes.""" calls = [ { "target": oracles_contract.address, "callData": oracles_contract.encodeABI(fn_name="paused"), }, { "target": oracles_contract.address, "callData": oracles_contract.encodeABI(fn_name="currentRewardsNonce"), }, { "target": oracles_contract.address, "callData": oracles_contract.encodeABI(fn_name="currentValidatorsNonce"), }, { "target": oracles_contract.address, "callData": oracles_contract.encodeABI(fn_name="getRoleMemberCount", args=[ORACLE_ROLE]), }, ] response = multicall_contract.functions.aggregate(calls).call()[1] paused = bool(Web3.toInt(primitive=response[0])) rewards_nonce = Web3.toInt(primitive=response[1]) validators_nonce = Web3.toInt(primitive=response[2]) total_oracles = Web3.toInt(primitive=response[3]) calls = [] for i in range(total_oracles): calls.append({ "target": oracles_contract.address, "callData": oracles_contract.encodeABI(fn_name="getRoleMember", args=[ORACLE_ROLE, i]), }) response = multicall_contract.functions.aggregate(calls).call()[1] oracles: List[ChecksumAddress] = [] for addr in response: oracles.append(Web3.toChecksumAddress(Web3.toBytes(Web3.toInt(addr)))) return Parameters( paused=paused, rewards_nonce=rewards_nonce, validators_nonce=validators_nonce, oracles=oracles, )
def test_finalize_fail_goal(chain: TestRPCChain, uncapped_flatprice_final: Contract, customer: str, preico_starts_at, preico_ends_at, preico_funding_goal): """Finalize can be done only for successful crowdsales.""" time_travel(chain, preico_starts_at + 1) wei_value = preico_funding_goal // 2 uncapped_flatprice_final.transact({"from": customer, "value": wei_value}).buy() time_travel(chain, preico_ends_at + 1) assert uncapped_flatprice_final.call().getState() == CrowdsaleState.Failure with pytest.raises(TransactionFailed): uncapped_flatprice_final.transact().finalize()
def test_set_upgrade_agent(upgradeable_token: Contract, upgrade_agent: Contract, team_multisig): """Upgrade agent can be set on a released token.""" # Preconditions are met assert upgrade_agent.call().isUpgradeAgent() assert upgradeable_token.call().canUpgrade() assert upgradeable_token.call().upgradeMaster() == team_multisig assert upgrade_agent.call().oldToken() == upgradeable_token.address assert upgrade_agent.call().originalSupply() == upgradeable_token.call().totalSupply() assert upgradeable_token.call().getUpgradeState() == UpgradeState.WaitingForAgent upgradeable_token.transact({"from": team_multisig}).setUpgradeAgent(upgrade_agent.address) assert upgradeable_token.call().getUpgradeState() == UpgradeState.ReadyToUpgrade
def test_finalize_only_by_crowdsale(chain: TestRPCChain, uncapped_flatprice_final: Contract, team_multisig: str, customer: str, preico_starts_at, preico_ends_at, preico_funding_goal, default_finalize_agent): """Finalizer can be only triggered by crowdsale.""" time_travel(chain, preico_starts_at + 1) wei_value = preico_funding_goal uncapped_flatprice_final.transact({"from": customer, "value": wei_value}).buy() time_travel(chain, preico_ends_at + 1) assert uncapped_flatprice_final.call().getState() == CrowdsaleState.Success # Checks for the owner with pytest.raises(TransactionFailed): default_finalize_agent.transact({"from": team_multisig}).finalizeCrowdsale()
def execute( self, to_contract: Contract, func: str, args=None, amount_in_eth: Optional[Decimal] = None, max_gas=100000 ): """Calls a smart contract from the hosted wallet. Creates a transaction that is proxyed through hosted wallet execute method. We need to have ABI as Populus Contract instance. :param wallet_address: Wallet address :param contract: Contract to called as address bound Populus Contract class :param func: Method name to be called :param args: Arguments passed to the method :param value: Additional value carried in the call in ETH :param gas: The max amount of gas the coinbase account is allowed to pay for this transaction. :return: txid of the execution as hex string """ assert isinstance(to_contract, Contract) if amount_in_eth: assert isinstance(amount_in_eth, Decimal) # Don't let floats slip through value = to_wei(amount_in_eth) else: value = 0 # Encode function arguments function_abi = to_contract._find_matching_fn_abi(func, args) # 4 byte function hash function_selector = function_abi_to_4byte_selector(function_abi) # data payload passed to the function arg_data = to_contract.encodeABI(func, args=args) call_data = function_selector + arg_data[2:] # test_event_execute() call data should look like # function selector + random int as 256-bit # 0x5093dc7d000000000000000000000000000000000000000000000000000000002a3f58fe # web3 takes bytes argument as actual bytes, not hex call_data = binascii.unhexlify(call_data[2:]) tx_info = { # The Ethereum account that pays the gas for this operation "from": self.contract.web3.eth.coinbase, "gas": max_gas, } txid = self.contract.transact(tx_info).execute(to_contract.address, value, max_gas, call_data) return txid
def test_halt(chain: TestRPCChain, web3: Web3, ico: Contract, uncapped_token: Contract, customer: str, preico_token_price, preico_starts_at, team_multisig): """Cannot buy tokens during the emergency pause mode.""" time_travel(chain, preico_starts_at + 1) wei_value = to_wei(1, "ether") ico.transact({"from": team_multisig}).halt() assert ico.call().halted() with pytest.raises(TransactionFailed): ico.transact({"from": customer, "value": wei_value}).buy() ico.transact({"from": team_multisig}).unhalt() assert not ico.call().halted() ico.transact({"from": customer, "value": wei_value}).buy()
def test_erc20_interface(token: Contract, token_owner: str, empty_address: str): """Token satisfies ERC-20 interface.""" # https://github.com/OpenZeppelin/zeppelin-solidity/blob/master/contracts/token/ERC20.sol assert token.call().balanceOf(empty_address) == 0 assert token.call().allowance(token_owner, empty_address) == 0 # Event # We follow OpenZeppelin - in the ERO20 issue names are _from, _to, _value transfer = token._find_matching_event_abi("Transfer", ["from", "to", "value"]) assert transfer approval = token._find_matching_event_abi("Approval", ["owner", "spender", "value"]) assert approval
def test_signature_contract_verify_v_r_s(web3: Web3, signature_contract: Contract): """Test that our signature verification works in Solidity contract. """ # Use random Ethereum address as payload for signing data = "0xda39147df55f6c51ad539a5e108adc5d7284b309" # Convert address to raw bytes data_bin = binascii.unhexlify(data[2:]) assert type(data_bin) == bytes private_key_seed = "foobar" # Address is 0x58708390680239282143999941903085911172379991841 signature_data = sign(data_bin, private_key_seed) # hash = big_endian_to_int(signature_data["hash"]) hash = signature_data["hash"] v = signature_data["v"] r = signature_data["r_bytes"] s = signature_data["s_bytes"] # 0x0a489345f9e9bc5254e18dd14fa7ecfdb2ce5f21 result = signature_contract.call().verify(hash, v, r, s) assert result == signature_data["address_ethereum"]
def get_constructor_arguments(contract: Contract, args: Optional[list]=None, kwargs: Optional[dict]=None): """Get constructor arguments for Etherscan verify. https://etherscanio.freshdesk.com/support/solutions/articles/16000053599-contract-verification-constructor-arguments """ constructor_abi = get_constructor_abi(contract.abi) if args is not None: return contract._encode_abi(constructor_abi, args)[2:] # No 0x else: constructor_abi = get_constructor_abi(contract.abi) arguments = merge_args_and_kwargs(constructor_abi, [], kwargs) deploy_data = add_0x_prefix( contract._encode_abi(constructor_abi, arguments) ) return deploy_data
def test_cannot_change_agent_in_fly(upgradeable_token: Contract, upgrade_agent: Contract, team_multisig, customer, upgrade_agent_2): """Upgrade agent cannot be changed after the ugprade has begun.""" upgradeable_token.transact({"from": team_multisig}).setUpgradeAgent(upgrade_agent.address) upgradeable_token.transact({"from": team_multisig}).transfer(customer, 10000) upgradeable_token.transact({"from": customer}).upgrade(10000) with pytest.raises(TransactionFailed): upgradeable_token.transact({"from": team_multisig}).setUpgradeAgent(upgrade_agent_2.address)
def sweep_account( private_key: str, faucet_address: str, token_contract: Contract, web3: Web3, wait_for_transaction ): address = privkey_to_addr(private_key) log.info('Sweeping account {}'.format(address)) token_balance = token_contract.call().balanceOf(address) if token_balance > 0: tx = create_signed_contract_transaction( private_key, token_contract, 'transfer', [ faucet_address, token_balance ] ) try: tx_hash = web3.eth.sendRawTransaction(tx) except ValueError as e: if e.args[0]['message'].startswith('Insufficient funds.'): pass else: raise else: wait_for_transaction(tx_hash) assert token_contract.call().balanceOf(address) == 0 balance = web3.eth.getBalance(address) if balance < NETWORK_CFG.POT_GAS_LIMIT * NETWORK_CFG.GAS_PRICE: return tx = create_signed_transaction( private_key, web3, to=faucet_address, value=balance - NETWORK_CFG.POT_GAS_LIMIT * NETWORK_CFG.GAS_PRICE, gas_limit=NETWORK_CFG.POT_GAS_LIMIT ) tx_hash = web3.eth.sendRawTransaction(tx) wait_for_transaction(tx_hash) assert web3.eth.getBalance(address) == 0, ( 'Sweeping of account {} (private key {}) failed.'.format(address, private_key) )
def test_sign_balance_proof_contract(channel_manager_contract: Contract): sig = sign_balance_proof( SENDER_PRIVATE_KEY, RECEIVER_ADDR, 37, 15, channel_manager_contract.address ) sender_recovered = channel_manager_contract.call().extractBalanceProofSignature( RECEIVER_ADDR, 37, 15, sig ) assert is_same_address(sender_recovered, SENDER_ADDR)
def test_sign_close_contract(channel_manager_contract: Contract): sig = sign_close( RECEIVER_PRIVATE_KEY, SENDER_ADDR, 315832, 13, channel_manager_contract.address ) receiver_recovered = channel_manager_contract.call().extractClosingSignature( SENDER_ADDR, 315832, 13, sig ) assert is_same_address(receiver_recovered, RECEIVER_ADDR)
def test_buy_again(chain: TestRPCChain, web3: Web3, ico: Contract, uncapped_token: Contract, customer: str, preico_token_price, preico_starts_at, team_multisig): """Can buy more.""" original_balance = web3.eth.getBalance(team_multisig) wei_value = to_wei(1, "ether") buys_tokens = wei_value // preico_token_price assert buys_tokens > 0 time_travel(chain, preico_starts_at + 1) # Buy twice ico.transact({"from": customer, "value": wei_value}).buy() ico.transact({"from": customer, "value": wei_value}).buy() # # See everything was correctly credited # # Tokens on every account assert uncapped_token.call().balanceOf(customer) == buys_tokens * 2 assert uncapped_token.call().totalSupply() == buys_tokens * 2 assert ico.call().tokensSold() == buys_tokens * 2 # Ether on every account assert ico.call().weiRaised() == wei_value * 2 assert ico.call().investedAmountOf(customer) == wei_value * 2 balance_diff = web3.eth.getBalance(team_multisig) - original_balance assert balance_diff == wei_value * 2 # Investors assert ico.call().investorCount() == 1 # # Events # # Crowdsale events = ico.pastEvents("Invested").get() assert len(events) == 2 # ERC-20 events = uncapped_token.pastEvents("Transfer").get() assert len(events) == 2
def test_initialized(ico: Contract, uncapped_token: Contract, team_multisig, preico_starts_at, preico_ends_at, preico_funding_goal): """Is initialized with the parameters we want.""" # We have owner assert ico.call().owner() == team_multisig # Crowdsale contract is in minters assert uncapped_token.call().mintAgents(ico.address) == True assert not uncapped_token.call().released() assert not ico.call().halted() assert ico.call().startsAt() == preico_starts_at assert ico.call().endsAt() == preico_ends_at assert ico.call().getState() == CrowdsaleState.PreFunding assert ico.call().minimumFundingGoal() == preico_funding_goal