Skip to content

Commit

Permalink
test: track latest published round id
Browse files Browse the repository at this point in the history
Signed-off-by: Reinis Martinsons <reinis@umaproject.org>
  • Loading branch information
Reinis-FRP committed May 10, 2024
1 parent 3518ea2 commit bbd4af5
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions test/unit/Oval.ChainlinkDestinationAdapter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ contract OvalChainlinkDestinationAdapter is CommonTest {

TestOval oval;

uint256 latestPublishedRound;

function setUp() public {
vm.warp(initialTimestamp);

Expand All @@ -33,7 +35,12 @@ contract OvalChainlinkDestinationAdapter is CommonTest {
oval.setUnlocker(permissionedUnlocker, true);
vm.stopPrank();

oval.publishRoundData(initialPrice, initialTimestamp);
publishRoundData(initialPrice, initialTimestamp);
}

function publishRoundData(int256 answer, uint256 timestamp) public {
oval.publishRoundData(answer, timestamp);
++latestPublishedRound;
}

function verifyOvalMatchesOval() public {
Expand All @@ -53,7 +60,7 @@ contract OvalChainlinkDestinationAdapter is CommonTest {

function testUpdatesWithinLockWindow() public {
// Publish an update to the mock source adapter.
oval.publishRoundData(newAnswer, newTimestamp);
publishRoundData(newAnswer, newTimestamp);

syncOvalWithOval();
assertTrue(oval.lastUnlockTime() == block.timestamp);
Expand All @@ -72,10 +79,10 @@ contract OvalChainlinkDestinationAdapter is CommonTest {
oval.latestRoundData();

// Check that Oval return the correct values scaled to the source oracle decimals.
assertTrue(roundId == 2); // We published twice and roundId starts at 1.
assertTrue(roundId == latestPublishedRound);
assertTrue(answer == newAnswer / internalDecimalsToSourceDecimals);
assertTrue(startedAt == newTimestamp);
assertTrue(updatedAt == newTimestamp);
assertTrue(answeredInRound == 2); // We published twice and roundId starts at 1.
assertTrue(answeredInRound == latestPublishedRound);
}
}

0 comments on commit bbd4af5

Please sign in to comment.