-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
94fa241
commit 99b0a63
Showing
3 changed files
with
66 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"feedAddress": "0x1594F325afc4f8dc4E4ad0A3F758f48B1F72930a", | ||
"heartbeat": 60, | ||
"macroWindowThreshold": 1, | ||
"microWindowThreshold": 1, | ||
"targetValue": 5 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
pragma solidity 0.8.10; | ||
|
||
import "forge-std/StdJson.sol"; | ||
import {Test, console2} from "forge-std/Test.sol"; | ||
import "@chainlink/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol"; | ||
|
||
contract TruflationFeedTest is Test { | ||
using stdJson for string; | ||
|
||
function append(string memory a, string memory b) internal pure returns (string memory) { | ||
return string(abi.encodePacked(a, b)); | ||
} | ||
|
||
struct JsonConfig { | ||
address feedAddress; | ||
uint256 heartbeat; | ||
uint256 macroWindowTreshold; | ||
uint256 microWindowTreshold; | ||
uint256 targetValue; | ||
} | ||
|
||
string truflationRPC; | ||
JsonConfig config; | ||
AggregatorV3Interface feed; | ||
|
||
function setUp() public { | ||
truflationRPC = vm.envString("TRUFLATION_RPC"); | ||
vm.createSelectFork(truflationRPC, 43_948_853); | ||
|
||
string memory root = vm.projectRoot(); | ||
string memory path = append(root, "/config/truflationFeed.json"); | ||
string memory json = vm.readFile(path); | ||
bytes memory jsonBytes = json.parseRaw(""); | ||
|
||
config = abi.decode(jsonBytes, (JsonConfig)); | ||
feed = AggregatorV3Interface(config.feedAddress); | ||
} | ||
|
||
function test() public { | ||
console2.log("Feed address: ", config.feedAddress); | ||
console2.log("Heartbeat: ", config.heartbeat); | ||
console2.log("Macro window treshold: ", config.macroWindowTreshold); | ||
console2.log("Micro window treshold: ", config.microWindowTreshold); | ||
console2.log("Target value: ", config.targetValue); | ||
} | ||
|
||
function testConsecutiveRoundId() public { | ||
(uint80 roundId,,,,) = feed.latestRoundData(); | ||
console2.log("Latest round id: ", roundId); | ||
console2.log("Current block number: ", block.number); | ||
|
||
vm.createSelectFork(truflationRPC, block.number + (5 * 60 * 60)); | ||
|
||
(uint80 nextRoundId,,,,) = feed.latestRoundData(); | ||
console2.log("Next round id: ", nextRoundId); | ||
console2.log("Current block number: ", block.number); | ||
} | ||
} |