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


Python tester.accounts方法代码示例

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


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

示例1: test_owner_2of3_rem_add

# 需要导入模块: from ethereum import tester [as 别名]
# 或者: from ethereum.tester import accounts [as 别名]
def test_owner_2of3_rem_add(self):
        n_wallet_owners = 3
        wallet, wallet_owners, wallet_owner_keys, translator = self.deploy_wallet(n_wallet_owners,
                                                                                  required=2)
        self.state.mine(1)

        old_acc = tester.accounts[0]
        assert wallet.isOwner(old_acc)

        rem_old = translator.encode_function_call('removeOwner', [old_acc])
        wallet.submitTransaction(wallet.address, 0, rem_old,
                                 10001, sender=tester.keys[1])
        wallet.submitTransaction(wallet.address, 0, rem_old,
                                 10001, sender=tester.keys[2])
        assert not wallet.isOwner(old_acc)

        self.state.mine(1)
        new_acc = tester.accounts[9]
        assert not wallet.isOwner(new_acc)
        add_new = translator.encode_function_call('addOwner', [new_acc])
        wallet.submitTransaction(wallet.address, 0, add_new,
                                 10001, sender=tester.keys[1])
        wallet.submitTransaction(wallet.address, 0, add_new,
                                 10001, sender=tester.keys[2])
        assert wallet.isOwner(new_acc) 
开发者ID:golemfactory,项目名称:golem-crowdfunding,代码行数:27,代码来源:test_wallet.py

示例2: test_gas_for_migrate_all

# 需要导入模块: from ethereum import tester [as 别名]
# 或者: from ethereum.tester import accounts [as 别名]
def test_gas_for_migrate_all(self):
        factory_key = urandom(32)
        addr, _ = self.deploy_contract(privtoaddr(factory_key), 1, 2)
        self.state.mine(1)
        for i, k in enumerate(tester.keys):
            v = random.randrange(15000 * denoms.ether, 82000 * denoms.ether)
            self.c.create(sender=k, value=v)
        self.state.mine(2)
        self.c.finalize()
        m_addr, _ = self.deploy_migration_contract(addr)
        t_addr, _ = self.deploy_target_contract(m_addr)
        self.c.setMigrationAgent(m_addr, sender=factory_key)
        self.m.setTargetToken(t_addr, sender=tester.k9)
        self.state.mine()
        self.state.block.coinbase = urandom(20)
        costs = []
        for i, k in enumerate(tester.keys):
            b = self.c.balanceOf(tester.accounts[i])
            m = self.monitor(i)
            self.c.migrate(b, sender=k)
            costs.append(m.gas())
        print(costs)
        assert max(costs) <= 99304
        assert min(costs) >= 56037 
开发者ID:golemfactory,项目名称:golem-crowdfunding,代码行数:26,代码来源:test_gnt.py

示例3: test_gas_for_migrate_half

# 需要导入模块: from ethereum import tester [as 别名]
# 或者: from ethereum.tester import accounts [as 别名]
def test_gas_for_migrate_half(self):
        factory_key = urandom(32)
        addr, _ = self.deploy_contract(privtoaddr(factory_key), 1, 2)
        self.state.mine(1)
        for i, k in enumerate(tester.keys):
            v = random.randrange(15000 * denoms.ether, 82000 * denoms.ether)
            self.c.create(sender=k, value=v)
        self.state.mine(2)
        self.c.finalize()
        m_addr, _ = self.deploy_migration_contract(addr)
        t_addr, _ = self.deploy_target_contract(m_addr)
        self.c.setMigrationAgent(m_addr, sender=factory_key)
        self.m.setTargetToken(t_addr, sender=tester.k9)
        self.state.mine()
        self.state.block.coinbase = urandom(20)
        costs = []
        for i, k in enumerate(tester.keys):
            b = self.c.balanceOf(tester.accounts[i])
            m = self.monitor(i)
            self.c.migrate(b / 2, sender=k)
            costs.append(m.gas())
        print(costs)
        assert max(costs) <= 114304
        assert min(costs) >= 71037 
