当前位置: 首页>>代码示例>>Python>>正文


Python tester.TransactionFailed方法代码示例

本文整理汇总了Python中ethereum.tester.TransactionFailed方法的典型用法代码示例。如果您正苦于以下问题:Python tester.TransactionFailed方法的具体用法?Python tester.TransactionFailed怎么用?Python tester.TransactionFailed使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ethereum.tester的用法示例。


在下文中一共展示了tester.TransactionFailed方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_milestone_prices

# 需要导入模块: from ethereum import tester [as 别名]
# 或者: from ethereum.tester import TransactionFailed [as 别名]
def test_milestone_prices(chain, milestone_pricing, start_time, end_time, customer):
    """We get correct milestone prices for different dates."""

    time_travel(chain, start_time - 1)
    with pytest.raises(TransactionFailed):
        # Div by zero, crowdsale has not begin yet
        assert milestone_pricing.call().getCurrentPrice()

    time_travel(chain, start_time)
    assert milestone_pricing.call().getCurrentPrice() == to_wei("0.10", "ether")

    time_travel(chain, start_time + 1)
    assert milestone_pricing.call().getCurrentPrice() == to_wei("0.10", "ether")

    # 1 week forward
    time_travel(chain, int((datetime.datetime(2017, 4, 22, 16, 0) - datetime.datetime(1970, 1, 1)).total_seconds()))
    assert milestone_pricing.call().getCurrentPrice() == to_wei("0.12", "ether")

    # 2 week forward
    time_travel(chain, int((datetime.datetime(2017, 4, 29, 16, 0) - datetime.datetime(1970, 1, 1)).total_seconds()))
    assert milestone_pricing.call().getCurrentPrice() == to_wei("0.13", "ether")

    # 3 week forward + last second
    time_travel(chain, end_time - 1)
    assert milestone_pricing.call().getCurrentPrice() == to_wei("0.14", "ether") 
开发者ID:Webhero9297,项目名称:ethereum,代码行数:27,代码来源:test_milestone_pricing.py

示例2: test_lock_incorrectly

# 需要导入模块: from ethereum import tester [as 别名]
# 或者: from ethereum.tester import TransactionFailed [as 别名]
def test_lock_incorrectly(loaded_token_vault, team_multisig, token, customer, customer_2):
    """In the case of lock fails, we can redeem the tokens.."""
    assert loaded_token_vault.call().getState() == TokenVaultState.Loading

    # Move wrong amount tokens
    token.transact({"from": team_multisig}).transfer(loaded_token_vault.address, 4000)

    assert loaded_token_vault.call().getState() == TokenVaultState.Loading

    # Failed lock attempt
    with pytest.raises(TransactionFailed):
        loaded_token_vault.transact({"from": team_multisig}).lock()

    assert loaded_token_vault.call().getState() == TokenVaultState.Loading

    # Move tokens to back to the owner
    before_balance =token.call().balanceOf(team_multisig)
    loaded_token_vault.transact({"from": team_multisig}).recoverFailedLock()
    after_balance = token.call().balanceOf(team_multisig)

    assert after_balance - before_balance == 4000 
开发者ID:Webhero9297,项目名称:ethereum,代码行数:23,代码来源:test_token_vault.py

示例3: test_load_after_lock

# 需要导入模块: from ethereum import tester [as 别名]
# 或者: from ethereum.tester import TransactionFailed [as 别名]
def test_load_after_lock(token_vault_single, team_multisig, token, customer, customer_2):
    """After locking, no new invetors can be added."""

    token_vault = token_vault_single

    assert token_vault.call().getState() == TokenVaultState.Loading

    token_vault.transact({"from": team_multisig}).setInvestor(customer, 1000)

    # Move in tokens and lock
    token.transact({"from": team_multisig}).transfer(token_vault.address, 1000)
    token_vault.transact({"from": team_multisig}).lock()
    assert token_vault.call().getState() == TokenVaultState.Holding

    with pytest.raises(TransactionFailed):
        token_vault.transact({"from": team_multisig}).setInvestor(customer_2, 2000) 
开发者ID:Webhero9297,项目名称:ethereum,代码行数:18,代码来源:test_token_vault.py

示例4: test_proxy_buy_move_funds_twice

