je veux tester la fonction "withdraw". voici la fonction précédent la fonction…
- User
je veux tester la fonction "withdraw". voici la fonction précédent la fonction "withdraw" : "function proposeWord(uint256 _gameId, string memory _wordToGuess, string memory _letterToGuess) public { require(state == State.inProgress, "Bad State"); require(msg.sender == games[_gameId].player1 || (msg.sender == games[_gameId].player2 && games[_gameId].isPlayer2Turn),"invalid address"); require(playerBalances[_gameId][msg.sender].balance > 0, "you didn't bet"); string memory filteredWord = wordFiltered(_wordToGuess); if (isWordCorrect(filteredWord)) { games[_gameId].winner = msg.sender; addBetToPlayer(_gameId, msg.sender); emit WordWin(_gameId, filteredWord);
emit GameFinished(_gameId); state = State.finished; } else { if (msg.sender == games[_gameId].player2) { games[_gameId].isPlayer2Turn = false; proposeLetter(_gameId, _letterToGuess, _wordToGuess);
} else { if (msg.sender == games[_gameId].player1) { games[_gameId].isPlayer2Turn = true; proposeLetter(_gameId, _letterToGuess, _wordToGuess); } } } }" le fonction withdraxw à tester : " function withdraw(uint256 _gameId, uint256 _amount) public payable { require(state == State.finished, "game is not over"); require(msg.sender == games[_gameId].player1 || msg.sender == games[_gameId].player2, "You re not a player"); address winner = games[_gameId].winner; require(winner == msg.sender, "You are not the winner"); require(!games[_gameId].player1HasWithdrawn || !games[_gameId].player2HasWithdrawn, "withdrawn balance"); uint256 balance = playerBalances[_gameId][msg.sender].balance; require(balance >= _amount, "Insufficient balance");code - Assistant
Pour tester la fonction "withdraw", vous pouvez utiliser le code ci-dessous :
javascript