Skip to content

Instantly share code, notes, and snippets.

@oberstet
Created April 6, 2018 18:35
Show Gist options
  • Save oberstet/07f76327d5e339a0757be12e9b794ad3 to your computer and use it in GitHub Desktop.
Save oberstet/07f76327d5e339a0757be12e9b794ad3 to your computer and use it in GitHub Desktop.
(cpy365_1) oberstet@thinkpad-t430s:~/scm/oberstet/pyethereum$ python -m pytest ethereum/tests/test_contracts.py
=========================================================================== test session starts ===========================================================================
platform linux -- Python 3.6.5, pytest-3.5.0, py-1.5.3, pluggy-0.6.0
rootdir: /home/oberstet/scm/oberstet/pyethereum, inifile:
plugins: timeout-1.0.0, catchlog-1.2.2
collected 56 items
ethereum/tests/test_contracts.py .........F.........................F.................... [100%]
================================================================================ FAILURES =================================================================================
_______________________________________________________________________________ test_hedge ________________________________________________________________________________
def test_hedge():
c, x = test_data_feeds()
x2 = c.contract(hedge_code, sender=tester.k0, language='serpent')
# Have the first party register, sending 10^16 wei and
# asking for a hedge using currency code 500
o1 = x2.main(x.address, 500, value=10 ** 16)
assert o1 == 1
# Have the second party register. It should receive the
# amount of units of the second currency that it is
# entitled to. Note that from the previous test this is
# set to 726
o2 = x2.main(0, 0, value=10 ** 16, sender=tester.k2)
assert o2 == 7260000000000000000
c.head_state.commit()
snapshot = c.snapshot()
# Set the price of the asset down to 300 wei
o3 = x.set(500, 300)
assert o3 == 1
# Finalize the contract. Expect code 3, meaning a margin call
o4 = x2.main(0, 0)
assert o4 == 3
c.revert(snapshot)
# Don't change the price. Finalize, and expect code 5, meaning
# the time has not expired yet
o5 = x2.main(0, 0)
assert o5 == 5
> c.mine(100, tester.a3)
ethereum/tests/test_contracts.py:364:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <ethereum.tools.tester.Chain object at 0x7f0d6a5368d0>, number_of_blocks = 100, timestamp = b'Y\x84C\xf1\x88\x0e\xf5\x85\xb2\x1f\x1du\x85\xbd\x05w@(a\xe5'
coinbase = b'\x82\xa9x\xb3\xf5\x96*[\tW\xd9\xee\x9e\xefG.\xe5[B\xf1'
def mine(self, number_of_blocks=1, timestamp=14, coinbase=a0):
self.cs.finalize(self.head_state, self.block)
set_execution_results(self.head_state, self.block)
self.block = Miner(self.block).mine(rounds=100, start_nonce=0)
assert self.chain.add_block(self.block)
b = self.block
for i in range(1, number_of_blocks):
b, _ = make_head_candidate(
> self.chain, parent=b, timestamp=self.chain.state.timestamp + timestamp, coinbase=coinbase)
E TypeError: unsupported operand type(s) for +: 'int' and 'bytes'
ethereum/tools/tester.py:259: TypeError
-------------------------------------------------------------------------- Captured stdout call ---------------------------------------------------------------------------
Initializing chain from provided state
INFO:eth.block Block pre-sealed, 639560 gas used
INFO:eth.chain Adding to head head=c6745cf3
Saved 6 address change logs
INFO:eth.chain Added block 1 (92665f97) with 10 txs and 639560 gas
-------------------------------------------------------------------------- Captured stderr call ---------------------------------------------------------------------------
Warning (file "main", line 2, char 21): The foo:i extern format is deprecated. It will still work for now but better regenerate the signature with `serpent mk_signature <file>` and paste the new signature in
Warning (file "main", line 2, char 29): The foo:i extern format is deprecated. It will still work for now but better regenerate the signature with `serpent mk_signature <file>` and paste the new signature in
Warning (file "main", line 2, char 21): The foo:i extern format is deprecated. It will still work for now but better regenerate the signature with `serpent mk_signature <file>` and paste the new signature in
Warning (file "main", line 2, char 29): The foo:i extern format is deprecated. It will still work for now but better regenerate the signature with `serpent mk_signature <file>` and paste the new signature in
___________________________________________________________________________ test_ed25519verify ____________________________________________________________________________
def test_ed25519verify():
c = tester.Chain()
> x = c.contract(ed25519verify_code, language='serpent')
ethereum/tests/test_contracts.py:1242:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
ethereum/tools/tester.py:241: in contract
sourcecode) + (ct.encode_constructor_arguments(args) if args else b'')
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
code = '\ndef main(msg:bytes32, vk:bytes32, sig1:bytes32, sig2:bytes32):\n return(ed25519verify(msg + vk + sig1 + sig2))\n', kwargs = {}
> compile = lambda code, **kwargs: pyext.compile(strtobytes(pre_transform(code, kwargs)))
E Exception: Error (file "main", line 3, char 43): Invalid argument count or LLL function: (ed25519verify (add (add (add (get 'msg) (get 'vk)) (get 'sig1)) (get 'sig2)))
../../../cpy365_1/lib/python3.6/site-packages/serpent.py:104: Exception
-------------------------------------------------------------------------- Captured stdout call ---------------------------------------------------------------------------
Initializing chain from provided state
-------------------------------------------------------------------------- Captured stderr call ---------------------------------------------------------------------------
Error (file "main", line 3, char 43): Invalid argument count or LLL function: (ed25519verify (add (add (add (get 'msg) (get 'vk)) (get 'sig1)) (get 'sig2)))
============================================================================ warnings summary =============================================================================
None
pytest-catchlog plugin has been merged into the core, please remove it from your requirements.
-- Docs: http://doc.pytest.org/en/latest/warnings.html
============================================================ 2 failed, 54 passed, 1 warnings in 11.81 seconds =============================================================
(cpy365_1) oberstet@thinkpad-t430s:~/scm/oberstet/pyethereum$
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment