1/5
# Rebase token tests pt.2 Let's dive into why we use `bound` rather than `assume`. When running fuzz tests, we have runs, where one run is an input for the test function. These runs are based on randomness and are used to spam as many values of these inputs as possible, which will then test for edge cases. The `assume` keyword will discard a run if the assumption does not pass. This is okay, but when fuzzing, we want to have as many runs as possible so we get a lot more test data. Instead, we use bound. This will modify the amount to be within those bounds. It does so using a modulus. Additionally, when looking at the inputs to this function: ```javascript function testDepositLinear(uint256 amount) public { vm.assume(amount > 1e5); amount = bound(amount, 1e5, type(uint96).max); // 1. deposit vm.startPrank(user); vm.deal(user, amount); // 2. check our rebase token balance // 3. warp the time and check the balance again // 4. warp the time again by the same amount and check the balance again vm.stopPrank(); } ``` We are bounding amount with `amount = bound(amount, 1e5, type(uint96).max)` to be the lower limit `1e5` and the upper limit of the maximum value of a uint 64. This helps preserve runs, and uses a modulus to do this.
A complete guide to testing a rebase token in Solidity. This lesson covers the important aspects of testing your rebase token, including linear interest, the ability to redeem, and the ability to transfer tokens to another chain.
Previous lesson
Previous
Next lesson
Next
Give us feedback
Course Overview
About the course
Advanced smart contract development
How to develop a stablecoin
How to develop a DeFi protocol
How to develop a DAO
Advanced smart contracts testing
Fuzz testing
Manual verification
Web3 Developer Relations
$85,000 - $125,000 (avg. salary)
Web3 developer
$60,000 - $150,000 (avg. salary)
Smart Contract Engineer
$100,000 - $150,000 (avg. salary)
Smart Contract Auditor
$100,000 - $200,000 (avg. salary)
Security researcher
$49,999 - $120,000 (avg. salary)
Guest lecturers:
Juliette Chevalier
Lead Developer relations at Aragon
Nader Dabit
Director of developer relations at Avara
Ally Haire
Developer relations at Protocol Labs
Harrison
Founder at GasliteGG
Last updated on March 11, 2025
Solidity Developer
Advanced FoundryDuration: 36min
Duration: 3h 06min
Duration: 5h 02min
Duration: 6h 02min
Duration: 2h 47min
Duration: 1h 23min
Duration: 4h 28min
Duration: 1h 19min
Duration: 1h 10min
Course Overview
About the course
Advanced smart contract development
How to develop a stablecoin
How to develop a DeFi protocol
How to develop a DAO
Advanced smart contracts testing
Fuzz testing
Manual verification
Web3 Developer Relations
$85,000 - $125,000 (avg. salary)
Web3 developer
$60,000 - $150,000 (avg. salary)
Smart Contract Engineer
$100,000 - $150,000 (avg. salary)
Smart Contract Auditor
$100,000 - $200,000 (avg. salary)
Security researcher
$49,999 - $120,000 (avg. salary)
Guest lecturers:
Juliette Chevalier
Lead Developer relations at Aragon
Nader Dabit
Director of developer relations at Avara
Ally Haire
Developer relations at Protocol Labs
Harrison
Founder at GasliteGG
Last updated on March 11, 2025
Testimonials
Read what our students have to say about this course.
Chainlink
Chainlink
Gustavo Gonzalez
Solutions Engineer at OpenZeppelin
Francesco Andreoli
Lead Devrel at Metamask
Albert Hu
DeForm Founding Engineer
Radek
Senior Developer Advocate at Ceramic
Boidushya
WalletConnect
Idris
Developer Relations Engineer at Axelar