當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。