Skip to content

Commit fdebfc8

Browse files
committed
refactor: add constructor tests
1 parent 7eb67ae commit fdebfc8

1 file changed

Lines changed: 18 additions & 13 deletions

File tree

contracts/test/core/GasTankDepositorTest.sol

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,24 @@ contract GasTankDepositorTest is Test {
2626
_gasTankDepositorImpl = new GasTankDepositor(rpcService, MAXIMUM_DEPOSIT);
2727
}
2828

29+
//=======================TESTS FOR CONSTRUCTOR=======================
30+
31+
function testConstructorRevertsWhenRpcServiceIsZeroAddress() public {
32+
vm.expectRevert(abi.encodeWithSelector(GasTankDepositor.RPCServiceNotSet.selector, ZERO_ADDRESS));
33+
new GasTankDepositor(ZERO_ADDRESS, MAXIMUM_DEPOSIT);
34+
}
35+
36+
function testConstructorRevertsWhenMaximumDepositIsZero() public {
37+
vm.expectRevert(abi.encodeWithSelector(GasTankDepositor.MaximumDepositNotMet.selector, 0, 0));
38+
new GasTankDepositor(rpcService, 0);
39+
}
40+
41+
function testConstructorSetsVariables() public view {
42+
assertEq(_gasTankDepositorImpl.RPC_SERVICE(), rpcService);
43+
assertEq(_gasTankDepositorImpl.MAXIMUM_DEPOSIT(), MAXIMUM_DEPOSIT);
44+
assertEq(_gasTankDepositorImpl.GAS_TANK_ADDRESS(), address(_gasTankDepositorImpl));
45+
}
46+
2947
//=======================TESTS=======================
3048

3149
function testSetsDelegationCodeAtAddress() public {
@@ -51,19 +69,6 @@ contract GasTankDepositorTest is Test {
5169
assertEq(alice.code.length, 0);
5270
}
5371

54-
//=======================TESTS FOR RECEIVING FUNDS=======================
55-
56-
function testReceivesFunds() public {
57-
_delegate();
58-
59-
uint256 beforeBalance = alice.balance;
60-
vm.prank(bob);
61-
(bool success,) = address(alice).call{value: 1 ether}("");
62-
assertTrue(success);
63-
uint256 afterBalance = alice.balance;
64-
assertEq(afterBalance, beforeBalance + 1 ether, "balance not increased");
65-
}
66-
6772
//=======================TESTS FOR RECEIVE AND FALLBACK=======================
6873

6974
function testFallbackRevert() public {

0 commit comments

Comments
 (0)