infrastructure-upgrade/lib/v3-core/contracts/test/BitMathEchidnaTest.sol
T-Hax 735546619e
init
Signed-off-by: T-Hax <>
2023-04-08 18:46:18 +00:00

19 lines
606 B
Solidity

// SPDX-License-Identifier: UNLICENSED
pragma solidity =0.7.6;
import '../libraries/BitMath.sol';
contract BitMathEchidnaTest {
function mostSignificantBitInvariant(uint256 input) external pure {
uint8 msb = BitMath.mostSignificantBit(input);
assert(input >= (uint256(2)**msb));
assert(msb == 255 || input < uint256(2)**(msb + 1));
}
function leastSignificantBitInvariant(uint256 input) external pure {
uint8 lsb = BitMath.leastSignificantBit(input);
assert(input & (uint256(2)**lsb) != 0);
assert(input & (uint256(2)**lsb - 1) == 0);
}
}