# 需要导入模块: from ethereum import tester [as 别名]
# 或者: from ethereum.tester import TransactionFailed [as 别名]
def test_proxy_buy_move_funds_twice(chain, web3, customer, customer_2, team_multisig, proxy_buyer, crowdsale, token):
    """We move funds only once."""

    assert proxy_buyer.call().getState() == 1

    proxy_buyer.transact({"value": to_wei(10000, "ether"), "from": customer}).investWithoutId()
    proxy_buyer.transact({"value": to_wei(20000, "ether"), "from": customer_2}).investWithoutId()

    # Everything funder
    assert proxy_buyer.call().weiRaisedTotal() == to_wei(30000, "ether")
    assert web3.eth.getBalance(proxy_buyer.address) == to_wei(30000, "ether")
    assert proxy_buyer.call().balances(customer) == to_wei(10000, "ether")
    assert proxy_buyer.call().balances(customer_2) == to_wei(20000, "ether")

    # Move over
    assert crowdsale.call().getState() == CrowdsaleState.Funding
    proxy_buyer.transact({"from": team_multisig}).setCrowdsale(crowdsale.address)
    assert proxy_buyer.call().crowdsale() == crowdsale.address
    proxy_buyer.transact({"from": customer}).buyForEverybody()

    with pytest.raises(TransactionFailed):
        proxy_buyer.transact({"from": customer}).buyForEverybody() 
开发者ID:Webhero9297,项目名称:ethereum,代码行数:24,代码来源:test_preico_proxy_buy.py

示例5: test_getchannelwith_must_return_zero_for_non_existing_channels

# 需要导入模块: from ethereum import tester [as 别名]
# 或者: from ethereum.tester import TransactionFailed [as 别名]
def test_getchannelwith_must_return_zero_for_non_existing_channels(
        tester_channelmanager,
        private_keys,
        settle_timeout):
    """ Queries to the channel manager for a non-existing channel with a partner
    must return zero.
    """
    addresses = map(privatekey_to_address, private_keys)

    sender_key = private_keys[0]
    sender_addr = privatekey_to_address(sender_key)
    null_addr = '0' * 40

    for addr in addresses:
        channel_address = tester_channelmanager.getChannelWith(addr, sender=sender_key)
        assert channel_address == null_addr

        # can not open a channel with itself
        if addr != sender_addr:
            tester_channelmanager.newChannel(addr, settle_timeout, sender=sender_key)
        else:
            with pytest.raises(TransactionFailed):
                tester_channelmanager.newChannel(addr, settle_timeout, sender=sender_key) 
开发者ID:raiden-network,项目名称:raiden,代码行数:25,代码来源:test_channel_manager.py

示例6: test_close_first_argument_is_for_partner_transfer

# 需要导入模块: from ethereum import tester [as 别名]
# 或者: from ethereum.tester import TransactionFailed [as 别名]
def test_close_first_argument_is_for_partner_transfer(tester_state, tester_channels):
    """ Close must not accept a transfer from the closing address. """
    pkey0, _, nettingchannel, channel0, channel1 = tester_channels[0]

    block_number = tester_state.block.number
    transfer0 = make_direct_transfer_from_channel(
        block_number,
        channel0,
        channel1,
        amount=90,
        pkey=pkey0,
    )

    transfer0_hash = sha3(transfer0.packed().data[:-65])
    with pytest.raises(TransactionFailed):
        nettingchannel.close(
            transfer0.nonce,
            transfer0.transferred_amount,
            transfer0.locksroot,
            transfer0_hash,
            transfer0.signature,
            sender=pkey0,
        ) 
开发者ID:raiden-network,项目名称:raiden,代码行数:25,代码来源:test_close.py

示例7: test_close_called_multiple_times

# 需要导入模块: from ethereum import tester [as 别名]
# 或者: from ethereum.tester import TransactionFailed [as 别名]
def test_close_called_multiple_times(tester_state, tester_nettingcontracts):
    """ A channel can be closed only once. """
    pkey0, pkey1, nettingchannel = tester_nettingcontracts[0]
    address0 = privatekey_to_address(pkey0)

    closed_block_number = tester_state.block.number
    nettingchannel.close(sender=pkey0)

    with pytest.raises(TransactionFailed):
        nettingchannel.close(sender=pkey0)

    with pytest.raises(TransactionFailed):
        nettingchannel.close(sender=pkey1)

    assert nettingchannel.closed(sender=pkey0) == closed_block_number
    assert nettingchannel.closingAddress(sender=pkey0) == encode_hex(address0) 
开发者ID:raiden-network,项目名称:raiden,代码行数:18,代码来源:test_close.py

示例8: manager_by_token

