Skip to content

Commit

Permalink
add view function of heartbeat
Browse files Browse the repository at this point in the history
  • Loading branch information
traceurl committed Dec 23, 2023
1 parent 309b54f commit 78c5cb6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
5 changes: 5 additions & 0 deletions contracts/DODOV3MM/D3Pool/D3Maker.sol
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,11 @@ contract D3Maker is InitializableOwnable {
}
}

function getHeartbeat() external view returns (uint256 lastHeartBeat, uint256 maxInterval) {
lastHeartBeat = state.heartBeat.lastHeartBeat;
maxInterval = state.heartBeat.maxInterval;
}

function getPoolTokenListFromMaker() external view returns(address[] memory tokenlist) {
return poolTokenlist;
}
Expand Down
8 changes: 8 additions & 0 deletions test/DODOV3MM/D3MM/D3Maker.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,10 @@ contract MakerTest is TestContext {
d3Maker.setNewToken(
address(token1), true, token1Info.priceInfo, token1Info.amountInfo, token1Info.kAsk, token1Info.kBid
);

(uint256 lastHeartBeat, uint256 maxInterval) = d3Maker.getHeartbeat();
assertEq(lastHeartBeat, block.timestamp);
assertEq(maxInterval, 100000);
}

function testCallInvalidToken() public {
Expand Down Expand Up @@ -432,6 +436,10 @@ contract MakerTest is TestContext {
vm.prank(owner);
d3Maker.setHeartbeat(300);

(uint256 lastHeartBeat, uint256 maxInterval) = d3Maker.getHeartbeat();
assertEq(lastHeartBeat, block.timestamp);
assertEq(maxInterval, 300);

vm.warp(302);
checkHB = d3Maker.checkHeartbeat();
assertEq(checkHB, false);
Expand Down

0 comments on commit 78c5cb6

Please sign in to comment.