selon la fonction "getActivePlayer" modifiée peux tu corriger les tests "function…
- User
selon la fonction "getActivePlayer" modifiée peux tu corriger les tests "function getActivePlayer(uint256 _gameId) public view returns (address) { if (state == State.firstLetter) { return games[_gameId].player2; } else { return games[_gameId].player1; } }" les tests "context ("FONCTION getActivePlayer", () => { beforeEach(async function() { penduelInstance = await Penduel.new(subId); await penduelInstance.createGame({ from: player1 }); await penduelInstance.joinGame({ from: player2 }); });
codedescribe ("Vérifie la fonction getActivePlayer pour player2", () => { it("doit retourner le player actif comme player2", async () => { const gameId = 1; const games = await penduelInstance.games(gameId); const isPlayer2Turn = games.isPlayer2Turn; const player2 = games.player2; assert.equal(isPlayer2Turn, true); assert.equal(player2, await penduelInstance.getActivePlayer.call(gameId), "le player actif doit être player2" ); }); }); describe ("Vérifie la fonction getActivePlayer pour player1", () => { it("doit retourner le player actif comme player1", async () => { const gameId = 1; const games = await penduelInstance.games(gameId); const isPlayer2Turn = games.isPlayer2Turn; const expectedPlayer = isPlayer2Turn ? games.player2 : games.player1; assert.equal(expectedPlayer, await penduelInstance.getActivePlayer.call(gameId), "le player actif doit être player1" ); }); });" - Assistant
Les tests doivent être modifiés comme suit :
javascript - User
il n'y a plus isPlayer2turn dans la fonction "function getActivePlayer(uint256 _gameId) public view returns (address) { if (state == State.firstLetter) { return games[_gameId].player2; } else { return games[_gameId].player1; } }
- Assistant
Correction des tests en tenant compte des modifications de la fonction
getActivePlayer:javascript