# 需要导入模块: from ethereum import tester [as 别名]
# 或者: from ethereum.tester import TransactionFailed [as 别名]
def manager_by_token(self, token_address):
        """ Find the channel manager for `token_address` and return a proxy to
        interact with it.

        If the token is not already registered it raises `TransactionFailed` when
        we do `self.registry_proxy.channelManagerByToken(token_address)`
        """
        if token_address not in self.token_to_channelmanager:
            manager_address = self.manager_address_by_token(token_address)
            manager = ChannelManagerTesterMock(
                self.tester_state,
                self.private_key,
                manager_address,
            )

            self.token_to_channelmanager[token_address] = manager
            self.address_to_channelmanager[manager_address] = manager

        return self.token_to_channelmanager[token_address] 
开发者ID:raiden-network,项目名称:raiden,代码行数:21,代码来源:tester_client.py

示例9: manager_address_if_token_registered

# 需要导入模块: from ethereum import tester [as 别名]
# 或者: from ethereum.tester import TransactionFailed [as 别名]
def manager_address_if_token_registered(self, token_address):
        """
        If the token is registered then, return the channel manager address.
        Also make sure that the channel manager is registered with the node.

        Returns None otherwise.
        """
        if not isaddress(token_address):
            raise InvalidAddress('token_address must be a valid address in binary')

        try:
            manager = self.raiden.default_registry.manager_by_token(token_address)
            if not self.raiden.channel_manager_is_registered(manager.address):
                self.raiden.register_channel_manager(manager.address)
            return manager.address
        except (EthNodeCommunicationError, TransactionFailed, NoTokenManager):
            return None 
开发者ID:raiden-network,项目名称:raiden,代码行数:19,代码来源:python.py

示例10: test_multi_vault_claim_too_much

# 需要导入模块: from ethereum import tester [as 别名]
# 或者: from ethereum.tester import TransactionFailed [as 别名]
def test_multi_vault_claim_too_much(chain, mysterium_multivault, preico_starts_at, mysterium_mv_token, team_multisig, customer, customer_2, mysterium_release_agent):
    """Somebody tries to claim too many tokens."""

    assert mysterium_mv_token.call().released()
    assert mysterium_mv_token.call().balanceOf(customer) == 0
    assert mysterium_mv_token.call().totalSupply() == 200

    # Load all 100% tokens to the vault for the test
    mysterium_mv_token.transact({"from": team_multisig}).transfer(mysterium_multivault.address, mysterium_mv_token.call().totalSupply())
    assert mysterium_mv_token.call().balanceOf(mysterium_multivault.address) == mysterium_mv_token.call().totalSupply()

    # Set the distribution balance
    mysterium_multivault.transact({"from": team_multisig}).fetchTokenBalance()

    # We pass the vault expiration date
    time_travel(chain, mysterium_multivault.call().freezeEndsAt() + 1)
    assert mysterium_multivault.call().getState() == MultiVaultState.Distributing

    # First customer gets his tokens
    assert mysterium_multivault.call().getClaimAmount(customer) == 60
    with pytest.raises(TransactionFailed):
        mysterium_multivault.transact({"from": customer}).claim(61) 
开发者ID:MysteriumNetwork,项目名称:contracts,代码行数:24,代码来源:test_multivault.py

示例11: test_multi_vault_claim_early

# 需要导入模块: from ethereum import tester [as 别名]
# 或者: from ethereum.tester import TransactionFailed [as 别名]
def test_multi_vault_claim_early(chain, mysterium_multivault, preico_starts_at, mysterium_mv_token, team_multisig, customer, customer_2, mysterium_release_agent):
    """Somebody tries to claim his tokens early."""

    assert mysterium_mv_token.call().released()
    assert mysterium_mv_token.call().balanceOf(customer) == 0
    assert mysterium_mv_token.call().totalSupply() == 200

    # Load all 100% tokens to the vault for the test
    mysterium_mv_token.transact({"from": team_multisig}).transfer(mysterium_multivault.address, mysterium_mv_token.call().totalSupply())
    assert mysterium_mv_token.call().balanceOf(mysterium_multivault.address) == mysterium_mv_token.call().totalSupply()

    # Set the distribution balance
    mysterium_multivault.transact({"from": team_multisig}).fetchTokenBalance()

    # We do not pass the vault expiration date
    time_travel(chain, mysterium_multivault.call().freezeEndsAt() - 1)
    assert mysterium_multivault.call().getState() == MultiVaultState.Holding

    # We can see the balance even before the transfer kicks in
    assert mysterium_multivault.call().getClaimAmount(customer) == 60

    # Early claim request fails
    with pytest.raises(TransactionFailed):
        mysterium_multivault.transact({"from": customer}).claim(1) 
