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


Python tester.a1方法代码示例

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


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

示例1: init_market

# 需要导入模块: from ethereum import tester [as 别名]
# 或者: from ethereum.tester import a1 [as 别名]
def init_market(self):
        self.buy_heap = self.s.abi_contract(self.HEAP_CONTRACT)
        self.sell_heap = self.s.abi_contract(self.HEAP_CONTRACT)

        self.buy_heap.set_owner(self.m.address)
        self.sell_heap.set_owner(self.m.address)

        self.c1 = self.s.abi_contract(self.SUBCURRENCY_CONTRACT)
        self.c2 = self.s.abi_contract(self.SUBCURRENCY_CONTRACT)

        self.c1.issue(tester.a0, 1000)
        self.c1.issue(tester.a1, 1000)
        self.c2.issue(tester.a2, 1000000)
        self.c2.issue(tester.a3, 1000000)

        self.m.init_market(self.buy_heap.address, self.sell_heap.address, self.c1.address, self.c2.address) 
开发者ID:beaugunderson,项目名称:serplint,代码行数:18,代码来源:test_market.py

示例2: test_lottery_5

# 需要导入模块: from ethereum import tester [as 别名]
# 或者: from ethereum.tester import a1 [as 别名]
def test_lottery_5(self):
        payments = {
            tester.a1: 1*eth,
            tester.a4: 4*eth,
            tester.a2: 2*eth,
            tester.a5: 5*eth,
            tester.a3: 3*eth,
        }

        lottery = Lottery(payments)
        assert lottery.value == 15*eth
        assert lottery.tickets[0].address == tester.a5

        assert lottery.root.left.left.value == lottery.tickets[0]
        assert lottery.root.left.right.value == lottery.tickets[1]
        assert lottery.root.right.left.value == lottery.tickets[2]
        assert lottery.root.right.right.left.value == lottery.tickets[3]
        assert lottery.root.right.right.right.value == lottery.tickets[4]

        assert lottery.root.hash.encode('hex') == 'a4a2fe70f894005badf01e06726c770f100f0969c491b065ef252f5ea48b87df' 
开发者ID:golemfactory,项目名称:ethereum-contracts,代码行数:22,代码来源:test_lottery.py

示例3: test_lottery_randomise

# 需要导入模块: from ethereum import tester [as 别名]
# 或者: from ethereum.tester import a1 [as 别名]
def test_lottery_randomise(self):
        self.deploy_contract()
        lottery = Lottery({tester.a1: 50 * eth, tester.a2: 50 * eth})
        assert lottery.value == 100 * eth
        self.lottery_init(3, lottery)
        assert self.lottery_get_value(lottery) == lottery.value
        self.state.mine(11)
        assert self.state.block.number == 11
        assert self.state.block.number > self.lottery_get_maturity(lottery)
        r = self.lottery_get_rand(lottery)
        assert r == 0
        g = self.lottery_randomise(3, lottery)
        assert g <= 44919
        r = self.lottery_get_rand(lottery)
        r = zpad(int_to_big_endian(r), 4)
        assert r == self.state.block.get_parent().hash[-4:]
        assert self.lottery_get_maturity(lottery) == 0
        assert self.lottery_get_value(lottery) == lottery.value 
开发者ID:golemfactory,项目名称:ethereum-contracts,代码行数:20,代码来源:test_lottery.py

示例4: test_lottery_payer_deposit

# 需要导入模块: from ethereum import tester [as 别名]
# 或者: from ethereum.tester import a1 [as 别名]
def test_lottery_payer_deposit(self):
        self.deploy_contract()
        payer = tester.a6
        w0 = self.state.block.get_balance(payer)
        lottery = Lottery({tester.a1: 33 * eth, tester.a2: 17 * eth})
        g1 = self.lottery_init(6, lottery)
        v = 50 * eth
        deposit = v / 10
        assert self.lottery_get_value(lottery) == v
        assert self.lottery_get_maturity(lottery) == 10
        b = self.state.block.get_balance(payer) - w0
        assert b == -(v + deposit + g1)
        self.state.mine(11)
        expected_rand = self.state.block.get_parent().hash[-4:]
        self.state.mine(127)
        self.lottery_randomise(9, lottery)  # Payer gets the deposit
        r = self.lottery_get_rand(lottery)
        r = zpad(int_to_big_endian(r), 4)
        assert r == expected_rand
        b = self.state.block.get_balance(payer) - w0
        assert b == -(v + g1) 
开发者ID:golemfactory,项目名称:ethereum-contracts,代码行数:23,代码来源:test_lottery.py

示例5: test_token

