Skip to content

Commit

Permalink
test(feed): check that answer is not stale
Browse files Browse the repository at this point in the history
  • Loading branch information
arthurka-o committed May 22, 2024
1 parent b79c738 commit 7f5a9ab
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions tests/feeds/chainlink/TruflationFeed.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -129,4 +129,21 @@ contract TruflationFeedTest is Test {
assertLt(data.priceOverMacroWindow, config.macroWindowCeiling);
}
}

function test_AnswerValueIsNotStale() public {
(uint80 latestRoundId,,,,) = feed.latestRoundData();
int256 answer;
int256 previousAnswer = type(int256).max;

for (uint80 index = latestRoundId; index > latestRoundId - config.roundCount; index--) {
(, answer,,,) = feed.getRoundData(index);

console2.log("Round ID: ", index);
console2.log("Answer: ", answer);
console2.log("-----------------");

assertNotEq(answer, previousAnswer);
previousAnswer = answer;
}
}
}

0 comments on commit 7f5a9ab

Please sign in to comment.