Skip to content

Commit 1202f17

Browse files
committed
style: format code for consistency and readability in RLCOFT contract and tests
1 parent b209c09 commit 1202f17

File tree

3 files changed

+44
-44
lines changed

3 files changed

+44
-44
lines changed

script/RLCOFT.s.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {EnvUtils} from "./UpdateEnvUtils.sol";
99
import {ERC1967Proxy} from "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol";
1010

1111
contract Deploy is Script {
12-
function run() external returns (address) {
12+
function run() external returns (address) {
1313
vm.startBroadcast();
1414

1515
string memory name = vm.envString("RLC_OFT_TOKEN_NAME");

src/RLCOFT.sol

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,10 @@ contract RLCOFT is OFTUpgradeable, UUPSUpgradeable, AccessControlDefaultAdminRul
2626
/// @param _name Name of the token
2727
/// @param _symbol Symbol of the token
2828
/// @param _owner Address of the contract owner
29-
function initialize(string memory _name, string memory _symbol, address _owner, address pauser) public initializer {
29+
function initialize(string memory _name, string memory _symbol, address _owner, address pauser)
30+
public
31+
initializer
32+
{
3033
__Ownable_init(_owner);
3134
__OFT_init(_name, _symbol, _owner);
3235
__UUPSUpgradeable_init();
@@ -46,7 +49,7 @@ contract RLCOFT is OFTUpgradeable, UUPSUpgradeable, AccessControlDefaultAdminRul
4649
function unpause() public onlyRole(PAUSER_ROLE) {
4750
_unpause();
4851
}
49-
52+
5053
/**
5154
* @dev * @dev See {ERC20-_update}.
5255
* The following functions are overrides required by Solidity.

test/RLCOFT.t.sol

Lines changed: 38 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,22 @@ import {ITokenSpender} from "../src/ITokenSpender.sol";
88

99
contract RLCOFTTest is Test {
1010
RLCOFT public rlcOft;
11-
11+
1212
address public owner;
1313
address public bridge;
1414
address public pauser;
1515
address public user1;
1616
address public user2;
17-
17+
1818
// Events to test
1919
event Paused(address account);
2020
event Unpaused(address account);
2121
event Transfer(address indexed from, address indexed to, uint256 value);
22-
22+
2323
// Custom errors from OpenZeppelin
2424
error EnforcedPause();
2525
error AccessControlUnauthorizedAccount(address account, bytes32 neededRole);
26-
26+
2727
function setUp() public {
2828
vm.createSelectFork(vm.envString("ARBITRUM_SEPOLIA_RPC_URL"));
2929

@@ -34,137 +34,134 @@ contract RLCOFTTest is Test {
3434
user1 = makeAddr("user1");
3535
user2 = makeAddr("user2");
3636

37-
3837
// Set up environment variables for the deployment
3938
vm.setEnv("RLC_OFT_TOKEN_NAME", "RLC OFT Test");
4039
vm.setEnv("RLC_TOKEN_SYMBOL", "RLCT");
4140
vm.setEnv("LAYER_ZERO_ARBITRUM_SEPOLIA_ENDPOINT_ADDRESS", "0x6EDCE65403992e310A62460808c4b910D972f10f");
4241
vm.setEnv("OWNER_ADDRESS", vm.toString(owner));
4342
vm.setEnv("PAUSER_ADDRESS", vm.toString(pauser));
44-
43+
4544
// Deploy the contract using the deployment script
4645
rlcOft = RLCOFT(new RLCOFTDeploy().run());
4746

48-
49-
vm.startPrank(owner);// We can't use vm.prank here as the first call will be rlcOft.BRIDGE_ROLE() before doing the grantRole
47+
vm.startPrank(owner); // We can't use vm.prank here as the first call will be rlcOft.BRIDGE_ROLE() before doing the grantRole
5048
rlcOft.grantRole(rlcOft.BRIDGE_ROLE(), bridge);
5149
vm.stopPrank();
52-
50+
5351
vm.startPrank(bridge);
54-
rlcOft.mint(user1, 1000 * 10**9);
55-
rlcOft.mint(user2, 500 * 10**9);
52+
rlcOft.mint(user1, 1000 * 10 ** 9);
53+
rlcOft.mint(user2, 500 * 10 ** 9);
5654
vm.stopPrank();
57-
5855
}
5956

6057
// ============ Deployment Tests ============
6158
function testDeployment() public {
6259
assertEq(rlcOft.name(), "RLC OFT Test");
6360
assertEq(rlcOft.symbol(), "RLCT");
6461
assertEq(rlcOft.decimals(), 9);
65-
assertEq(rlcOft.totalSupply(), 1500 * 10**9); // 1000 + 500
62+
assertEq(rlcOft.totalSupply(), 1500 * 10 ** 9); // 1000 + 500
6663
}
6764

6865
// ============ Pausable Tests ============
6966
function testPauseByPauser() public {
7067
vm.expectEmit(true, false, false, false);
7168
emit Paused(pauser);
72-
69+
7370
vm.prank(pauser);
7471
rlcOft.pause();
75-
72+
7673
assertTrue(rlcOft.paused());
7774
}
78-
75+
7976
function testPauseUnauthorized() public {
8077
vm.expectRevert(abi.encodeWithSelector(AccessControlUnauthorizedAccount.selector, user1, rlcOft.PAUSER_ROLE()));
8178
vm.prank(user1);
8279
rlcOft.pause();
8380
}
84-
81+
8582
function testUnpauseByPauser() public {
8683
// First pause
8784
vm.prank(pauser);
8885
rlcOft.pause();
8986
assertTrue(rlcOft.paused());
90-
87+
9188
// Then unpause
9289
vm.expectEmit(true, false, false, false);
9390
emit Unpaused(pauser);
94-
91+
9592
vm.prank(pauser);
9693
rlcOft.unpause();
97-
94+
9895
assertFalse(rlcOft.paused());
9996
}
100-
97+
10198
function testUnpauseUnauthorized() public {
10299
vm.prank(pauser);
103100
rlcOft.pause();
104-
101+
105102
vm.expectRevert(abi.encodeWithSelector(AccessControlUnauthorizedAccount.selector, user1, rlcOft.PAUSER_ROLE()));
106103
vm.prank(user1);
107104
rlcOft.unpause();
108105
}
109-
106+
110107
function testTransferWhenPaused() public {
111108
// Pause the contract
112109
vm.prank(pauser);
113110
rlcOft.pause();
114-
111+
115112
vm.expectRevert(EnforcedPause.selector);
116113
vm.prank(user1);
117-
rlcOft.transfer(user2, 100 * 10**9);
114+
rlcOft.transfer(user2, 100 * 10 ** 9);
118115
}
119-
116+
120117
function testTransferFromWhenPaused() public {
121118
// First approve
122119
vm.prank(user1);
123-
rlcOft.approve(user2, 100 * 10**9);
124-
120+
rlcOft.approve(user2, 100 * 10 ** 9);
121+
125122
// Pause the contract
126123
vm.prank(pauser);
127124
rlcOft.pause();
128-
125+
129126
// Try to transferFrom - should fail with EnforcedPause() custom error
130127
vm.expectRevert(EnforcedPause.selector);
131128
vm.prank(user2);
132-
rlcOft.transferFrom(user1, user2, 100 * 10**9);
129+
rlcOft.transferFrom(user1, user2, 100 * 10 ** 9);
133130
}
134-
131+
135132
function testMintWhenPaused() public {
136133
// Pause the contract
137134
vm.prank(pauser);
138135
rlcOft.pause();
139-
136+
140137
// Try to mint - should fail with EnforcedPause() custom error
141138
vm.expectRevert(EnforcedPause.selector);
142139
vm.prank(bridge);
143-
rlcOft.mint(user1, 100 * 10**9);
140+
rlcOft.mint(user1, 100 * 10 ** 9);
144141
}
145-
142+
146143
function testBurnWhenPaused() public {
147144
// Pause the contract
148145
vm.prank(pauser);
149146
rlcOft.pause();
150-
147+
151148
// Try to burn - should fail with EnforcedPause() custom error
152149
vm.expectRevert(EnforcedPause.selector);
153150
vm.prank(bridge);
154-
rlcOft.burn(100 * 10**9);
151+
rlcOft.burn(100 * 10 ** 9);
155152
}
156-
153+
157154
function testTransferWhenNotPaused() public {
158-
uint256 transferAmount = 100 * 10**9;
155+
uint256 transferAmount = 100 * 10 ** 9;
159156
uint256 initialBalance1 = rlcOft.balanceOf(user1);
160157
uint256 initialBalance2 = rlcOft.balanceOf(user2);
161-
158+
162159
vm.expectEmit(true, true, false, true);
163160
emit Transfer(user1, user2, transferAmount);
164-
161+
165162
vm.prank(user1);
166163
bool success = rlcOft.transfer(user2, transferAmount);
167-
164+
168165
assertTrue(success);
169166
assertEq(rlcOft.balanceOf(user1), initialBalance1 - transferAmount);
170167
assertEq(rlcOft.balanceOf(user2), initialBalance2 + transferAmount);

0 commit comments

Comments
 (0)