mirror of
https://github.com/logos-messaging/logos-messaging-rlnv2-contract.git
synced 2026-01-07 08:23:09 +00:00
define period boundaries: start inclusive, end exclusive
This commit is contained in:
parent
0201d38f6f
commit
018ba1c9d2
@ -296,11 +296,11 @@ abstract contract MembershipUpgradeable is Initializable {
|
||||
}
|
||||
|
||||
/// @dev Determine whether the current timestamp is within a given period
|
||||
/// @param _start timestamp in which the period starts
|
||||
/// @param _duration duration of the period
|
||||
/// @param _start timestamp in which the period starts (inclusive)
|
||||
/// @param _duration duration of the period (end timestamp exclusive)
|
||||
function _isInPeriod(uint256 _start, uint32 _duration) internal view returns (bool) {
|
||||
uint256 timeNow = block.timestamp;
|
||||
return (_start <= timeNow && timeNow <= _start + uint256(_duration));
|
||||
return (_start <= timeNow && timeNow < _start + uint256(_duration));
|
||||
}
|
||||
|
||||
/// @notice Determine if a membership is expired
|
||||
@ -311,11 +311,11 @@ abstract contract MembershipUpgradeable is Initializable {
|
||||
}
|
||||
|
||||
/// @dev Determine whether the current timestamp is after a given period
|
||||
/// @param _start timestamp in which the period starts
|
||||
/// @param _duration duration of the period
|
||||
/// @param _start timestamp in which the period starts (inclusive)
|
||||
/// @param _duration duration of the period (end timestamp exclusive)
|
||||
function _isAfterPeriod(uint256 _start, uint32 _duration) internal view returns (bool) {
|
||||
uint256 timeNow = block.timestamp;
|
||||
return (_start + uint256(_duration) < timeNow);
|
||||
return (_timestampAfterPeriod(_start, _duration) <= timeNow);
|
||||
}
|
||||
|
||||
/// @notice Returns the timestamp on which a membership can be considered expired (i.e. when its grace period ends)
|
||||
@ -326,10 +326,10 @@ abstract contract MembershipUpgradeable is Initializable {
|
||||
}
|
||||
|
||||
/// @dev Returns the first timestamp after a specified period
|
||||
/// @param _start timestamp in which the period starts
|
||||
/// @param _duration duration of the period
|
||||
/// @param _start timestamp in which the period starts (inclusive)
|
||||
/// @param _duration duration of the period (exclusive)
|
||||
function _timestampAfterPeriod(uint256 _start, uint32 _duration) internal pure returns (uint256) {
|
||||
return _start + uint256(_duration) + 1;
|
||||
return _start + uint256(_duration);
|
||||
}
|
||||
|
||||
/// @dev Withdraw any available deposit balance in tokens after a membership is erased.
|
||||
|
||||
@ -268,7 +268,7 @@ contract WakuRlnV2Test is Test {
|
||||
w.extendMemberships(commitmentsToExtend);
|
||||
|
||||
(,, uint256 newGracePeriodStartTimestamp, uint32 newGracePeriodDuration,,,,) = w.memberships(idCommitment);
|
||||
uint256 expectedExpirationTimestamp = newGracePeriodStartTimestamp + uint256(newGracePeriodDuration) + 1;
|
||||
uint256 expectedExpirationTimestamp = newGracePeriodStartTimestamp + uint256(newGracePeriodDuration);
|
||||
uint256 membershipExpirationTimestamp = w.membershipExpirationTimestamp(idCommitment);
|
||||
assertEq(expectedExpirationTimestamp, membershipExpirationTimestamp);
|
||||
assertTrue(expectedExpirationTimestamp > ogExpirationTimestamp);
|
||||
@ -289,7 +289,7 @@ contract WakuRlnV2Test is Test {
|
||||
|
||||
(,, uint256 fetchedgracePeriodStartTimestamp, uint32 fetchedGracePeriod,,,,) = w.memberships(idCommitment);
|
||||
|
||||
uint256 expectedExpirationTimestamp = fetchedgracePeriodStartTimestamp + uint256(fetchedGracePeriod) + 1;
|
||||
uint256 expectedExpirationTimestamp = fetchedgracePeriodStartTimestamp + uint256(fetchedGracePeriod);
|
||||
uint256 membershipExpirationTimestamp = w.membershipExpirationTimestamp(idCommitment);
|
||||
|
||||
assertEq(expectedExpirationTimestamp, membershipExpirationTimestamp);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user