-
-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
44 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
pragma solidity ^0.8.0; | ||
|
||
import "https://github.com/OpenZeppelin/openzeppelin-solidity/contracts/test/ERC20Test.sol"; | ||
import "../smart-contracts/pi-network/pi_token.sol"; | ||
|
||
contract PiTokenTest is ERC20Test { | ||
PiToken private piToken; | ||
|
||
function setUp() public { | ||
piToken = new PiToken(); | ||
} | ||
|
||
function testTransfer() public { | ||
address alice = address(0x123); | ||
address bob = address(0x456); | ||
uint256 amount = 100; | ||
|
||
piToken.transfer(alice, amount); | ||
assertEq(piToken.balanceOf(alice), amount); | ||
|
||
piToken.transfer(bob, amount); | ||
assertEq(piToken.balanceOf(bob), amount); | ||
} | ||
|
||
function testApprove() public { | ||
address alice = address(0x123); | ||
address bob = address(0x456); | ||
uint256 amount = 100; | ||
|
||
piToken.approve(alice, amount); | ||
assertEq(piToken.allowance(alice, bob), amount); | ||
} | ||
|
||
function testTransferFrom() public { | ||
address alice = address(0x123); | ||
address bob = address(0x456); | ||
uint256 amount = 100; | ||
|
||
piToken.transfer(alice, amount); | ||
piToken.approve(alice, amount); | ||
piToken.transferFrom(alice, bob, amount); | ||
assertEq(piToken.balanceOf(bob), amount); | ||
} | ||
} |