Skip to content

Commit 819e5f4

Browse files
Omid BodaghiOmid Bodaghi
authored andcommitted
Setup test files
1 parent ac70c3a commit 819e5f4

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed

src/Raffle.sol

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,4 +139,8 @@ contract Raffle is VRFConsumerBaseV2Plus {
139139
function getEntranceFee() external view returns (uint256) {
140140
return i_entranceFee;
141141
}
142+
143+
function getRaffleState() external view returns (RaffleState) {
144+
return s_raffleState;
145+
}
142146
}

test/unit/RaffleTest.s.sol

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// SPDX-License-Identifier: MIT
2+
pragma solidity ^0.8.28;
3+
4+
import {Test} from "forge-std/Test.sol";
5+
import {DeployRaffle} from "../../script/DeployRaffle.s.sol";
6+
import {HelperConfig} from "../../script/HelperConfig.s.sol";
7+
import {Raffle} from "../../src/Raffle.sol";
8+
9+
contract RaffleTest is Test {
10+
Raffle public raffle;
11+
HelperConfig public helperConfig;
12+
13+
uint256 entranceFee;
14+
uint256 interval;
15+
address vrfCoordinator;
16+
bytes32 gasLane;
17+
uint256 subscriptionId;
18+
uint32 callbackGasLimit;
19+
20+
address public PLAYER = makeAddr("player");
21+
uint256 public constant STARTING_PLAYER_BALANCE = 10 ether;
22+
23+
function setUp() external {
24+
DeployRaffle deployer = new DeployRaffle();
25+
(raffle, helperConfig) = deployer.deployContract();
26+
27+
HelperConfig.NetworkConfig memory config = helperConfig.getConfig();
28+
entranceFee = config.entranceFee;
29+
interval = config.interval;
30+
vrfCoordinator = config.vrfCoordinator;
31+
gasLane = config.gasLane;
32+
subscriptionId = config.subscriptionId;
33+
callbackGasLimit = config.callbackGasLimit;
34+
}
35+
36+
function testRaffleInitializesInOpesState() public view {
37+
assert(raffle.getRaffleState() == Raffle.RaffleState.OPEN);
38+
}
39+
}

0 commit comments

Comments
 (0)