From 6862776f7afc48eedb3b3419d1abd75fa4a1b83a Mon Sep 17 00:00:00 2001 From: Whatmelon Date: Tue, 10 Dec 2024 05:24:27 +0800 Subject: [PATCH] fixed the bug by add a receive function but meet a new bug in vrfcoordinator fullfillRandowWord --- test/unit/RaffleTest.t.sol | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/test/unit/RaffleTest.t.sol b/test/unit/RaffleTest.t.sol index fde25e2..2337369 100644 --- a/test/unit/RaffleTest.t.sol +++ b/test/unit/RaffleTest.t.sol @@ -15,6 +15,8 @@ contract RaffleTest is Test { using CCEncoder for bool[]; using CCEncoder for bool[4]; event EnterRaffle(address indexed player); + event fallbackCalled(address Sender, uint Value, bytes Data); + event Received(address Sender, uint Value); Raffle raffle; HelperConfig helperConfig; @@ -82,7 +84,11 @@ contract RaffleTest is Test { assertEq(addressFromRaffle, PlayerAddress); } - function testEmitsEventOnEntrance() public M_startPrankPlayer M_enterRaffle { + function testEmitsEventOnEntrance() + public + M_startPrankPlayer + M_enterRaffle + { vm.expectEmit(true, false, false, false, address(raffle)); emit EnterRaffle(PlayerAddress); raffle.enterRaffle{value: entranceFee}(); @@ -293,6 +299,14 @@ contract RaffleTest is Test { assert(winnerBalance == startingBalance + prize); assert(endingTimeStamp > startingTimeStamp); } + + receive() external payable { + emit Received(msg.sender, msg.value); + } + + fallback() external payable { + emit fallbackCalled(msg.sender, msg.value, msg.data); + } } contract ToolTest is Test {