布朗尼本地测试与Ganache失败

发布于 2025-01-24 12:42:03 字数 1515 浏览 0 评论 0原文

遵循Bootcamp Day2 Video中有关与布朗尼测试坚固合同的步骤,我在本地测试Chainlink-Mix脚本时偶然发现了错误。

Here are the steps are taken to introduce the error:

  1. execute brownie compile
  2. execute genache-cli in separate terminal
  3. execute brownie run scripts/price_feed_scripts/01_deploy_price_consumer_v3.py
  4. 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:

  1. execute brownie compile
  2. execute genache-cli in separate terminal
  3. execute brownie run scripts/price_feed_scripts/01_deploy_price_consumer_v3.py
  4. 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

生死何惧 2025-01-31 12:42:03

默认情况下,布朗尼不会将已部署的合同的位置保存到本地运行链中,因为它们经常被删除,并且会占用大量空间,因此您必须告诉布朗尼以记住部署到Ganache的东西。

在您的Brownie-config.yaml添加

dev_deployment_artifacts: true

和重新运行脚本中

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 add

dev_deployment_artifacts: true

And rerun your scripts

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文