Greeter
在 Populus 上,由於 py.test,我無法進行基本測試(問候契約)
我無法使以下基本測試範例在楊樹上工作。
- 平台 darwin——Python 2.7.10、pytest-3.0.5、py-1.4.32、pluggy-0.4.0 rootdir:/Users/avatar/populus、inifile:
- 外掛:popup-1.4.2
- 作業系統:在 mac OS 和 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 ...
出現以下錯誤:
_____ 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
作為推薦版本 0.6 從這裡下載:https ://github.com/pipermerriam/py-solc/tree/v0.6.0並在下載的文件夾中我做了:
python setup.py install
。還py-solc
嘗試了 0.9 和 0.9.1 版本。如果您能幫助我解決這個問題,我將不勝感激。
只需從上述評論中添加答案,以便可以關閉此問題:
sudo pip install --upgrade populus
應該解決這個問題。儘管沒有人可能再遇到這個特定問題了。