Skip to content

Commit

Permalink
test(erc20): fix tests for ERC20 after refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
bidzyyys committed Apr 4, 2024
1 parent a4b80d4 commit dc04ea3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions contracts/src/erc20/extensions/burnable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ impl ERC20Burnable {
///
/// * `value` - Amount to be burnt.
///
/// # Errors
///
/// If the `from` address doesn't have enough tokens, then the error
/// [`Error::InsufficientBalance`] is returned.
pub fn burn(&mut self, value: U256) -> Result<(), Error> {
Expand All @@ -40,6 +42,8 @@ impl ERC20Burnable {
/// * `account` - Owner's address.
/// * `value` - Amount to be burnt.
///
/// # Errors
///
/// If not enough allowance is available, then the error
/// [`Error::InsufficientAllowance`] is returned.
/// * If the `from` address is `Address::ZERO`, then the error
Expand Down
6 changes: 6 additions & 0 deletions contracts/src/erc20/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -530,6 +530,11 @@ mod tests {
fn transfer_from_errors_when_invalid_sender(contract: ERC20) {
let alice = address!("A11CEacF9aa32246d767FCCD72e02d6bCbcC375d");
let one = U256::from(1);
contract
._allowances
.setter(Address::ZERO)
.setter(msg::sender())
.set(one);
let result = contract.transfer_from(Address::ZERO, alice, one);
assert!(matches!(result, Err(Error::InvalidSender(_))));
}
Expand All @@ -538,6 +543,7 @@ mod tests {
fn transfer_from_errors_when_invalid_receiver(contract: ERC20) {
let alice = address!("A11CEacF9aa32246d767FCCD72e02d6bCbcC375d");
let one = U256::from(1);
contract._allowances.setter(alice).setter(msg::sender()).set(one);
let result = contract.transfer_from(alice, Address::ZERO, one);
assert!(matches!(result, Err(Error::InvalidReceiver(_))));
}
Expand Down

0 comments on commit dc04ea3

Please sign in to comment.