pragma solidity ^0.8.19;
import {Test} from "forge-std/Test.sol";
import {console2} from "forge-std/console2.sol";
import {LikeRegistry} from "../src/LikeRegistry.sol";
import {SoulboundProfileNFT} from "../src/SoulboundProfileNFT.sol";
contract LikeRegistryTest is Test {
LikeRegistry likeRegistry;
SoulboundProfileNFT soulboundProfileNFT;
uint256 initialBalance = 100 ether;
address USER1 = makeAddr("User 1");
address USER2 = makeAddr("User 2");
function setUp() public {
soulboundProfileNFT = new SoulboundProfileNFT();
likeRegistry = new LikeRegistry(address(soulboundProfileNFT));
vm.deal(USER1, initialBalance);
vm.deal(USER2, initialBalance);
}
function test_if_userBalances_is_not_updated() public {
_mintSoulNFT(USER1, "User 1", 20, "https://example.com/image.png");
_mintSoulNFT(USER2, "User 2", 20, "https://example.com/image.png");
_mutualLike(USER1, USER2);
uint256 user1Balance = likeRegistry.userBalances(USER1);
uint256 user2Balance = likeRegistry.userBalances(USER2);
assertEq(user1Balance, initialBalance);
assertEq(user2Balance, initialBalance);
}
function _mutualLike(address user1, address user2) internal {
vm.prank(user1);
likeRegistry.likeUser{value: initialBalance}(user2);
_getBalance(user1);
vm.prank(user2);
likeRegistry.likeUser{value: initialBalance}(user1);
_getBalance(user2);
_getTotalFees();
}
function _mintSoulNFT(address user, string memory name, uint8 age, string memory profileImage) internal {
vm.prank(user);
soulboundProfileNFT.mintProfile(name, age, profileImage);
}
function _getBalance(address user) internal view {
console2.log("address of user:", user);
console2.log("user balance in ca:likeRegister", user.balance);
}
function _getTotalFees() internal view {
console2.log("total fees in ca:likeRegister", likeRegistry.getTotalFees());
}
}
function likeUser(address liked) external payable {
require(msg.value >= 1 ether, "Must send at least 1 ETH");
require(!likes[msg.sender][liked], "Already liked");
require(msg.sender != liked, "Cannot like yourself");
require(profileNFT.profileToToken(msg.sender) != 0, "Must have a profile NFT");
require(profileNFT.profileToToken(liked) != 0, "Liked user must have a profile NFT");
likes[msg.sender][liked] = true;
+ userBalances[msg.sender] += msg.value;
emit Liked(msg.sender, liked);
// Check if mutual like
if (likes[liked][msg.sender]) {
matches[msg.sender].push(liked);
matches[liked].push(msg.sender);
emit Matched(msg.sender, liked);
matchRewards(liked, msg.sender);
}
}