本文整理汇总了Python中ethereum.tester.k3方法的典型用法代码示例。如果您正苦于以下问题:Python tester.k3方法的具体用法?Python tester.k3怎么用?Python tester.k3使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ethereum.tester
的用法示例。
在下文中一共展示了tester.k3方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_close_only_participant_can_close
# 需要导入模块: from ethereum import tester [as 别名]
# 或者: from ethereum.tester import k3 [as 别名]
def test_close_only_participant_can_close(tester_nettingcontracts):
""" Only the participants may call close. """
# Third party close is discussed on issue #182
_, _, nettingchannel = tester_nettingcontracts[0]
nonparticipant_key = tester.k3
with pytest.raises(TransactionFailed):
nettingchannel.close(sender=nonparticipant_key)
示例2: test_crowdfund
# 需要导入模块: from ethereum import tester [as 别名]
# 或者: from ethereum.tester import k3 [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)
示例3: test_full_scenario
# 需要导入模块: from ethereum import tester [as 别名]
# 或者: from ethereum.tester import k3 [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
示例4: test_create
# 需要导入模块: from ethereum import tester [as 别名]
# 或者: from ethereum.tester import k3 [as 别名]
def test_create(self):
addr, _ = self.deploy_contract(urandom(20), 1, 2)
self.state.mine(1)
v = 13 * denoms.ether + 13
self.c.create(sender=tester.k3, value=v)
assert self.c.balanceOf(tester.a3) == v * self.c.tokenCreationRate()
示例5: test_create_raw
# 需要导入模块: from ethereum import tester [as 别名]
# 或者: from ethereum.tester import k3 [as 别名]
def test_create_raw(self):
addr, _ = self.deploy_contract(urandom(20), 1, 2)
self.state.mine(1)
v = 13 * denoms.ether + 13
create_fn_id = decode_hex('efc81a8c')
self.state.send(tester.k3, addr, value=v, evmdata=create_fn_id)
assert self.c.balanceOf(tester.a3) == v * self.c.tokenCreationRate()
示例6: test_no_fallback_fn
# 需要导入模块: from ethereum import tester [as 别名]
# 或者: from ethereum.tester import k3 [as 别名]
def test_no_fallback_fn(self):
addr, _ = self.deploy_contract(urandom(20), 1, 2)
self.state.mine(1)
v = 13 * denoms.ether + 13
with self.assertRaises(TransactionFailed):
self.state.send(tester.k3, addr, value=v)
assert self.c.balanceOf(tester.a3) == 0
示例7: test_send_raw_data_no_value
# 需要导入模块: from ethereum import tester [as 别名]
# 或者: from ethereum.tester import k3 [as 别名]
def test_send_raw_data_no_value(self):
random_data = urandom(4)
print("RANDOM DATA: {}".format(random_data.encode('hex')))
addr, _ = self.deploy_contract(tester.a9, 7, 9)
assert self.c.totalSupply() == 0
assert self.contract_balance() == 0
with self.assertRaises(TransactionFailed):
self.state.send(tester.k3, addr, value=0, evmdata=random_data)
assert self.c.totalSupply() == 0
assert self.contract_balance() == 0
self.state.mine(7)
assert self.is_funding_active()
with self.assertRaises(TransactionFailed):
self.state.send(tester.k3, addr, value=0, evmdata=random_data)
assert self.c.totalSupply() == 0
assert self.contract_balance() == 0
self.state.mine(3)
assert not self.is_funding_active()
with self.assertRaises(TransactionFailed):
self.state.send(tester.k3, addr, value=0, evmdata=random_data)
assert self.c.totalSupply() == 0
assert self.contract_balance() == 0
示例8: test_send_raw_data_and_value
# 需要导入模块: from ethereum import tester [as 别名]
# 或者: from ethereum.tester import k3 [as 别名]
def test_send_raw_data_and_value(self):
random_data = urandom(4)
print("RANDOM DATA: {}".format(random_data.encode('hex')))
addr, _ = self.deploy_contract(tester.a9, 7, 9)
max_value = self.c.tokenCreationCap() / self.c.tokenCreationRate()
random_value = randint(0, max_value)
print("RANDOM VALUE: {}".format(random_value))
assert self.c.totalSupply() == 0
assert self.contract_balance() == 0
with self.assertRaises(TransactionFailed):
self.state.send(tester.k3, addr, random_value, evmdata=random_data)
assert self.c.totalSupply() == 0
assert self.contract_balance() == 0
self.state.mine(7)
assert self.is_funding_active()
with self.assertRaises(TransactionFailed):
self.state.send(tester.k3, addr, random_value, evmdata=random_data)
assert self.c.totalSupply() == 0
assert self.contract_balance() == 0
self.state.mine(3)
assert not self.is_funding_active()
with self.assertRaises(TransactionFailed):
self.state.send(tester.k4, addr, random_value, evmdata=random_data)
assert self.c.totalSupply() == 0
assert self.contract_balance() == 0