布朗尼本地测试与Ganache失败
遵循Bootcamp Day2 Video中有关与布朗尼测试坚固合同的步骤,我在本地测试Chainlink-Mix脚本时偶然发现了错误。
Here are the steps are taken to introduce the error:
- execute brownie compile
- execute genache-cli in separate terminal
- execute brownie run scripts/price_feed_scripts/01_deploy_price_consumer_v3.py
- brownie run scripts/price_feed_scripts/02_read_price_feed.py
ganache is selected as the default network and the server在IP/端口127.0.0.1:8545上聆听。
brownie run scripts/price_feed_scripts/02_read_price_feed.py
Brownie v1.18.1 - Python development framework for Ethereum
ChainlinkMixProject is the active project.
/usr/local/lib/python3.9/site-packages/brownie/network/main.py:44: BrownieEnvironmentWarning: Development network has a block height of 14
warnings.warn(
Attached to local RPC client listening at '127.0.0.1:8545'...
Running 'scripts/price_feed_scripts/02_read_price_feed.py::main'...
<brownie.network.contract.ContractContainer object at 0x10e410dc0>
File "brownie/_cli/run.py", line 51, in main
return_value, frame = run(
File "brownie/project/scripts.py", line 103, in run
return_value = f_locals[method_name](*args, **kwargs)
File "./scripts/price_feed_scripts/02_read_price_feed.py", line 7, in main
price_feed_contract = PriceFeedConsumer[-1]
File "brownie/network/contract.py", line 175, in __getitem__
return self._contracts[i]
IndexError: list index out of range
Ganache在Brownie-Config.yaml中设置为默认网络
Following the steps taken in the bootcamp day2 video on testing solidity contracts with brownie, I stumbled upon an error when testing the chainlink-mix scripts locally.
Here are the steps are taken to introduce the error:
- execute brownie compile
- execute genache-cli in separate terminal
- execute brownie run scripts/price_feed_scripts/01_deploy_price_consumer_v3.py
- brownie run scripts/price_feed_scripts/02_read_price_feed.py
ganache is selected as the default network and the server is listening on the ip/port 127.0.0.1:8545.
brownie run scripts/price_feed_scripts/02_read_price_feed.py
Brownie v1.18.1 - Python development framework for Ethereum
ChainlinkMixProject is the active project.
/usr/local/lib/python3.9/site-packages/brownie/network/main.py:44: BrownieEnvironmentWarning: Development network has a block height of 14
warnings.warn(
Attached to local RPC client listening at '127.0.0.1:8545'...
Running 'scripts/price_feed_scripts/02_read_price_feed.py::main'...
<brownie.network.contract.ContractContainer object at 0x10e410dc0>
File "brownie/_cli/run.py", line 51, in main
return_value, frame = run(
File "brownie/project/scripts.py", line 103, in run
return_value = f_locals[method_name](*args, **kwargs)
File "./scripts/price_feed_scripts/02_read_price_feed.py", line 7, in main
price_feed_contract = PriceFeedConsumer[-1]
File "brownie/network/contract.py", line 175, in __getitem__
return self._contracts[i]
IndexError: list index out of range
ganache is set as default network in the brownie-config.yaml
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
默认情况下,布朗尼不会将已部署的合同的位置保存到本地运行链中,因为它们经常被删除,并且会占用大量空间,因此您必须告诉布朗尼以记住部署到Ganache的东西。
在您的
Brownie-config.yaml
添加和重新运行脚本中
Brownie doesn't save the location of deployed contracts to a local running chain by default since they get deleted so often and would take up a ton of space, so you have to tell brownie to remember stuff deployed to ganache.
In your
brownie-config.yaml
addAnd rerun your scripts