Skip to content

Commit

Permalink
Create pi_token_test.sol
Browse files Browse the repository at this point in the history
  • Loading branch information
KOSASIH authored Aug 7, 2024
1 parent f28973c commit 2d0529d
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions projects/DAPIO/tests/unit-tests/pi_token_test.sol
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);
}
}

0 comments on commit 2d0529d

Please sign in to comment.