Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import pytest
- def test_transferFrom(token, accounts):
- '''Transfer tokens with transferFrom'''
- token.approve(accounts[1], "6 ether", {'from': accounts[0]})
- token.transferFrom(accounts[0], accounts[2], "5 ether", {'from': accounts[1]})
- assert token.balanceOf(accounts[2]) == "5 ether"
- assert token.balanceOf(accounts[1]) == 0
- assert token.balanceOf(accounts[0]) == "995 ether"
- assert token.allowance(accounts[0], accounts[1]) == "1 ether"
- def test_transferFrom_reverts(token, accounts):
- '''transerFrom should revert'''
- with pytest.reverts("Insufficient allowance"):
- token.transferFrom(accounts[0], accounts[2], "1 ether", {'from': accounts[1]})
- with pytest.reverts("Insufficient allowance"):
- token.transferFrom(accounts[0], accounts[2], "1 ether", {'from': accounts[0]})
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement