In Developer Basecamp 13 Session 5, we walked through writing integration tests using Foundry for the counter contract that we built in Session 4. You’ll learn how to create effective test cases, validate outcomes with assert, and verify that functions panic correctly. We also covered checking error messages, using cheatcodes for advanced testing, capturing events, and setting STRK balances.
Useful links:
– Playlist: https://youtube.com/playlist?list=PLMXIoXErTTYV-Pd6tXu0TzsQ2EYQ5bBEh&si=WmMFjhV9rmn1JiqW
– Slides: https://docs.google.com/presentation/d/11NY_SzeiYwF6rEulDAmcb1_aobpmMvk35eTpuLFria4/edit?usp=drive_link
– Starknet Foundry: https://foundry-rs.github.io/starknet-foundry/
Timestamps
00:00:04 Recap of Session 4 – Building a Counter Contract
00:03:04 Manual vs Automated Testing
00:07:44 Unit vs Integration Testing
00:09:26 Writing the First Integration Test
00:28:43 Abstracting Deployment into a Helper Function
00:40:10 Testing Edge Cases – Underflow Protection
00:45:47 Capturing Events with Spy Events
00:59:58 Owner-Only Access Control Test
01:07:34 Reset Counter with Payment – Testing STRK Token
01:27:53 Utility Function for Token Amounts
source









Leave a Reply
You must be logged in to post a comment.