It allows one person to date multiple partner, which does not ensures genuine connection.
pragma solidity ^0.8.19;
import "forge-std/Test.sol";
import "../src/SoulboundProfileNFT.sol";
import "../src/LikeRegistry.sol";
contract TestLikeRegistry is Test {
SoulboundProfileNFT soulboundNFT;
address Alice = address(0x123);
address Bob = address(0x456);
address Eve = address(0x789);
address owner = makeAddr("owner");
LikeRegistry likeRegistry;
function setUp() public {
vm.prank(owner);
soulboundNFT = new SoulboundProfileNFT();
vm.prank(owner);
likeRegistry = new LikeRegistry(address(soulboundNFT));
}
modifier createProfile() {
vm.prank(Alice);
soulboundNFT.mintProfile("Alice", 25, "ipfs://profileImage");
vm.prank(Bob);
soulboundNFT.mintProfile("Bob", 25, "ipfs://profileImage");
vm.prank(Eve);
soulboundNFT.mintProfile("Eve", 25, "ipfs://profileImage");
vm.deal(Alice, 10 ether);
vm.deal(Bob, 10 ether);
vm.deal(Eve, 10 ether);
_;
}
function testMultipleMatchedProfile() public createProfile {
vm.prank(Alice);
(bool success,) = address(likeRegistry).call{value: 1 ether}(abi.encodeWithSignature("likeUser(address)", Bob));
vm.prank(Bob);
(bool success2,) =
address(likeRegistry).call{value: 1 ether}(abi.encodeWithSignature("likeUser(address)", Alice));
vm.prank(Eve);
(bool success3,) = address(likeRegistry).call{value: 1 ether}(abi.encodeWithSignature("likeUser(address)", Bob));
vm.prank(Bob);
(bool success4,) = address(likeRegistry).call{value: 1 ether}(abi.encodeWithSignature("likeUser(address)", Eve));
vm.prank(Bob);
address[] memory userLikes = likeRegistry.getMatches();
assert(userLikes.length == 2);
for (uint256 i; i < userLikes.length; i++) {
console.log(userLikes[i]);
}
}
/
* Ran 1 test for test/testLikeRegistry.t.sol:TestLikeRegistry
* [PASS] testMultipleMatchedProfile() (gas: 5084272)
* Logs:
* 0x0000000000000000000000000000000000000123
* 0x0000000000000000000000000000000000000789
*
* Suite result: ok. 1 passed; 0 failed; 0 skipped; finished in 2.13ms (868.20µs CPU time)
*/
}
Here we are checking if liked address is already match with someone.