Add this test into the `EggHuntGameTest.t.sol` file
```javascript
function testGameCanBeEndBeforeDeadlinePass() public {
game.startGame(1 hours);
vm.warp(1 minutes);
assertEq(game.getGameStatus(), "Game is active");
game.endGame();
assertEq(game.getGameStatus(),"Game is not active");
}
```
Result:
```javascript
Ran 1 test for test/EggHuntGameTest.t.sol:EggGameTest
[PASS] testGameCanBeEndBeforeDeadlinePass() (gas: 65715)
Traces:
[68515] EggGameTest::testGameCanBeEndBeforeDeadlinePass()
├─ [53376] EggHuntGame::startGame(3600)
│ ├─ emit GameStarted(startTime: 1, endTime: 3601)
│ └─ ← [Stop]
├─ [0] VM::warp(60)
│ └─ ← [Return]
├─ [945] EggHuntGame::getGameStatus() [staticcall]
│ └─ ← [Return] "Game is active"
├─ [0] VM::assertEq("Game is active", "Game is active") [staticcall]
│ └─ ← [Return]
├─ [1792] EggHuntGame::endGame()
│ ├─ emit GameEnded(endTime: 60)
│ └─ ← [Stop]
├─ [561] EggHuntGame::getGameStatus() [staticcall]
│ └─ ← [Return] "Game is not active"
├─ [0] VM::assertEq("Game is not active", "Game is not active") [staticcall]
│ └─ ← [Return]
└─ ← [Stop]
Suite result: ok. 1 passed; 0 failed; 0 skipped; finished in 4.81ms (742.03µs CPU time)
Ran 1 test suite in 2.78s (4.81ms CPU time): 1 tests passed, 0 failed, 0 skipped (1 total tests)
```
The protocol should implement machenism so that also owner can not end the game before the actual deadline passed.
Make changes in to `endGame` function.
```diff
function endGame() external onlyOwner {
require(gameActive, "Game not active");
+ require(block.timestamp > endTime, "Duration is not passed yet");
gameActive = false;
emit GameEnded(block.timestamp);
}
```