chore: sync submodule state (parent ref update)
Made-with: Cursor
This commit is contained in:
@@ -11,8 +11,11 @@ contract XAUOracleTest is Test {
|
||||
Aggregator public feed2;
|
||||
|
||||
address public admin = address(0x1);
|
||||
uint256 public constant PRICE1 = 0.05e18; // 1 ETH = 0.05 oz XAU
|
||||
uint256 public constant PRICE2 = 0.051e18; // 1 ETH = 0.051 oz XAU
|
||||
// Aggregator has decimals=8; use 8-decimal prices (0.05 -> 5e6)
|
||||
uint256 public constant PRICE1 = 5e6; // 0.05 oz XAU in 8 decimals
|
||||
uint256 public constant PRICE2 = 51e5; // 0.051 oz XAU in 8 decimals
|
||||
// Expected 18-decimal price: 0.0505 -> 5.05e16
|
||||
uint256 public constant EXPECTED_AVG_18 = 505e14; // (PRICE1+PRICE2)/2 converted to 18 decimals
|
||||
|
||||
function setUp() public {
|
||||
vm.startPrank(admin);
|
||||
@@ -26,7 +29,7 @@ contract XAUOracleTest is Test {
|
||||
feed1.addTransmitter(admin);
|
||||
feed2.addTransmitter(admin);
|
||||
|
||||
// Update feeds
|
||||
// Update feeds (8-decimal values)
|
||||
feed1.updateAnswer(PRICE1);
|
||||
feed2.updateAnswer(PRICE2);
|
||||
|
||||
@@ -45,8 +48,8 @@ contract XAUOracleTest is Test {
|
||||
|
||||
assertGt(price, 0);
|
||||
assertGt(timestamp, 0);
|
||||
// Price should be weighted average: (PRICE1 + PRICE2) / 2
|
||||
assertApproxEqAbs(price, (PRICE1 + PRICE2) / 2, 1e15); // Allow small rounding error
|
||||
// Price should be weighted average: (PRICE1 + PRICE2) / 2, converted to 18 decimals
|
||||
assertApproxEqAbs(price, EXPECTED_AVG_18, 1e15); // Allow small rounding error
|
||||
}
|
||||
|
||||
function test_UpdatePrice() public {
|
||||
@@ -58,15 +61,15 @@ contract XAUOracleTest is Test {
|
||||
}
|
||||
|
||||
function test_AddPriceFeed() public {
|
||||
vm.startPrank(admin);
|
||||
Aggregator feed3 = new Aggregator("ETH/XAU Feed 3", admin, 3600, 50);
|
||||
feed3.addTransmitter(admin);
|
||||
feed3.updateAnswer(PRICE1);
|
||||
|
||||
vm.prank(admin);
|
||||
oracle.addPriceFeed(address(feed3), 3333); // 33.33%
|
||||
|
||||
vm.prank(admin);
|
||||
oracle.updatePrice();
|
||||
vm.stopPrank();
|
||||
|
||||
(uint256 price, ) = oracle.getETHPriceInXAU();
|
||||
assertGt(price, 0);
|
||||
|
||||
Reference in New Issue
Block a user