# 需要导入模块: from ethereum import tester [as 别名]
# 或者: from ethereum.tester import a1 [as 别名]
def test_token():
    standard_token_path = get_contract_path('StandardToken.sol')
    human_token_path = get_contract_path('HumanStandardToken.sol')

    state = tester.state()
    state.block.number = 1158001

    address0 = tester.a0
    address1 = tester.a1

    standard_token = state.abi_contract(
        None,
        path=standard_token_path,
        language='solidity',
    )

    contract_libraries = {
        'StandardToken': hexlify(standard_token.address),
    }
    human_token = state.abi_contract(
        None,
        path=human_token_path,
        language='solidity',
        libraries=contract_libraries,
        constructor_parameters=[10000, 'raiden', 0, 'rd'],
    )

    # pylint: disable=no-member
    assert human_token.balanceOf(address0) == 10000
    assert human_token.balanceOf(address1) == 0
    assert human_token.transfer(address1, 5000) is True
    assert human_token.balanceOf(address0) == 5000
    assert human_token.balanceOf(address1) == 5000 
开发者ID:raiden-network,项目名称:raiden,代码行数:35,代码来源:test_token.py

示例6: test_crowdfund

# 需要导入模块: from ethereum import tester [as 别名]
# 或者: from ethereum.tester import a1 [as 别名]
def test_crowdfund():
    s = tester.state()
    c = s.abi_contract(crowdfund_code)
    # Create a campaign with id 100
    c.create_campaign(100, 45, 100000, 2)
    # Create a campaign with id 200
    c.create_campaign(200, 48, 100000, 2)
    # Make some contributions
    c.contribute(100, value=1, sender=tester.k1)
    assert 1 == c.progress_report(100)
    c.contribute(200, value=30000, sender=tester.k2)
    c.contribute(100, value=59049, sender=tester.k3)
    assert 59050 == c.progress_report(100)
    c.contribute(200, value=70001, sender=tester.k4)
    # Expect the 100001 units to be delivered to the destination
    # account for campaign 2
    assert 100001 == s.block.get_balance(utils.int_to_addr(48))
    mida1 = s.block.get_balance(tester.a1)
    mida3 = s.block.get_balance(tester.a3)
    # Mine 5 blocks to expire the campaign
    s.mine(5)
    # Ping the campaign after expiry
    c.contribute(100, value=1)
    # Expect refunds
    assert mida1 + 1 == s.block.get_balance(tester.a1)
    assert mida3 + 59049 == s.block.get_balance(tester.a3) 
开发者ID:ethereumproject,项目名称:pyethereum,代码行数:28,代码来源:test_contracts.py

示例7: test_full_scenario

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

        # Place orders
        self.c1.send(self.m.address, 1000, sender=tester.k0)
        self.m.buy(1200, sender=tester.k0)

        self.c1.send(self.m.address, 1000, sender=tester.k1)
        self.m.buy(1400, sender=tester.k1)

        self.c2.send(self.m.address, 1000000, sender=tester.k2)
        self.m.sell(800, sender=tester.k2)

        self.c2.send(self.m.address, 1000000, sender=tester.k3)
        self.m.sell(600, sender=tester.k3)

        print("Orders placed")

        # Next epoch and ping
        self.s.mine(100)
        print("Mined 100")
        assert self.m.tick() == 1
        print("Updating")

        # Check
        assert self.c2.balance(tester.a0) == 800000
        assert self.c2.balance(tester.a1) == 600000
        assert self.c1.balance(tester.a2) == 833
        assert self.c1.balance(tester.a3) == 714
        print("Balance checks passed")

        assert self.m.volume() == 1547
        assert self.m.price() == 1000
        assert self.c1.balance(self.m.address) == 453
        assert self.c2.balance(self.m.address) == 600000
        assert self.buy_heap.size() == 0
        assert self.sell_heap.size() == 0 
开发者ID:beaugunderson,项目名称:serplint,代码行数:39,代码来源:test_market.py

示例8: test_simple_send

# 需要导入模块: from ethereum import tester [as 别名]
# 或者: from ethereum.tester import a1 [as 别名]
def test_simple_send(self):
        self.c.issue(tester.a0, 100000000000)
        assert self.c.balance(tester.a0) == 100000000000

        assert self.c.send(tester.a1, 1000) == 1
        assert self.c.balance(tester.a0) == 100000000000 - 1000
        assert self.c.balance(tester.a1) == 1000
        last_tx = self.c.last_tx()
        assert utils.int_to_addr(last_tx[0]) == tester.a0
        assert utils.int_to_addr(last_tx[1]) == tester.a1
        assert last_tx[2:] == [1000, 1] 
开发者ID:beaugunderson,项目名称:serplint,代码行数:13,代码来源:test_subcurrency.py

示例9: test_send_with_negative_amount_should_fail

# 需要导入模块: from ethereum import tester [as 别名]
# 或者: from ethereum.tester import a1 [as 别名]
def test_send_with_negative_amount_should_fail(self):
        self.c.issue(tester.a0, 100000000000)
        assert self.c.send(tester.a0, -1000, sender=tester.k1) == 0
        assert self.c.balance(tester.a0) == 100000000000
        assert self.c.balance(tester.a1) == 0 
开发者ID:beaugunderson,项目名称:serplint,代码行数:7,代码来源:test_subcurrency.py

示例10: test_single_refund

