2

I was not able to make the following Basic Testing example work on populus.

  • platform darwin -- Python 2.7.10, pytest-3.0.5, py-1.4.32, pluggy-0.4.0 rootdir: /Users/avatar/populus, inifile:
  • plugins: populus-1.4.2
  • OS: tried on mac OS and Linux.

-

[$] mkdir populus && cd populus
[$] populus init 
Created Directory: ./contracts
Created Example Contract: ./contracts/Greeter.sol
Created Directory: ./tests
Created Example Tests: ./tests/test_greeter.py

[~/pop]$ populus compile

============ Compiling ==============
> Loading source files from: ./contracts
> Found 1 contract source files
- contracts/Greeter.sol
> Compiled 1 contracts
- Greeter
> Wrote compiled assets to: ./build/contracts.json

[$] pytest tests/test_greeter.py //does not work ...

Following error emerged:


_____ test_greeter ______________________________________________________________________________

chain = <populus.chain.EthereumTesterChain object at 0x10db60610>

    def test_greeter(chain):
>       greeter = chain.get_contract('Greeter')

tests/test_greeter.py:2:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/usr/local/lib/python2.7/site-packages/populus/chain.py:566: in get_contract
    registrar = self.registrar
/usr/local/lib/python2.7/site-packages/populus/utils/functional.py:50: in __get__
    res = instance.__dict__[self.name] = self.func(instance)
/usr/local/lib/python2.7/site-packages/populus/chain.py:533: in registrar
    deploy_txn_hash = self.RegistrarFactory.deploy()
/usr/local/lib/python2.7/site-packages/populus/chain.py:206: in RegistrarFactory
    return get_registrar(self.web3)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

web3 = <web3.main.Web3 object at 0x10db60f50>, address = None

    def get_registrar(web3, address=None):
        registrar_contract_data = get_compiled_registrar_contract()
        return web3.eth.contract(
            address=address,
            abi=registrar_contract_data['abi'],
>           code=registrar_contract_data['code'],
            code_runtime=registrar_contract_data['code_runtime'],
        )
E       KeyError: 'code'

/usr/local/lib/python2.7/site-packages/populus/migrations/registrar.py:51: KeyError
__________________________________________________________________________ test_custom_greeting __________________________________________________________________________

chain = <populus.chain.EthereumTesterChain object at 0x10df08d10>

    def test_custom_greeting(chain):
>       greeter = chain.get_contract('Greeter')

tests/test_greeter.py:9:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/usr/local/lib/python2.7/site-packages/populus/chain.py:566: in get_contract
    registrar = self.registrar
/usr/local/lib/python2.7/site-packages/populus/utils/functional.py:50: in __get__
    res = instance.__dict__[self.name] = self.func(instance)
/usr/local/lib/python2.7/site-packages/populus/chain.py:533: in registrar
    deploy_txn_hash = self.RegistrarFactory.deploy()
/usr/local/lib/python2.7/site-packages/populus/chain.py:206: in RegistrarFactory
    return get_registrar(self.web3)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

web3 = <web3.main.Web3 object at 0x10df08c90>, address = None

    def get_registrar(web3, address=None):
        registrar_contract_data = get_compiled_registrar_contract()
        return web3.eth.contract(
            address=address,
            abi=registrar_contract_data['abi'],
>           code=registrar_contract_data['code'],
            code_runtime=registrar_contract_data['code_runtime'],
        )
E       KeyError: 'code'

/usr/local/lib/python2.7/site-packages/populus/migrations/registrar.py:51: KeyError

As recommendation Version 0.6 is downloaded from here: https://github.com/pipermerriam/py-solc/tree/v0.6.0 and inside downloaded folder I did: python setup.py install. Also py-solc version 0.9 and 0.9.1 is tried.

I would so grateful if you could help me to solve this problem.

  • 1
    I bet my left testicle this is some sort of version incompatibility issue. I poked Piper on Gitter.im chat gitter.im/pipermerriam/populus to see if he can confirm this issue. – Mikko Ohtamaa Jan 18 '17 at 16:45
  • Yes, If you pin py-solc<=1.7.0 things should start working. Alternatively you can be brave and start using populus==1.5.0-beta.1. – Piper Merriam Jan 19 '17 at 4:08
  • I did pip install py-solc==0.9.1 and it works. – alper Jan 20 '17 at 11:07
1

Just adding the answer from the above comments, so that this question can be closed:

sudo pip install --upgrade populus should solve this problem. Although no one is likely to have this specific issue anymore.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.