ethereum / pyethereum

Next generation cryptocurrency network
2.67k stars 719 forks source link

test_contracts.py fails #336

Closed RomanZacharia closed 8 years ago

RomanZacharia commented 8 years ago

One of the test cases fails on the most resent fixtures commit 4db720dbd

============================================================================== FAILURES =============================================================================== _ test_ecrecover __

def test_ecrecover():
    s = tester.state()
    c = s.abi_contract(ecrecover_code)

    priv = utils.sha3('some big long brainwallet password')
    pub = bitcoin.privtopub(priv)

    msghash = utils.sha3('the quick brown fox jumps over the lazy dog')

    pk = PrivateKey(priv, raw=True)
    signature = pk.ecdsa_recoverable_serialize(
        pk.ecdsa_sign_recoverable(msghash, raw=True)
    )
    signature = signature[0] + chr(signature[1])
    V = ord(signature[64]) + 27
    R = big_endian_to_int(signature[0:32])
    S = big_endian_to_int(signature[32:64])

    assert bitcoin.ecdsa_raw_verify(msghash, (V, R, S), pub)

    addr = utils.big_endian_to_int(utils.sha3(bitcoin.encode_pubkey(pub, 'bin')[1:])[12:])
    assert utils.big_endian_to_int(utils.privtoaddr(priv)) == addr
  result = c.test_ecrecover(utils.big_endian_to_int(msghash), V, R, S)

ethereum/tests/test_contracts.py:1221:


ethereum/tester.py:110: in kall self._translator.encode(f, args), ethereum/abi.py:87: in encode encode_abi(fdata['encode_types'], args) ethereum/abi.py:366: in encode_abi myhead += enc(proctypes[i], args[i]) ethereum/abi.py:341: in enc return utils.to_string(encode_single(typ, arg))


typ = ('int', '256', []), arg = 607723637138147953...042300358765319404L

def encode_single(typ, arg):
    base, sub, _ = typ
    # Unsigned integers: uint<sz>
    if base == 'uint':
        sub = int(sub)
        i = decint(arg)

        if not 0 <= i < 2**sub:
            raise ValueOutOfBounds(repr(arg))
        return zpad(encode_int(i), 32)
    # bool: int<sz>
    elif base == 'bool':
        assert isinstance(arg, bool)
        return zpad(encode_int(int(arg)), 32)
    # Signed integers: int<sz>
    elif base == 'int':
        sub = int(sub)
        i = decint(arg)
        if not -2**(sub - 1) <= i < 2**(sub - 1):
          raise ValueOutOfBounds(repr(arg))

E ValueOutOfBounds: 60772363713814795336605161565488663769306106990467902980560042300358765319404L

RomanZacharia commented 8 years ago

Resolved after pulling the PR 335