When I use vm.prank(PLAYER)
, the assertion fails because PLAYER
and playerRecorded
are different.
function testRaffleUpdatesPlayersWhenTheyEnter() public {
// Arrange
vm.prank(PLAYER);
console.log(PLAYER);
// Act
uint256 entranceFee = raffle.getEntranceFee();
raffle.enterRaffle{value: entranceFee}();
// Assert
address playerRecorded = raffle.getPlayer(0);
assert(playerRecorded == PLAYER);
console.log(playerRecorded);
}
But, when I use vm.startPrank(PLAYER)
, the test passes and PLAYER
and playerRecorded
are the same, how come?
function testRaffleUpdatesPlayersWhenTheyEnter() public {
// Arrange
vm.startPrank(PLAYER);
console.log(PLAYER);
// Act
uint256 entranceFee = raffle.getEntranceFee();
raffle.enterRaffle{value: entranceFee}();
// Assert
address playerRecorded = raffle.getPlayer(0);
assert(playerRecorded == PLAYER);
console.log(playerRecorded);
vm.stopPrank();
}