# 需要导入模块: from ethereum import tester [as 别名]
# 或者: from ethereum.tester import a1 [as 别名]
def test_single_refund(self):
        addr, _ = self.deploy_contract(tester.a9, 1, 4)
        self.state.mine(1)
        value = 150000 * denoms.ether - 1
        self.c.create(sender=tester.k1, value=value)
        assert self.c.totalSupply() == value * 1000
        self.state.mine(6)

        lg = self.state.block.gas_used
        b = self.state.block.get_balance(tester.a1)

        with self.event_listener(self.c, self.state) as listener:
            self.c.refund(sender=tester.k1)

            assert listener.event('Refund',
                                  _from=tester.a1.encode('hex'),
                                  _value=value)
            assert not listener.events  # no more events

        refund = self.state.block.get_balance(tester.a1) - b
        assert refund == value - (self.state.block.gas_used - lg) * tester.gas_price

        b = self.state.block.get_balance(tester.a2)
        with self.assertRaises(TransactionFailed):
            self.c.refund(sender=tester.k2)
        refund = self.state.block.get_balance(tester.a2) - b
        assert refund < 0 
开发者ID:golemfactory,项目名称:golem-crowdfunding,代码行数:29,代码来源:test_gnt.py

示例11: test_lottery_2

# 需要导入模块: from ethereum import tester [as 别名]
# 或者: from ethereum.tester import a1 [as 别名]
def test_lottery_2(self):
        payments = {
            tester.a1: 1*eth,
            tester.a2: 1*eth,
        }

        lottery = Lottery(payments)
        assert lottery.value == 2*eth
        assert lottery.tickets[0].address == tester.a1

        assert lottery.root.left.value == lottery.tickets[0]
        assert lottery.root.right.value == lottery.tickets[1]

        assert lottery.root.hash.encode('hex') == '033978b28985c7e15b104b1c123511ae240b6a5cec8f07e718dcedc21e1067d7' 
开发者ID:golemfactory,项目名称:ethereum-contracts,代码行数:16,代码来源:test_lottery.py

示例12: test_lottery_init

# 需要导入模块: from ethereum import tester [as 别名]
# 或者: from ethereum.tester import a1 [as 别名]
def test_lottery_init(self):
        self.deploy_contract()
        lottery = Lottery({tester.a1: 9, tester.a2: 1})
        g = self.lottery_init(2, lottery)
        assert g <= 84103
        assert self.lottery_get_value(lottery) == 10
        assert self.lottery_get_maturity(lottery) == 10 
开发者ID:golemfactory,项目名称:ethereum-contracts,代码行数:9,代码来源:test_lottery.py

示例13: test_lottery_payer_deposit_owner

# 需要导入模块: from ethereum import tester [as 别名]
# 或者: from ethereum.tester import a1 [as 别名]
def test_lottery_payer_deposit_owner(self):
        self.deploy_contract(9)
        payer = tester.a6
        w0 = self.state.block.get_balance(payer)
        lottery = Lottery({tester.a1: 11 * eth, tester.a2: 39 * eth})
        g1 = self.lottery_init(6, lottery)
        v = 50 * eth
        deposit = v / 10
        assert self.lottery_get_value(lottery) == v
        assert self.lottery_get_maturity(lottery) == 10
        b = self.state.block.get_balance(payer) - w0
        assert b == -(v + deposit + g1)
        self.state.mine(256 + 11)
        expected_rand = self.state.block.get_parent().hash[-4:]
        # Owner gets the deposit
        self.lottery_randomise(8, lottery)
        r = self.lottery_get_rand(lottery)
        r = zpad(int_to_big_endian(r), 4)
        assert r == expected_rand
        assert b == -(v + deposit + g1)

        assert self.lottery_get_owner_deposit() == deposit

        b0 = self.state.block.get_balance(tester.a9)
        self.lottery_owner_payout()
        b = self.state.block.get_balance(tester.a9) - b0
        assert b == deposit
        assert self.lottery_get_owner_deposit() == 0 
开发者ID:golemfactory,项目名称:ethereum-contracts,代码行数:30,代码来源:test_lottery.py

示例14: test_lottery_find_winner

# 需要导入模块: from ethereum import tester [as 别名]
# 或者: from ethereum.tester import a1 [as 别名]
def test_lottery_find_winner(self):
        lottery = Lottery({tester.a1: 50, tester.a2: 50})
        r = 2**32/2
        assert lottery.find_winner(r - 1)[0].address == tester.a1
        assert lottery.find_winner(r)[0].address == tester.a2 
开发者ID:golemfactory,项目名称:ethereum-contracts,代码行数:7,代码来源:test_lottery.py

示例15: test_lottery_find_winner2

# 需要导入模块: from ethereum import tester [as 别名]
# 或者: from ethereum.tester import a1 [as 别名]
def test_lottery_find_winner2(self):
        lottery = Lottery({
            tester.a4: 40 * eth,
            tester.a3: 30 * eth,
            tester.a2: 20 * eth,
            tester.a1: 10 * eth,
        })
        r = int(2**32 * 0.4)
        assert lottery.find_winner(r)[0].address == tester.a3 
开发者ID:golemfactory,项目名称:ethereum-contracts,代码行数:11,代码来源:test_lottery.py


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