Advertisement
Guest User

Untitled

a guest
Oct 17th, 2019
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. import pytest
  2.  
  3. def test_transferFrom(token, accounts):
  4. '''Transfer tokens with transferFrom'''
  5. token.approve(accounts[1], "6 ether", {'from': accounts[0]})
  6. token.transferFrom(accounts[0], accounts[2], "5 ether", {'from': accounts[1]})
  7.  
  8. assert token.balanceOf(accounts[2]) == "5 ether"
  9. assert token.balanceOf(accounts[1]) == 0
  10. assert token.balanceOf(accounts[0]) == "995 ether"
  11. assert token.allowance(accounts[0], accounts[1]) == "1 ether"
  12.  
  13.  
  14. def test_transferFrom_reverts(token, accounts):
  15. '''transerFrom should revert'''
  16. with pytest.reverts("Insufficient allowance"):
  17. token.transferFrom(accounts[0], accounts[2], "1 ether", {'from': accounts[1]})
  18.  
  19. with pytest.reverts("Insufficient allowance"):
  20. token.transferFrom(accounts[0], accounts[2], "1 ether", {'from': accounts[0]})
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement