mirror of
https://github.com/lens-protocol/core.git
synced 2026-04-22 03:02:03 -04:00
test: Some test fixed
Co-authored-by: Victor Naumik <vicnaum@gmail.com>
This commit is contained in:
@@ -81,7 +81,7 @@ contract CollectingTest_Generic is CollectingTest_Base {
|
||||
);
|
||||
|
||||
vm.startPrank(collectorProfileOwner);
|
||||
vm.expectRevert(Errors.PublicationDoesNotExist.selector);
|
||||
vm.expectRevert(Errors.CollectNotAllowed.selector);
|
||||
_mockCollect();
|
||||
vm.stopPrank();
|
||||
}
|
||||
@@ -98,7 +98,7 @@ contract CollectingTest_Generic is CollectingTest_Base {
|
||||
);
|
||||
|
||||
vm.startPrank(collectorProfileOwner);
|
||||
vm.expectRevert(Errors.PublicationDoesNotExist.selector);
|
||||
vm.expectRevert(Errors.CollectNotAllowed.selector);
|
||||
_mockCollect();
|
||||
vm.stopPrank();
|
||||
}
|
||||
@@ -119,6 +119,21 @@ contract CollectingTest_Generic is CollectingTest_Base {
|
||||
_mockCollect();
|
||||
}
|
||||
|
||||
function testCannotCollectMirror() public {
|
||||
_checkCollectNFTBefore();
|
||||
|
||||
// Mirror once
|
||||
vm.prank(profileOwner);
|
||||
uint256 mirrorPubId = hub.mirror(mockMirrorParams);
|
||||
|
||||
// Collecting the mirror
|
||||
mockCollectParams.publicationCollectedId = mirrorPubId;
|
||||
|
||||
vm.prank(collectorProfileOwner);
|
||||
vm.expectRevert(Errors.CollectNotAllowed.selector);
|
||||
_mockCollect();
|
||||
}
|
||||
|
||||
// SCENARIOS
|
||||
|
||||
function testCollect() public {
|
||||
@@ -143,30 +158,6 @@ contract CollectingTest_Generic is CollectingTest_Base {
|
||||
_checkCollectNFTAfter(nftId, startNftId + 1);
|
||||
}
|
||||
|
||||
function testCollectMirrorOfMirrorPointsToOriginalPost() public {
|
||||
uint256 startNftId = _checkCollectNFTBefore();
|
||||
uint256 startMirrorId = mockMirrorParams.pointedPubId;
|
||||
|
||||
// mirror once
|
||||
vm.startPrank(profileOwner);
|
||||
uint256 newPubId = hub.mirror(mockMirrorParams);
|
||||
assertEq(newPubId, startMirrorId + 1);
|
||||
|
||||
// mirror again
|
||||
mockMirrorParams.pointedPubId = newPubId;
|
||||
newPubId = hub.mirror(mockMirrorParams);
|
||||
assertEq(newPubId, startMirrorId + 2);
|
||||
|
||||
// We're expecting a mirror to point at the original post ID
|
||||
mockCollectParams.publicationCollectedId = startMirrorId;
|
||||
vm.stopPrank();
|
||||
|
||||
vm.prank(collectorProfileOwner);
|
||||
uint256 nftId = _mockCollect();
|
||||
|
||||
_checkCollectNFTAfter(nftId, startNftId + 1);
|
||||
}
|
||||
|
||||
function testExecutorCollect() public {
|
||||
uint256 startNftId = _checkCollectNFTBefore();
|
||||
|
||||
|
||||
@@ -345,15 +345,15 @@ contract EventTest is BaseTest {
|
||||
|
||||
// Collected
|
||||
vm.expectEmit(true, true, true, true, address(hub));
|
||||
emit Events.Collected(
|
||||
newProfileId, // TODO: Replace with proper ProfileID
|
||||
newProfileId,
|
||||
expectedPubId,
|
||||
newProfileId,
|
||||
expectedPubId,
|
||||
'',
|
||||
block.timestamp
|
||||
);
|
||||
emit Events.Collected({
|
||||
publicationCollectedProfileId: newProfileId, // TODO: Replace with proper ProfileID
|
||||
publicationCollectedId: expectedPubId,
|
||||
collectorProfileId: newProfileId,
|
||||
referrerProfileId: 0,
|
||||
referrerPubId: 0,
|
||||
collectModuleData: '',
|
||||
timestamp: block.timestamp
|
||||
});
|
||||
|
||||
// TODO: Replace with proper ProfileID
|
||||
hub.collect(
|
||||
@@ -374,14 +374,13 @@ contract EventTest is BaseTest {
|
||||
followTargetIds[0] = 1;
|
||||
bytes[] memory followDatas = new bytes[](1);
|
||||
followDatas[0] = '';
|
||||
uint256 expectedPubId = 1;
|
||||
address expectedCollectNFTAddress = predictContractAddress(address(hub), 0);
|
||||
string memory expectedNFTName = '1-Collect-1';
|
||||
string memory expectedNFTSymbol = '1-Cl-1';
|
||||
|
||||
vm.startPrank(profileOwner);
|
||||
hub.post(mockPostParams);
|
||||
hub.mirror(mockMirrorParams);
|
||||
uint256 postId = hub.post(mockPostParams);
|
||||
uint256 mirrorId = hub.mirror(mockMirrorParams);
|
||||
|
||||
// BaseInitialized
|
||||
vm.expectEmit(false, false, false, true, expectedCollectNFTAddress);
|
||||
@@ -389,13 +388,13 @@ contract EventTest is BaseTest {
|
||||
|
||||
// CollectNFTInitialized
|
||||
vm.expectEmit(true, true, true, true, expectedCollectNFTAddress);
|
||||
emit Events.CollectNFTInitialized(newProfileId, expectedPubId, block.timestamp);
|
||||
emit Events.CollectNFTInitialized(newProfileId, postId, block.timestamp);
|
||||
|
||||
// CollectNFTDeployed
|
||||
vm.expectEmit(true, true, true, true, address(hub));
|
||||
emit Events.CollectNFTDeployed(
|
||||
newProfileId,
|
||||
expectedPubId,
|
||||
postId,
|
||||
expectedCollectNFTAddress,
|
||||
block.timestamp
|
||||
);
|
||||
@@ -404,7 +403,7 @@ contract EventTest is BaseTest {
|
||||
vm.expectEmit(true, true, true, true, address(hub));
|
||||
emit Events.CollectNFTTransferred(
|
||||
newProfileId,
|
||||
expectedPubId,
|
||||
postId,
|
||||
1, // collect nft id
|
||||
address(0),
|
||||
profileOwner,
|
||||
@@ -417,24 +416,24 @@ contract EventTest is BaseTest {
|
||||
|
||||
// Collected
|
||||
vm.expectEmit(true, true, true, true, address(hub));
|
||||
emit Events.Collected(
|
||||
newProfileId, // TODO: Replace with proper ProfileID
|
||||
newProfileId,
|
||||
expectedPubId,
|
||||
newProfileId,
|
||||
expectedPubId,
|
||||
'',
|
||||
block.timestamp
|
||||
);
|
||||
emit Events.Collected({
|
||||
publicationCollectedProfileId: newProfileId, // TODO: Replace with proper ProfileID
|
||||
publicationCollectedId: postId,
|
||||
collectorProfileId: newProfileId,
|
||||
referrerProfileId: newProfileId,
|
||||
referrerPubId: mirrorId,
|
||||
collectModuleData: '',
|
||||
timestamp: block.timestamp
|
||||
});
|
||||
|
||||
// TODO: Replace with proper ProfileID
|
||||
hub.collect(
|
||||
DataTypes.CollectParams({
|
||||
publicationCollectedProfileId: 1,
|
||||
publicationCollectedId: expectedPubId,
|
||||
publicationCollectedProfileId: newProfileId,
|
||||
publicationCollectedId: postId,
|
||||
collectorProfileId: newProfileId,
|
||||
referrerProfileId: 0,
|
||||
referrerPubId: 0,
|
||||
referrerProfileId: newProfileId,
|
||||
referrerPubId: mirrorId,
|
||||
collectModuleData: ''
|
||||
})
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user