Skip to content

Fix mock price feed deployment broadcasting - #47

Open
dkrithika wants to merge 1 commit into
smartcontractkit:mainfrom
dkrithika:improve-test-coverage
Open

Fix mock price feed deployment broadcasting#47
dkrithika wants to merge 1 commit into
smartcontractkit:mainfrom
dkrithika:improve-test-coverage

Conversation

@dkrithika

Copy link
Copy Markdown

Summary

The mock price feed was deployed before vm.startBroadcast() in PriceFeedConsumer.s.sol.

As a result, the mock deployment was not broadcast to the target network, while PriceFeedConsumer was deployed with the mock's address. This caused getPriceFeed() to return an address with no contract bytecode.

Root Cause

The deployment script previously called new MockV3Aggregator() before vm.startBroadcast().

This meant the mock was created during script execution but was not deployed as part of the broadcasted transactions.

Fix

Moved vm.startBroadcast() before the mock price feed deployment so that both the MockV3Aggregator and PriceFeedConsumer deployments are broadcast to the target network.

Verification

The issue was reproduced by calling getPriceFeed() and checking the returned address with cast code, which returned 0x, indicating that no contract bytecode existed at that address.

After the fix:

  • getPriceFeed() returned the deployed mock price feed address.
  • cast code on the returned address returned deployed contract bytecode.
  • getLatestPrice() returned 2000000000000000000000, corresponding to the expected 2000e18 mock price.
  • forge test passed.

@dkrithika
dkrithika requested review from a team, Nalon, andrejrakic and thodges-gh as code owners August 29, 2026 13:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant