Skip to content

Commit

Permalink
Merge pull request #14 from mmsaki/main
Browse files Browse the repository at this point in the history
missing tests wip
  • Loading branch information
extropyCoder authored Feb 9, 2024
2 parents 09092c3 + 949b470 commit 2b377ac
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 4 deletions.
3 changes: 1 addition & 2 deletions src/Gas.sol
Original file line number Diff line number Diff line change
Expand Up @@ -316,8 +316,7 @@ contract GasContract is Ownable, Constants {
emit WhiteListTransfer(_recipient);
}


function getPaymentStatus(address sender) public returns (bool, uint256) {
function getPaymentStatus(address sender) public view returns (bool, uint256) {
return (whiteListStruct[sender].paymentStatus, whiteListStruct[sender].amount);
}

Expand Down
43 changes: 41 additions & 2 deletions test/Gas.UnitTests.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
pragma solidity ^0.8.0;

import "forge-std/Test.sol";
import "../../src/Gas.sol";
import "../src/Gas.sol";

contract GasTest is Test {
GasContract public gas;
Expand Down Expand Up @@ -156,6 +156,45 @@ contract GasTest is Test {
assertEq(gas.balances(_recipient),(_preRecipientAmount + _amount) - gas.whitelist(_sender));
}

function testBalanceOf() public {
uint256 bal = gas.balanceOf(owner);
assertEq(bal, totalSupply);
}

}
function testCheckForAdmin() public {
bool isAdmin = gas.checkForAdmin(owner);
assertEq(isAdmin, true);
}

// TODO: No Specification
function testGetPaymentHistory() public {}

// TODO: No Specification
function testGetTradingMode() public {}

// TODO: No Specification
function testAddHistory() public {}

function testTransfer(uint256 _amount, address _recipient) public {
vm.assume(_amount <= totalSupply);
vm.startPrank(owner);

uint256 ownerBal = gas.balanceOf(owner);
uint256 balBefore = gas.balanceOf(_recipient);
gas.transfer(_recipient, _amount, "name");
uint256 balAfter = gas.balanceOf(_recipient);

assertEq(balAfter, balBefore + _amount);
assertEq(gas.balanceOf(owner), ownerBal - _amount);
}

function testAddToWhitelist(address user, uint256 tier) public {
vm.expectRevert();
vm.startPrank(user);
vm.assume(user != owner);
gas.addToWhitelist(user, tier);
vm.stopPrank();
}

function testGetPaymentStatus(address sender) public {
}

0 comments on commit 2b377ac

Please sign in to comment.