Skip to content

Commit

Permalink
Fix code style issues with Prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
lint-action committed Sep 19, 2023
1 parent a6c8cc1 commit 5e19170
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 42 deletions.
4 changes: 2 additions & 2 deletions contracts/StableJoeStaking.sol
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,10 @@ contract StableJoeStaking is Initializable, OwnableUpgradeable {

/// @notice Accumulated `token` rewards per share, scaled to `ACC_REWARD_PER_SHARE_PRECISION`
mapping(IERC20Upgradeable => uint256) public accRewardPerShare;

// @dev gap to keep the storage ordering, replace `uint256 public DEPOSIT_FEE_PERCENT_PRECISION;`
uint256[1] private __gap3;

/// @notice The precision of `accRewardPerShare`
uint256 public constant ACC_REWARD_PER_SHARE_PRECISION = 1e24;

Expand Down
45 changes: 22 additions & 23 deletions test/StableJoeStaking.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ describe("Stable Joe Staking", function () {
],
{
unsafeAllow: ["constructor", "state-variable-immutable"],
constructorArgs: [this.joe.address]
constructorArgs: [this.joe.address],
}
);

Expand Down Expand Up @@ -201,9 +201,9 @@ describe("Stable Joe Staking", function () {
// Making sure that `pendingReward` still return the accurate tokens even after updating pools
await this.stableJoeStaking.connect(this.alice).deposit("1");

expect(
await this.rewardToken.balanceOf(this.alice.address)
).to.be.equal(ethers.utils.parseEther("1"));
expect(await this.rewardToken.balanceOf(this.alice.address)).to.be.equal(
ethers.utils.parseEther("1")
);

expect(
await this.stableJoeStaking.pendingReward(
Expand All @@ -228,9 +228,9 @@ describe("Stable Joe Staking", function () {
// Making sure that `pendingReward` still return the accurate tokens even after updating pools
await this.stableJoeStaking.connect(this.alice).deposit("1");

expect(
await this.rewardToken.balanceOf(this.alice.address)
).to.be.equal(ethers.utils.parseEther("2"));
expect(await this.rewardToken.balanceOf(this.alice.address)).to.be.equal(
ethers.utils.parseEther("2")
);

expect(
await this.stableJoeStaking.pendingReward(
Expand Down Expand Up @@ -734,34 +734,33 @@ describe("Stable Joe Staking", function () {
ethers.utils.parseEther("100")
); // We send 100 Tokens to sJoe's address

await this.stableJoeStaking.connect(this.dev).sweep(
stuckToken.address,
this.dev.address
);
await this.stableJoeStaking
.connect(this.dev)
.sweep(stuckToken.address, this.dev.address);

expect(await stuckToken.balanceOf(this.dev.address)).to.be.equal(
ethers.utils.parseEther("100")
);
expect(await stuckToken.balanceOf(this.stableJoeStaking.address)).to.be.equal(
0
);
expect(
await stuckToken.balanceOf(this.stableJoeStaking.address)
).to.be.equal(0);

// Should fail for joe
await expect(
this.stableJoeStaking.connect(this.dev).sweep(
this.joe.address,
this.dev.address
)
this.stableJoeStaking
.connect(this.dev)
.sweep(this.joe.address, this.dev.address)
).to.be.revertedWith("StableJoeStaking: token can't be swept");

// Should fail if stuckToken is added as a reward token
await this.stableJoeStaking.connect(this.dev).addRewardToken(stuckToken.address);
await this.stableJoeStaking
.connect(this.dev)
.addRewardToken(stuckToken.address);

await expect(
this.stableJoeStaking.connect(this.dev).sweep(
stuckToken.address,
this.dev.address
)
this.stableJoeStaking
.connect(this.dev)
.sweep(stuckToken.address, this.dev.address)
).to.be.revertedWith("StableJoeStaking: token can't be swept");
});
});
Expand Down
26 changes: 9 additions & 17 deletions test/foundry/UpgradeSJoe.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -26,37 +26,29 @@ contract TestUpgradeSJoe is Test {

imp = new StableJoeStaking(IERC20Upgradeable(joe));
}

function test_CantInitialize() public {
vm.expectRevert("Initializable: contract is already initialized");
imp.initialize(
IERC20Upgradeable(address(0)),
address(0),
0
);
imp.initialize(IERC20Upgradeable(address(0)), address(0), 0);

_upgrade();

vm.expectRevert("Initializable: contract is already initialized");
imp.initialize(
IERC20Upgradeable(address(0)),
address(0),
0
);
imp.initialize(IERC20Upgradeable(address(0)), address(0), 0);
}

function test_VerifyStorage() public {
bytes32[] memory slots = new bytes32[](50);

uint256 i;

slots[i++] = bytes32(uint256(uint160(address(sjoe.joe()))));
slots[i++] = bytes32(sjoe.internalJoeBalance());

uint256 l = sjoe.rewardTokensLength();
slots[i++] = bytes32(l);

for(uint256 ii = 0; ii < l; ii++) {
for (uint256 ii = 0; ii < l; ii++) {
IERC20Upgradeable token = sjoe.rewardTokens(ii);

slots[i++] = bytes32(uint256(uint160(address(token))));
Expand All @@ -74,7 +66,7 @@ contract TestUpgradeSJoe is Test {

slots[i++] = bytes32(sjoe.DEPOSIT_FEE_PERCENT_PRECISION());
slots[i++] = bytes32(sjoe.ACC_REWARD_PER_SHARE_PRECISION());

_upgrade();

uint256 j;
Expand All @@ -83,7 +75,7 @@ contract TestUpgradeSJoe is Test {
assertEq(slots[j++], bytes32(sjoe.internalJoeBalance()), "test_VerifyStorage::2");
assertEq(slots[j++], bytes32(sjoe.rewardTokensLength()), "test_VerifyStorage::3");

for(uint256 jj = 0; jj < l; jj++) {
for (uint256 jj = 0; jj < l; jj++) {
IERC20Upgradeable token = sjoe.rewardTokens(jj);

assertEq(slots[j++], bytes32(uint256(uint160(address(token)))), "test_VerifyStorage::4");
Expand All @@ -109,7 +101,7 @@ contract TestUpgradeSJoe is Test {
sjoe.sweep(IERC20Upgradeable(joe), address(this));

vm.startPrank(owner);

vm.expectRevert("StableJoeStaking: token can't be swept");
sjoe.sweep(IERC20Upgradeable(joe), address(this));

Expand Down

0 comments on commit 5e19170

Please sign in to comment.