Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C: QA & gas optimizations #6

Merged
merged 13 commits into from
Apr 5, 2022
340 changes: 168 additions & 172 deletions contracts/HolyPaladinToken.sol

Large diffs are not rendered by default.

38 changes: 19 additions & 19 deletions src/test/LockingHPAL.test.sol
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ contract LockingHPALTest is DSTest {

if(amount == 0){
vm.expectRevert(
bytes("hPAL: Null amount")
bytes4(keccak256(bytes("NullAmount()")))
);
vm.prank(locker);
hpal.lock(amount, lockDuration);
Expand All @@ -87,7 +87,7 @@ contract LockingHPALTest is DSTest {
}
else if(amount > stakingAmount) {
vm.expectRevert(
bytes("hPAL: Amount over balance")
bytes4(keccak256(bytes("AmountExceedBalance()")))
);
vm.prank(locker);
hpal.lock(amount, lockDuration);
Expand Down Expand Up @@ -145,7 +145,7 @@ contract LockingHPALTest is DSTest {

if(amount == 0){
vm.expectRevert(
bytes("hPAL: Null amount")
bytes4(keccak256(bytes("NullAmount()")))
);
vm.prank(locker);
hpal.lock(amount, lockDuration);
Expand All @@ -161,7 +161,7 @@ contract LockingHPALTest is DSTest {
}
else if(amount > stakingAmount) {
vm.expectRevert(
bytes("hPAL: Amount over balance")
bytes4(keccak256(bytes("AmountExceedBalance()")))
);
vm.prank(locker);
hpal.lock(amount, lockDuration);
Expand All @@ -177,7 +177,7 @@ contract LockingHPALTest is DSTest {
}
else if(amount < lockAmount) {
vm.expectRevert(
bytes("hPAL: smaller amount")
bytes4(keccak256(bytes("SmallerAmount()")))
);
vm.prank(locker);
hpal.lock(amount, lockDuration);
Expand Down Expand Up @@ -229,7 +229,7 @@ contract LockingHPALTest is DSTest {

if(duration < hpal.MIN_LOCK_DURATION()){
vm.expectRevert(
bytes("hPAL: Lock duration under min")
bytes4(keccak256(bytes("DurationUnderMin()")))
);
vm.prank(locker);
hpal.lock(lockAmount, duration);
Expand All @@ -245,7 +245,7 @@ contract LockingHPALTest is DSTest {
}
else if(duration > hpal.MAX_LOCK_DURATION()) {
vm.expectRevert(
bytes("hPAL: Lock duration over max")
bytes4(keccak256(bytes("DurationOverMax()")))
);
vm.prank(locker);
hpal.lock(lockAmount, duration);
Expand Down Expand Up @@ -303,7 +303,7 @@ contract LockingHPALTest is DSTest {

if(duration < hpal.MIN_LOCK_DURATION()){
vm.expectRevert(
bytes("hPAL: Lock duration under min")
bytes4(keccak256(bytes("DurationUnderMin()")))
);
vm.prank(locker);
hpal.lock(lockAmount, duration);
Expand All @@ -319,7 +319,7 @@ contract LockingHPALTest is DSTest {
}
else if(duration > hpal.MAX_LOCK_DURATION()) {
vm.expectRevert(
bytes("hPAL: Lock duration over max")
bytes4(keccak256(bytes("DurationOverMax()")))
);
vm.prank(locker);
hpal.lock(lockAmount, duration);
Expand All @@ -335,7 +335,7 @@ contract LockingHPALTest is DSTest {
}
else if(duration < lockDuration) {
vm.expectRevert(
bytes("hPAL: smaller duration")
bytes4(keccak256(bytes("SmallerDuration()")))
);
vm.prank(locker);
hpal.lock(lockAmount, duration);
Expand Down Expand Up @@ -393,7 +393,7 @@ contract LockingHPALTest is DSTest {

if(amount == 0){
vm.expectRevert(
bytes("hPAL: Null amount")
bytes4(keccak256(bytes("NullAmount()")))
);
vm.prank(locker);
hpal.increaseLock(amount);
Expand All @@ -409,7 +409,7 @@ contract LockingHPALTest is DSTest {
}
else if(amount > stakingAmount) {
vm.expectRevert(
bytes("hPAL: Amount over balance")
bytes4(keccak256(bytes("AmountExceedBalance()")))
);
vm.prank(locker);
hpal.increaseLock(amount);
Expand All @@ -425,7 +425,7 @@ contract LockingHPALTest is DSTest {
}
else if(amount < lockAmount) {
vm.expectRevert(
bytes("hPAL: smaller amount")
bytes4(keccak256(bytes("SmallerAmount()")))
);
vm.prank(locker);
hpal.increaseLock(amount);
Expand Down Expand Up @@ -483,7 +483,7 @@ contract LockingHPALTest is DSTest {

if(duration < hpal.MIN_LOCK_DURATION()){
vm.expectRevert(
bytes("hPAL: Lock duration under min")
bytes4(keccak256(bytes("DurationUnderMin()")))
);
vm.prank(locker);
hpal.increaseLockDuration(duration);
Expand All @@ -499,7 +499,7 @@ contract LockingHPALTest is DSTest {
}
else if(duration > hpal.MAX_LOCK_DURATION()) {
vm.expectRevert(
bytes("hPAL: Lock duration over max")
bytes4(keccak256(bytes("DurationOverMax()")))
);
vm.prank(locker);
hpal.increaseLockDuration(duration);
Expand All @@ -515,7 +515,7 @@ contract LockingHPALTest is DSTest {
}
else if(duration < lockDuration) {
vm.expectRevert(
bytes("hPAL: smaller duration")
bytes4(keccak256(bytes("SmallerDuration()")))
);
vm.prank(locker);
hpal.increaseLockDuration(duration);
Expand Down Expand Up @@ -659,7 +659,7 @@ contract LockingHPALTest is DSTest {

if(amount == 0){
vm.expectRevert(
bytes("hPAL: Null amount")
bytes4(keccak256(bytes("NullAmount()")))
);
vm.prank(locker);
hpal.stakeAndLock(amount, 31536000);
Expand Down Expand Up @@ -760,7 +760,7 @@ contract LockingHPALTest is DSTest {

if(amount == 0){
vm.expectRevert(
bytes("hPAL: Null amount")
bytes4(keccak256(bytes("NullAmount()")))
);
vm.prank(locker);
hpal.stakeAndIncreaseLock(amount, 31536000);
Expand Down Expand Up @@ -850,7 +850,7 @@ contract LockingHPALTest is DSTest {

if(amount > previousAvailableBalanceLocker) {
vm.expectRevert(
bytes("hPAL: Available balance too low")
bytes4(keccak256(bytes("AvailableBalanceTooLow()")))
);
vm.prank(locker);
hpal.transfer(receiver, amount);
Expand Down
8 changes: 4 additions & 4 deletions src/test/StakingHPAL.test.sol
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ contract StakingHPALTest is DSTest {

if(amount == 0){
vm.expectRevert(
bytes("hPAL: Null amount")
bytes4(keccak256(bytes("NullAmount()")))
);
vm.prank(staker);
hpal.stake(amount);
Expand Down Expand Up @@ -148,7 +148,7 @@ contract StakingHPALTest is DSTest {

if(amount == 0){
vm.expectRevert(
bytes("hPAL: Null amount")
bytes4(keccak256(bytes("NullAmount()")))
);
vm.prank(staker);
hpal.unstake(amount, staker);
Expand Down Expand Up @@ -232,7 +232,7 @@ contract StakingHPALTest is DSTest {

if(amount == 0){
vm.expectRevert(
bytes("hPAL: incorrect amount")
bytes4(keccak256(bytes("IncorrectAmount()")))
);
vm.prank(staker);
hpal.claim(amount);
Expand Down Expand Up @@ -297,7 +297,7 @@ contract StakingHPALTest is DSTest {

if(amount > stakingAmount) {
vm.expectRevert(
bytes("hPAL: Available balance too low")
bytes4(keccak256(bytes("AvailableBalanceTooLow()")))
);
vm.prank(staker);
hpal.transfer(receiver, amount);
Expand Down
26 changes: 13 additions & 13 deletions test/0_HPAL_staking.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ describe('HolyPaladinToken contract tests - Base & Staking', () => {
expect(await hPAL.smartWalletChecker()).to.be.eq(ethers.constants.AddressZero)
expect(await hPAL.futureSmartWalletChecker()).to.be.eq(ethers.constants.AddressZero)

expect(await hPAL.kickRatioPerWeek()).to.be.eq(1000)
expect(await hPAL.kickRatioPerWeek()).to.be.eq(100)
expect(await hPAL.bonusLockVoteRatio()).to.be.eq(ethers.utils.parseEther('0.5'))
expect(await hPAL.emergency()).to.be.false

Expand Down Expand Up @@ -192,7 +192,7 @@ describe('HolyPaladinToken contract tests - Base & Staking', () => {

await expect(
hPAL.connect(user1).stake(0)
).to.be.revertedWith('hPAL: Null amount')
).to.be.revertedWith('NullAmount')

});

Expand Down Expand Up @@ -402,7 +402,7 @@ describe('HolyPaladinToken contract tests - Base & Staking', () => {

await expect(
hPAL.connect(user2).transfer(user1.address, amount)
).to.be.revertedWith('hPAL: Available balance too low')
).to.be.revertedWith('AvailableBalanceTooLow')

});

Expand Down Expand Up @@ -489,7 +489,7 @@ describe('HolyPaladinToken contract tests - Base & Staking', () => {

await expect(
hPAL.connect(user1).transferFrom(user2.address, user1.address, amount)
).to.be.revertedWith('hPAL: Available balance too low')
).to.be.revertedWith('AvailableBalanceTooLow')

});

Expand Down Expand Up @@ -803,7 +803,7 @@ describe('HolyPaladinToken contract tests - Base & Staking', () => {

await expect(
hPAL.getPastVotes(user2.address, currentBlock + 1000)
).to.be.revertedWith('hPAL: invalid blockNumber')
).to.be.revertedWith('InvalidBlockNumber')

});

Expand Down Expand Up @@ -908,7 +908,7 @@ describe('HolyPaladinToken contract tests - Base & Staking', () => {

await expect(
hPAL.getPastDelegate(user1.address, currentBlock + 1000)
).to.be.revertedWith('hPAL: invalid blockNumber')
).to.be.revertedWith('InvalidBlockNumber')

});

Expand All @@ -934,7 +934,7 @@ describe('HolyPaladinToken contract tests - Base & Staking', () => {

await expect(
hPAL.connect(user1).unstake(unstake_amount, user1.address)
).to.be.revertedWith('hPAL: unstake period expired')
).to.be.revertedWith('UnstakePeriodExpired')

});

Expand All @@ -947,7 +947,7 @@ describe('HolyPaladinToken contract tests - Base & Staking', () => {

await expect(
hPAL.connect(user1).unstake(unstake_amount, user1.address)
).to.be.revertedWith('hPAL: Insufficient cooldown')
).to.be.revertedWith('InsufficientCooldown')

});

Expand Down Expand Up @@ -1021,7 +1021,7 @@ describe('HolyPaladinToken contract tests - Base & Staking', () => {

await expect(
hPAL.connect(user1).unstake(unstake_amount, user1.address)
).to.be.revertedWith('hPAL: unstake period expired')
).to.be.revertedWith('UnstakePeriodExpired')

});

Expand Down Expand Up @@ -1109,11 +1109,11 @@ describe('HolyPaladinToken contract tests - Base & Staking', () => {

await expect(
hPAL.connect(user1).unstake(0, user1.address)
).to.be.revertedWith('hPAL: Null amount')
).to.be.revertedWith('NullAmount')

await expect(
hPAL.connect(user1).unstake(unstake_amount, ethers.constants.AddressZero)
).to.be.revertedWith('hPAL: Address Zero')
).to.be.revertedWith('AddressZero')

});

Expand Down Expand Up @@ -1360,7 +1360,7 @@ describe('HolyPaladinToken contract tests - Base & Staking', () => {

await expect(
hPAL.connect(user2).cooldown()
).to.be.revertedWith('hPAL: No balance')
).to.be.revertedWith('NoBalance')

});

Expand Down Expand Up @@ -1552,7 +1552,7 @@ describe('HolyPaladinToken contract tests - Base & Staking', () => {

await expect(
hPAL.connect(user1).unstake(unstake_amount, user1.address)
).to.be.revertedWith('hPAL: Insufficient cooldown')
).to.be.revertedWith('InsufficientCooldown')

});

Expand Down
Loading