Files
smom-dbis-138/test/AggregatorFuzz.t.sol
defiQUG 1fb7266469 Add Oracle Aggregator and CCIP Integration
- Introduced Aggregator.sol for Chainlink-compatible oracle functionality, including round-based updates and access control.
- Added OracleWithCCIP.sol to extend Aggregator with CCIP cross-chain messaging capabilities.
- Created .gitmodules to include OpenZeppelin contracts as a submodule.
- Developed a comprehensive deployment guide in NEXT_STEPS_COMPLETE_GUIDE.md for Phase 2 and smart contract deployment.
- Implemented Vite configuration for the orchestration portal, supporting both Vue and React frameworks.
- Added server-side logic for the Multi-Cloud Orchestration Portal, including API endpoints for environment management and monitoring.
- Created scripts for resource import and usage validation across non-US regions.
- Added tests for CCIP error handling and integration to ensure robust functionality.
- Included various new files and directories for the orchestration portal and deployment scripts.
2025-12-12 14:57:48 -08:00

83 lines
2.4 KiB
Solidity

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;
import "forge-std/Test.sol";
import "../contracts/oracle/Aggregator.sol";
contract AggregatorFuzzTest is Test {
Aggregator aggregator;
address admin;
address transmitter;
address user;
function setUp() public {
admin = address(1);
transmitter = address(2);
user = address(3);
vm.prank(admin);
aggregator = new Aggregator(
"ETH/USD Price Feed",
admin,
60, // heartbeat: 60 seconds
50 // deviationThreshold: 0.5% (50 basis points)
);
vm.prank(admin);
aggregator.addTransmitter(transmitter);
}
function testFuzzUpdateAnswer(uint256 answer) public {
vm.assume(answer > 0);
vm.assume(answer < type(uint256).max / 100000000); // Prevent overflow
vm.prank(transmitter);
aggregator.updateAnswer(answer);
assertEq(aggregator.latestAnswer(), int256(answer));
}
function testFuzzMultipleUpdates(uint256[10] memory answers) public {
for (uint i = 0; i < answers.length; i++) {
vm.assume(answers[i] > 0);
vm.assume(answers[i] < type(uint256).max / 100000000);
vm.prank(transmitter);
aggregator.updateAnswer(answers[i]);
assertEq(aggregator.latestAnswer(), int256(answers[i]));
}
}
function testFuzzAddTransmitter(address newTransmitter) public {
vm.assume(newTransmitter != address(0));
vm.assume(newTransmitter != admin);
vm.assume(newTransmitter != transmitter);
vm.prank(admin);
aggregator.addTransmitter(newTransmitter);
assertTrue(aggregator.isTransmitter(newTransmitter));
}
function testFuzzSetHeartbeat(uint256 heartbeat) public {
vm.assume(heartbeat > 0);
vm.assume(heartbeat < type(uint256).max / 2);
vm.prank(admin);
aggregator.updateHeartbeat(heartbeat);
assertEq(aggregator.heartbeat(), heartbeat);
}
function testFuzzSetDeviationThreshold(uint256 threshold) public {
vm.assume(threshold <= 10000); // Max 100%
vm.prank(admin);
aggregator.updateDeviationThreshold(threshold);
assertEq(aggregator.deviationThreshold(), threshold);
}
}