Day 150 of writing a smart contract a day until someone hired me.
SHFT Security
WOW! Happy day 150 guys 🥳
If I knew when I started this that I would have made it 150 days I probably.... Well I probably would have started budgeting a bit more closely.
But I also would be pretty proud of how far this account has gone. I know I've definitely learned a lot while writing and researching these posts.
Anyways. What's today's continuation of the SHFT project?
Security!
So after getting that basic frontend set up (and doing a little bit of styling with TailwindCSS offscreen). It's time to go back to the smart contracts and secure things a bit. That double claim attack I talked about is a real problem. And we never actually added a "fund()" function to do anything with the funded contract.
So I added the fund part into our happy path and various other security tests to make sure the owner can't call "fund()" without the time passing and goal being hit.
Note that in Foundry all you have to do to make a test for failure function is start the function name with "testFail". Using the expect revert is probably a better way to do this, but I wanted to use testFail for this.
A few further points
- Most of the functions are collapsed so you can see them, sorry I can't screenshot the whole thing it's getting too big.
- I am not testing for Fund's behavior (adding liquidity to Uniswap). Mainly because I don't want to actually add it to the contract. Sorry but I've done this before and I don't actually care much to do it for a demo thing because it's always a pain.
So as of now things don't compile, since that "fund()" function doesn't exist. So we'll make that function, then fill everything out to make these tests pass tomorrow!