「🏗️」 wip: test not passing 😭
This commit is contained in:
86
code/test/Kanel42_token.t.sol
Normal file
86
code/test/Kanel42_token.t.sol
Normal file
@ -0,0 +1,86 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
pragma solidity 0.8.28;
|
||||
|
||||
import "../../lib/forge-std/src/Test.sol";
|
||||
import "../Kanel42_token.sol";
|
||||
|
||||
contract Kanel42TokenTest is Test {
|
||||
Kanel42_token public token;
|
||||
|
||||
// This function runs before each test
|
||||
function setUp() public {
|
||||
token = new Kanel42_token();
|
||||
}
|
||||
|
||||
// Test the initial supply of the token
|
||||
function testInitialSupply() public {
|
||||
assertEq(token.totalSupply(), 8000000000);
|
||||
assertEq(token.totalMinted(), 0);
|
||||
}
|
||||
|
||||
// Test minting tokens
|
||||
function testMint() public {
|
||||
uint256 initialBalance = token.balanceOf(address(this));
|
||||
uint256 mintAmount = 1000000; // Mint 1 token (considering 6 decimals)
|
||||
|
||||
// Mint tokens by sending ether
|
||||
vm.deal(address(this), 0.01 ether);
|
||||
token.mint{ value: 0.01 ether }();
|
||||
|
||||
uint256 finalBalance = token.balanceOf(address(this));
|
||||
assertEq(finalBalance - initialBalance, mintAmount);
|
||||
}
|
||||
|
||||
// // Test transferring tokens
|
||||
// function testTransfer() public {
|
||||
// address sender = address(this);
|
||||
// address recipient = address(1);
|
||||
// uint256 transferAmount = 1000000; // Transfer 1 token (considering 6 decimals)
|
||||
//
|
||||
// // Mint tokens to the sender
|
||||
// vm.deal(sender, 0.01 ether);
|
||||
// token.mint{ value: 0.01 ether }();
|
||||
//
|
||||
// // Transfer tokens to the recipient
|
||||
// token.transfer(recipient, transferAmount);
|
||||
//
|
||||
// assertEq(token.balanceOf(recipient), transferAmount);
|
||||
// }
|
||||
//
|
||||
// // Test burning tokens
|
||||
// function testBurn() public {
|
||||
// uint256 initialBalance = token.balanceOf(address(this));
|
||||
// uint256 burnAmount = 1000000; // Burn 1 token (considering 6 decimals)
|
||||
//
|
||||
// // Mint tokens to have something to burn
|
||||
// vm.deal(address(this), 0.01 ether);
|
||||
// token.mint{ value: 0.01 ether }();
|
||||
//
|
||||
// // Burn tokens
|
||||
// token.burn(burnAmount);
|
||||
//
|
||||
// uint256 finalBalance = token.balanceOf(address(this));
|
||||
// assertEq(initialBalance, finalBalance + burnAmount);
|
||||
// }
|
||||
//
|
||||
// // Test approval and transferFrom
|
||||
// function testApproveAndTransferFrom() public {
|
||||
// address owner = address(this);
|
||||
// address spender = address(1);
|
||||
// address recipient = address(2);
|
||||
// uint256 approveAmount = 1000000; // Approve 1 token (considering 6 decimals)
|
||||
//
|
||||
// // Mint tokens to the owner
|
||||
// vm.deal(owner, 0.01 ether);
|
||||
// token.mint{ value: 0.01 ether }();
|
||||
//
|
||||
// // Approve spender to spend tokens on behalf of owner
|
||||
// token.approve(spender, approveAmount);
|
||||
//
|
||||
// // Transfer tokens from owner to recipient using transferFrom
|
||||
// vm.prank(spender);
|
||||
// token.transferFrom(owner, recipient, approveAmount);
|
||||
//
|
||||
// assertEq(token.balanceOf(recipient), approveAmount);
|
||||
// }
|
||||
}
|
Reference in New Issue
Block a user