diff --git a/test/fork/adapters/UnionSourceAdapter.sol b/test/fork/adapters/UnionSourceAdapter.sol index ca0e14b..e04c80e 100644 --- a/test/fork/adapters/UnionSourceAdapter.sol +++ b/test/fork/adapters/UnionSourceAdapter.sol @@ -165,9 +165,9 @@ contract UnionSourceAdapterTest is CommonTest { function testLookbackDropChronicle() public { // Fork to a block where chronicle was the newest. vm.createSelectFork("mainnet", targetChronicleBlock); + _whitelistOnChronicle(); uint256 targetTimestamp = block.timestamp; sourceAdapter.setMaxAge(2 days); // Set max age to 2 days to disable this logic for the test. - _whitelistOnChronicle(); // Snapshotting union adapter should not affect historical lookups, but we do it just to prove it does not interfere. sourceAdapter.snapshotData(); diff --git a/test/unit/BaseController.sol b/test/unit/BaseController.sol index 7a2083c..b00abe6 100644 --- a/test/unit/BaseController.sol +++ b/test/unit/BaseController.sol @@ -16,6 +16,8 @@ contract BaseControllerTest is CommonTest { TestBaseController baseController; function setUp() public { + vm.warp(lastUnlockTime); + vm.startPrank(owner); baseController = new TestBaseController(18); baseController.setUnlocker(permissionedUnlocker, true); diff --git a/test/unit/SnapshotSource.SnapshotData.sol b/test/unit/SnapshotSource.SnapshotData.sol index f5b501f..576e939 100644 --- a/test/unit/SnapshotSource.SnapshotData.sol +++ b/test/unit/SnapshotSource.SnapshotData.sol @@ -78,38 +78,39 @@ contract SnapshotSourceSnapshotDataTest is CommonTest { function testMaxAgeIsRespected() public { // Set maxAge to 2000 for testing + vm.warp(10000); snapshotSource.setMaxAge(2000); // Publish data at different timestamps - vm.warp(1000); - snapshotSource.publishSourceData(100, 1000); + vm.warp(11000); + snapshotSource.publishSourceData(100, 11000); snapshotSource.snapshotData(); - vm.warp(2000); - snapshotSource.publishSourceData(200, 2000); + vm.warp(12000); + snapshotSource.publishSourceData(200, 12000); snapshotSource.snapshotData(); - vm.warp(3000); - snapshotSource.publishSourceData(300, 3000); + vm.warp(13000); + snapshotSource.publishSourceData(300, 13000); snapshotSource.snapshotData(); - vm.warp(4000); - snapshotSource.publishSourceData(400, 4000); + vm.warp(14000); + snapshotSource.publishSourceData(400, 14000); snapshotSource.snapshotData(); // Verify behavior when requesting data within the maxAge limit - (int256 answerAt4000, uint256 timestampAt4000,) = snapshotSource.tryLatestDataAt(4000, 10); - assertTrue(answerAt4000 == 400 && timestampAt4000 == 4000); + (int256 answerAt14000, uint256 timestampAt14000,) = snapshotSource.tryLatestDataAt(14000, 10); + assertTrue(answerAt14000 == 400 && timestampAt14000 == 14000); - (int256 answerAt3000, uint256 timestampAt3000,) = snapshotSource.tryLatestDataAt(3000, 10); - assertTrue(answerAt3000 == 300 && timestampAt3000 == 3000); + (int256 answerAt13000, uint256 timestampAt13000,) = snapshotSource.tryLatestDataAt(13000, 10); + assertTrue(answerAt13000 == 300 && timestampAt13000 == 13000); // Request data at the limit of maxAge should still work. - (int256 answerAt2000, uint256 timestampAt2000,) = snapshotSource.tryLatestDataAt(2000, 10); - assertTrue(answerAt2000 == 200 && timestampAt2000 == 2000); + (int256 answerAt12000, uint256 timestampAt12000,) = snapshotSource.tryLatestDataAt(12000, 10); + assertTrue(answerAt12000 == 200 && timestampAt12000 == 12000); - // Request data older than maxAge (1000), should get the latest available data at 4000. - (int256 answerAt1000, uint256 timestampAt1000,) = snapshotSource.tryLatestDataAt(1000, 10); - assertTrue(answerAt1000 == 400 && timestampAt1000 == 4000); + // Request data older than maxAge (1000), should get the latest available data at 14000. + (int256 answerAt11000, uint256 timestampAt11000,) = snapshotSource.tryLatestDataAt(11000, 10); + assertTrue(answerAt11000 == 400 && timestampAt11000 == 14000); } }