Lesson 9 [Smart Contract Lottery] - Testing RaffleNotOpen() #1754
-
I tried to test if someone can enter is the Raffle is Calculating.
i checked all my code but don't find any problems.. and the -vvvv doesnt give me any answers, i think the raffle don't get closed if i look at the logs but i can't expect why.. i'll upload my code in repo in some minutes. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 4 replies
-
Hello @DS-Coding0, Please post the code for the test so that we can gain more insight and possibly help. |
Beta Was this translation helpful? Give feedback.
-
Below is the test stack trace from when I ran the same test. Traces:
[156571] LotteryTest::testCantEnterWhenRaffleIsCalculating()
├─ [0] VM::prank(player: [0x44E97aF4418b7a17AABD8090bEA0A471a366305C])
│ └─ ← [Return]
├─ [47808] Lottery::enter{value: 10000000000000000}()
│ ├─ emit enteredLottery(player: player: [0x44E97aF4418b7a17AABD8090bEA0A471a366305C])
│ └─ ← [Stop]
├─ [0] VM::warp(32)
│ └─ ← [Return]
├─ [0] VM::roll(2)
│ └─ ← [Return]
├─ [75119] Lottery::performUpkeep(0x307830)
│ ├─ [0] console::log("The address of the lottery contract is: ", Lottery: [0x9fE46736679d2D9a65F0992F2272dE9f3c7fa6e0]) [staticcall]
│ │ └─ ← [Stop]
│ ├─ [44392] VRFCoordinatorV2Mock::requestRandomWords(0x474e34a077df58807dbe9c96d3c009b23b3c6d0cce433e59bbf5b34f823bc56c, 1, 3, 100000 [1e5], 1)
│ │ ├─ [0] console::log("The msg sender for this requestRandomWords call is: ", Lottery: [0x9fE46736679d2D9a65F0992F2272dE9f3c7fa6e0]) [staticcall]
│ │ │ └─ ← [Stop]
│ │ ├─ emit RandomWordsRequested(keyHash: 0x474e34a077df58807dbe9c96d3c009b23b3c6d0cce433e59bbf5b34f823bc56c, requestId: 1, preSeed: 100, subId: 1, minimumRequestConfirmations: 3, callbackGasLimit: 100000 [1e5], numWords: 1, sender: Lottery: [0x9fE46736679d2D9a65F0992F2272dE9f3c7fa6e0])
│ │ └─ ← [Return] 1
│ ├─ emit randomNumberRequested(requestId: 1)
│ └─ ← [Stop]
├─ [0] console::log(LotteryTest: [0x34A1D3fff3958843C43aD80F30b94c510645C316]) [staticcall]
│ └─ ← [Stop]
├─ [0] VM::expectRevert(Lottery__LotteryIsCalculatingWinner())
│ └─ ← [Return]
├─ [0] VM::prank(player2: [0xEb0A3b7B96C1883858292F0039161abD287E3324])
│ └─ ← [Return]
├─ [404] Lottery::enter{value: 10000000000000000}()
│ └─ ← [Revert] Lottery__LotteryIsCalculatingWinner()
└─ ← [Stop]
Suite result: ok. 1 passed; 0 failed; 0 skipped; finished in 30.26ms (1.92ms CPU time)
Ran 1 test suite in 4.76s (30.26ms CPU time): 1 tests passed, 0 failed, 0 skipped (1 total tests) Something i observed in your stack trace is for some reason the test didn't make the second |
Beta Was this translation helpful? Give feedback.
-
I need to open my eyes...
at |
Beta Was this translation helpful? Give feedback.
Below is the test stack trace from when I ran the same test.