开发者ID:golemfactory,项目名称:golem-crowdfunding,代码行数:26,代码来源:test_gnt.py

示例4: test_gas_for_refund

# 需要导入模块: from ethereum import tester [as 别名]
# 或者: from ethereum.tester import accounts [as 别名]
def test_gas_for_refund(self):
        addr, _ = self.deploy_contract(urandom(20), 1, 2)
        self.state.mine(1)
        for i, k in enumerate(tester.keys):
            v = random.randrange(1 * denoms.ether, 15000 * denoms.ether)
            self.c.create(sender=k, value=v)
        self.state.mine(2)
        self.state.block.coinbase = urandom(20)
        costs = []
        for i, k in enumerate(tester.keys):
            b = self.c.balanceOf(tester.accounts[i])
            m = self.monitor(i, -(b // 1000))
            self.c.refund(sender=k)
            costs.append(m.gas())
        print(costs)
        assert max(costs) == 27113
        assert min(costs) == 21057 
开发者ID:golemfactory,项目名称:golem-crowdfunding,代码行数:19,代码来源:test_gnt.py

示例5: test_transfer_enabled_after_max_fund_reached

# 需要导入模块: from ethereum import tester [as 别名]
# 或者: from ethereum.tester import accounts [as 别名]
def test_transfer_enabled_after_max_fund_reached(self):
        founder = tester.accounts[2]
        addr, _ = self.deploy_contract(founder, 3, 7)
        assert self.c.funding()
        for _ in range(3):
            self.state.mine()
            assert self.c.funding()

        assert self.state.block.number == self.starting_block + 3
        self.c.create(sender=tester.keys[0], value=11)
        assert self.c.funding()
        self.c.create(sender=tester.keys[1], value=self.c.tokenCreationCap() / self.c.tokenCreationRate() - 11)
        assert self.c.funding()
        for _ in range(8):
            self.state.mine()
            assert self.c.funding()
        # Transfer is enabled after the funding is finalized.
        self.c.finalize(sender=tester.k5)
        assert not self.c.funding() 
开发者ID:golemfactory,项目名称:golem-crowdfunding,代码行数:21,代码来源:test_gnt.py

示例6: test_wallet_looping_in_payable

# 需要导入模块: from ethereum import tester [as 别名]
# 或者: from ethereum.tester import accounts [as 别名]
def test_wallet_looping_in_payable(self):
        founder = tester.accounts[9]
        key = tester.keys[9]
        wallet_addr, g0 = self.deploy_wallet(founder)
        assert 0 == self.wallet.get_out_i(sender=key)
        self.wallet.set_extra_work(1, sender=key)
        extra = 10  # 601 passes, 602 fails send
        value = 11000
        self.wallet.set_extra_work(extra)
        self.state.mine(1)
        initial_b = self.state.block.get_balance(wallet_addr)
        self.state.send(tester.keys[0], wallet_addr, value)
        self.state.mine(1)
        current_b = self.state.block.get_balance(wallet_addr)
        assert extra == self.wallet.get_out_i(sender=key)
        assert current_b == initial_b + value 
开发者ID:golemfactory,项目名称:golem-crowdfunding,代码行数:18,代码来源:test_gnt.py

示例7: test_good_wallet

# 需要导入模块: from ethereum import tester [as 别名]
# 或者: from ethereum.tester import accounts [as 别名]
def test_good_wallet(self):
        founder = tester.accounts[9]
        key = tester.keys[9]
        wallet_addr, g0 = self.deploy_wallet(founder)
        c_addr = self.deploy_contract_on_wallet(wallet_addr, 1, 2)
        value = int(self.c.tokenCreationMin() / self.c.tokenCreationRate())
        self.state.mine(1)
        self.c.create(sender=tester.k1, value=value)
        self.state.mine(3)
        extra = 0
        self.wallet.set_extra_work(extra)
        assert extra == self.wallet.get_extra_work()
        initial_b = self.state.block.get_balance(wallet_addr)
        self.wallet.finalize(c_addr, sender=key)
        self.state.mine(1)
        current_b = self.state.block.get_balance(wallet_addr)
        assert current_b == initial_b + value
        assert extra == self.wallet.get_out_i(sender=key) 
开发者ID:golemfactory,项目名称:golem-crowdfunding,代码行数:20,代码来源:test_gnt.py

示例8: test_withdraw

# 需要导入模块: from ethereum import tester [as 别名]
# 或者: from ethereum.tester import accounts [as 别名]
def test_withdraw(self):
        self.deploy_contract()
        assert self.contract_balance() == 0
        v = 4800 * eth  # TODO: Use pytest parametrize
        w = 2016 * eth
        self.deposit(6, v)
        assert self.contract_balance() == v
        assert self.balance_of(6) == v
        a = tester.accounts[6]
        b0 = self.state.block.get_balance(a)
        eg = self.withdraw(6, w)
        assert eg <= 12393
        assert self.contract_balance() == v - w
        diff = self.state.block.get_balance(a) - b0
        g = w - diff
        limit = 21000 + 5000 + 6700 + 1492
        assert g <= limit
        assert self.balance_of(6) == v - w 
开发者ID:golemfactory,项目名称:ethereum-contracts,代码行数:20,代码来源:test_bankofdeposit.py

示例9: test_withdraw_explicit_to_self

# 需要导入模块: from ethereum import tester [as 别名]
# 或者: from ethereum.tester import accounts [as 别名]
def test_withdraw_explicit_to_self(self):
        self.deploy_contract()
        assert self.contract_balance() == 0
        v = 1234 * eth
        w = 1111 * eth
        self.deposit(6, v)
        assert self.contract_balance() == v
        assert self.balance_of(6) == v
        a = tester.accounts[6]
        b0 = self.state.block.get_balance(a)
        eg = self.withdraw(6, w, 6)
        assert eg <= 12408
        assert self.contract_balance() == v - w
        diff = self.state.block.get_balance(a) - b0
        g = w - diff
        limit = 21000 + 5000 + 6700 + 2881
        assert g <= limit
        assert self.balance_of(6) == v - w 
开发者ID:golemfactory,项目名称:ethereum-contracts,代码行数:20,代码来源:test_bankofdeposit.py

示例10: test_withdraw_explicit_to

# 需要导入模块: from ethereum import tester [as 别名]
# 或者: from ethereum.tester import accounts [as 别名]
def test_withdraw_explicit_to(self):
        self.deploy_contract()
        assert self.contract_balance() == 0
        v = 1234 * eth
        w = 1111 * eth
        self.deposit(6, v)
        assert self.contract_balance() == v
        assert self.balance_of(6) == v
        a = tester.accounts[6]
        b0 = self.state.block.get_balance(a)
        to = tester.accounts[7]
        b_to = self.state.block.get_balance(to)
        eg = self.withdraw(6, w, 7)
        assert eg <= 12408
        assert self.contract_balance() == v - w
        g = b0 - self.state.block.get_balance(a)
        limit = 21000 + 5000 + 6700 + 2881
        assert g <= limit
        assert self.balance_of(6) == v - w
        assert self.state.block.get_balance(to) - b_to == w 
开发者ID:golemfactory,项目名称:ethereum-contracts,代码行数:22,代码来源:test_bankofdeposit.py

示例11: test_transfer_value_4

# 需要导入模块: from ethereum import tester [as 别名]
# 或者: from ethereum.tester import accounts [as 别名]
def test_transfer_value_4(self):
        """Transfers value included in transaction to 4 other accounts."""
        self.deploy_contract()
        self.deposit(1, 1)
        self.deposit(2, 1)
        self.deposit(3, 1)
        self.deposit(4, 1)
        self.deposit(5, 1)
        v = 1000 * eth
        g = self.transfer(1, [(2, 2*eth), (3, 3*eth), (4, 4*eth), (5, 5*eth)],
                          value=v)
        assert self.balance(2) == 2*eth + 1
        assert self.balance(3) == 3*eth + 1
        assert self.balance(4) == 4*eth + 1
        assert self.balance(5) == 5*eth + 1
        b1 = self.balance(1)
        assert b1 == (1000-2-3-4-5)*eth + 1  # Rest should go to 1
        g -= b1
        assert g <= 63032 
开发者ID:golemfactory,项目名称:ethereum-contracts,代码行数:21,代码来源:test_bankofdeposit.py

示例12: test_transfer_mixed_4

# 需要导入模块: from ethereum import tester [as 别名]
# 或者: from ethereum.tester import accounts [as 别名]
def test_transfer_mixed_4(self):
        """Deposits some value, then transfers bigger amount to 4 other
           accounts using deposited value and value included in transaction.
           """
        self.deploy_contract()
        v = 100
        p = 55 + 44 + 33 + 22
        d = p / 2
        self.deposit(1, d*eth)  # Deposit half of payments
        self.transfer(1, [(5, 55*eth), (4, 44*eth), (3, 33*eth), (2, 22*eth)],
                      value=(d + 100)*eth)  # Transfer another half + v
        assert self.balance(2) == 22*eth
        assert self.balance(3) == 33*eth
        assert self.balance(4) == 44*eth
        assert self.balance(5) == 55*eth
        assert self.balance(1) == v*eth  # Rest should go to 1 
开发者ID:golemfactory,项目名称:ethereum-contracts,代码行数:18,代码来源:test_bankofdeposit.py

示例13: test_transfer_external_value_2

# 需要导入模块: from ethereum import tester [as 别名]
# 或者: from ethereum.tester import accounts [as 别名]
def test_transfer_external_value_2(self):
        """Transfers exact value included in transaction to 2 other accounts.
           This is a benchmark used to compare with transfer().
           See :func:test_transfer_exact_value_2.
           """
        self.deploy_contract()
        self.deposit(1, 1)
        self.deposit(7, 1)
        v1, v7 = 1*eth, 7*eth
        v = v1 + v7
        g = self.transfer_external_value(8, [(1, v1), (7, v7)], value=v)
        savings = 1 - (g / 39975.0)
        assert g <= 39843
        assert savings < 0.005
        assert self.balance(8) == 0
        assert self.balance(1) == v1 + 1
        assert self.balance(7) == v7 + 1
        assert self.contract_balance() == v + 2 
开发者ID:golemfactory,项目名称:ethereum-contracts,代码行数:20,代码来源:test_bankofdeposit.py

示例14: _send_evm_transaction

# 需要导入模块: from ethereum import tester [as 别名]
# 或者: from ethereum.tester import accounts [as 别名]
def _send_evm_transaction(tester_module, evm, transaction):
    from ethereum import tester

    try:
        # record the current gas price so that it can be reset after sending
        # the transaction.
        pre_transaction_gas_price = tester.gas_price
        pre_transaction_gas_limit = tester.gas_limit
        # set the evm gas price to the one specified by the transaction.
        tester.gas_price = transaction.get('gas_price', tester.gas_price)
        tester.gas_limit = transaction['gas']

        # get the private key of the sender.
        try:
            sender = tester.keys[tester.accounts.index(transaction['from'])]
        except ValueError:
            sender = evm.extra_accounts[transaction['from']]

        output = evm.send(
            sender=sender,
            to=transaction.get('to', b''),
            value=transaction.get('value', 0),
            evmdata=transaction.get('data', b''),
        )
    finally:
        # revert the tester gas price back to the original value.
        tester.gas_price = pre_transaction_gas_price
        tester.gas_limit = pre_transaction_gas_limit

    return output 
开发者ID:ethereum,项目名称:eth-tester,代码行数:32,代码来源:main.py

示例15: get_accounts

# 需要导入模块: from ethereum import tester [as 别名]
# 或者: from ethereum.tester import accounts [as 别名]
def get_accounts(self):
        from ethereum import tester

        for account in tester.accounts:
            yield account

        for account in self.evm.extra_accounts.keys():
            yield account 
开发者ID:ethereum,项目名称:eth-tester,代码行数:10,代码来源:main.py


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