Skip to content

Commit 01b1670

Browse files
ADD: Test passed
1 parent 626f937 commit 01b1670

5 files changed

Lines changed: 33 additions & 58 deletions

File tree

script/Counter.s.sol

Lines changed: 0 additions & 19 deletions
This file was deleted.

src/Counter.sol

Lines changed: 0 additions & 14 deletions
This file was deleted.

src/gameSessionfactoryContract.sol

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ contract rockPaperScissorGame{
6969
}else if(msg.sender == player2.addr){
7070

7171
if( !(player2.hasCommitted) ) revert AlreadyCommitted();
72-
player2.committedMove = "";
72+
player2.committedMove = _move;
7373
player2.hasCommitted = true;
7474

7575
} else{
@@ -167,5 +167,9 @@ contract gameSessionFactory{
167167
function getAllChildContractAddress() external view returns (uint256){
168168
return deployedGameSession.length;
169169
}
170+
171+
function getDeployedContract() external view returns (address [] memory){
172+
return deployedGameSession;
173+
}
170174

171175
}

test/Counter.t.sol

Lines changed: 0 additions & 24 deletions
This file was deleted.

test/factory.t.sol

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// SPDX-License-Identifier: UNLICENSED
2+
pragma solidity ^0.8.13;
3+
4+
import {Test, console} from "forge-std/Test.sol";
5+
import {gameSessionFactory} from "../src/gameSessionfactoryContract.sol";
6+
7+
contract factoryTest is Test {
8+
gameSessionFactory public game;
9+
10+
function setUp() public {
11+
game = new gameSessionFactory();
12+
}
13+
14+
//check if it deploys a contract
15+
function testCreatNewContract() public{
16+
17+
game.createNewContract();
18+
19+
address [] memory games = game.getDeployedContract();
20+
21+
assertEq(games.length, 1);
22+
console.log(games.length);
23+
24+
assertTrue(games[0] != address(0));
25+
26+
console.log(games[0]);
27+
}
28+
}

0 commit comments

Comments
 (0)