开发者ID:MysteriumNetwork,项目名称:contracts,代码行数:26,代码来源:test_multivault.py

示例12: test_unlock_vault_early

# 需要导入模块: from ethereum import tester [as 别名]
# 或者: from ethereum.tester import TransactionFailed [as 别名]
def test_unlock_vault_early(chain, web3, vault, depositor, vault_opens_at, team_multisig):
    """Vault unlock fails."""
    # Money goes in
    test_value = to_wei(1000, "ether")

    vault_balance = web3.eth.getBalance(vault.address)
    team_multisig_balance = web3.eth.getBalance(team_multisig)
    web3.eth.sendTransaction({"from": depositor, "value": test_value, "to": vault.address})

    # Vault received ETH
    assert web3.eth.getBalance(vault.address) > vault_balance

    # Go to unlock date
    time_travel(chain, vault_opens_at-1)
    with pytest.raises(TransactionFailed):
        vault.transact({"from": depositor}).unlock()

    # Money was transferred to team multisig
    assert web3.eth.getBalance(team_multisig) == team_multisig_balance

    # Vault is empty now
    assert web3.eth.getBalance(vault.address) == test_value 
开发者ID:MysteriumNetwork,项目名称:contracts,代码行数:24,代码来源:test_intermediate_vault.py

示例13: test_bitcoin_suisse

# 需要导入模块: from ethereum import tester [as 别名]
# 或者: from ethereum.tester import TransactionFailed [as 别名]
def test_bitcoin_suisse(chain, ready_crowdsale, bitcoin_suisse, mysterium_pricing, team_multisig):
    """"Test BitcoinSuisse address whitelisting.

    Spec 3.2.
    """

    crowdsale = ready_crowdsale

    # Cannot transact initially
    assert crowdsale.call().getState() == CrowdsaleState.PreFunding

    with pytest.raises(TransactionFailed):
        crowdsale.transact({"from": bitcoin_suisse, "value": to_wei(10000, "ether")}).buy()

    # Now let's set rate and whitelist
    mysterium_pricing.transact({"from": team_multisig}).setConversionRate(130 * 10000)
    crowdsale.transact({"from": team_multisig}).setEarlyParicipantWhitelist(bitcoin_suisse, True)

    # Now BitcoinSuisse can execute
    crowdsale.transact({"from": bitcoin_suisse, "value": to_wei(10000, "ether")}).buy() 
开发者ID:MysteriumNetwork,项目名称:contracts,代码行数:22,代码来源:test_crowdsale.py

示例14: test_hard_cao_reached

# 需要导入模块: from ethereum import tester [as 别名]
# 或者: from ethereum.tester import TransactionFailed [as 别名]
def test_hard_cao_reached(started_crowdsale, team_multisig, customer, mysterium_pricing):
    """Crowdsale is full when the hard cap is reached.

    Spec 3.6.
    """

    crowdsale = started_crowdsale

    # Reset hard cap
    crowdsale.transact({"from": team_multisig}).setHardCapCHF(10000000 * 10000)

    hard_cap = crowdsale.call().getHardCap()

    # Some generous person comes and buy all tokens in the world
    crowdsale.transact({"from": customer, "value": hard_cap}).buy()

    # We reached the cap
    assert crowdsale.call().isCrowdsaleFull()
    assert crowdsale.call().getState() == CrowdsaleState.Success

    with pytest.raises(TransactionFailed):
        crowdsale.transact({"from": customer, "value": to_wei(1, "ether")}).buy() 
开发者ID:MysteriumNetwork,项目名称:contracts,代码行数:24,代码来源:test_crowdsale.py

示例15: test_payable_period

# 需要导入模块: from ethereum import tester [as 别名]
# 或者: from ethereum.tester import TransactionFailed [as 别名]
def test_payable_period(self):
        c_addr, _ = self.deploy_contract(tester.a0, 2, 3)
        value = 3 * denoms.ether

        # before funding
        self.state.mine(1)
        with self.assertRaises(TransactionFailed):
            self.c.create(sender=tester.k1, value=value)

        # during funding
        self.state.mine(1)
        self.c.create(sender=tester.k1, value=value)

        # post funding
        self.state.mine(2)
        with self.assertRaises(TransactionFailed):
            self.c.create(sender=tester.k1, value=value) 
开发者ID:golemfactory,项目名称:golem-crowdfunding,代码行数:19,代码来源:test_gnt.py


注:本文中的ethereum.tester.TransactionFailed方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。