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 59dd8f7 commit 388ec26
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 @@ -541,6 +541,11 @@ mod tests {
test_utils::with_storage::<ERC20>(|token| {
let alice = address!("A11CEacF9aa32246d767FCCD72e02d6bCbcC375d");
let one = U256::from(1);
token
._allowances
.setter(Address::ZERO)
.setter(msg::sender())
.set(one);
let result = token.transfer_from(Address::ZERO, alice, one);
assert!(matches!(result, Err(Error::InvalidSender(_))));
})
Expand All @@ -551,6 +556,7 @@ mod tests {
test_utils::with_storage::<ERC20>(|token| {
let alice = address!("A11CEacF9aa32246d767FCCD72e02d6bCbcC375d");
let one = U256::from(1);
token._allowances.setter(alice).setter(msg::sender()).set(one);
let result = token.transfer_from(alice, Address::ZERO, one);
assert!(matches!(result, Err(Error::InvalidReceiver(_))));
})
Expand Down

0 comments on commit 388ec26

Please sign in to comment.