Optimize Math operations using branchless bool to uint translation. (#4878)

Co-authored-by: Hadrien Croubois <hadrien.croubois@gmail.com>
Co-authored-by: ernestognw <ernestognw@gmail.com>
This commit is contained in:
Igor Żuk
2024-02-07 10:20:25 +01:00
committed by GitHub
parent 0a757ec463
commit 17a8955cd8
5 changed files with 94 additions and 62 deletions

View File

@ -146,4 +146,14 @@ describe('SafeCast', function () {
.withArgs(ethers.MaxUint256);
});
});
describe('toUint (bool)', function () {
it('toUint(false) should be 0', async function () {
expect(await this.mock.$toUint(false)).to.equal(0n);
});
it('toUint(true) should be 1', async function () {
expect(await this.mock.$toUint(true)).to.equal(1n);
});
});
});