Web3 × AI Engineer · Smart Contracts (Solidity, Cairo) · MCP + Agentic Workflows · Shipping on Ethereum, Base & Starknet · Learning Rust
35 Followers
This screenshot says 100% coverage. I still don't trust it. A test can hit every line and assert nothing real: the quantity that should sum, the createdAt that shouldn't move, the index left dangling after a swap. Coverage = what ran. Assertions = what you actually checked. 🔑
Solidity gotcha: `delete myArray` empties the array but leaves your index mapping pointing at ghosts. Re-add a deleted item and it sneaks into a phantom slot → out-of-bounds panic. Clear each key first, then nuke the array. The mapping never sees your delete coming.
Underused Solidity pattern: `using-for` Verbose: StockLib.decrease(stocks, id, qty); With `using StockLib for mapping(...)`: stocks.decrease(id, qty); Same gas. Cleaner code. Methods on your types. The value before the dot becomes the first arg. Canonical Solidity pattern.
The EVM revert gives you atomicity for free. Killed a "validate all stock first" loop in my multi-vendor checkout. decrementStock already reverts when stock runs short — and one revert unwinds the entire tx: stock, invoices, payments already sent. The revert IS your rollback. 🔑