mirror of
https://github.com/lens-protocol/core.git
synced 2026-04-22 03:02:03 -04:00
Merge remote-tracking branch 'origin/feat/quote-publication' into T-6536/-refactor-remove-all-withsig-data-types
This commit is contained in:
@@ -4,10 +4,11 @@ pragma solidity ^0.8.13;
|
||||
import './base/BaseTest.t.sol';
|
||||
import './helpers/SignatureHelpers.sol';
|
||||
import './helpers/CollectingHelpers.sol';
|
||||
import './MetaTxNegatives.t.sol';
|
||||
|
||||
// TODO add check for _initialize() called for fork tests - check name and symbol set
|
||||
|
||||
contract CollectingTest_Base is BaseTest, CollectingHelpers, SigSetup {
|
||||
contract CollectingTest is BaseTest, CollectingHelpers, SigSetup {
|
||||
uint256 constant collectorProfileOwnerPk = 0xC011EEC7012;
|
||||
address collectorProfileOwner;
|
||||
uint256 collectorProfileId;
|
||||
@@ -15,30 +16,6 @@ contract CollectingTest_Base is BaseTest, CollectingHelpers, SigSetup {
|
||||
uint256 constant userWithoutProfilePk = 0x105312;
|
||||
address userWithoutProfile;
|
||||
|
||||
function _mockCollect() internal virtual returns (uint256) {
|
||||
return
|
||||
_collect(
|
||||
mockCollectParams.collectorProfileId,
|
||||
mockCollectParams.publicationCollectedProfileId,
|
||||
mockCollectParams.publicationCollectedId,
|
||||
mockCollectParams.collectModuleData
|
||||
);
|
||||
}
|
||||
|
||||
function _mockCollectWithSig(address delegatedSigner, uint256 signerPrivKey)
|
||||
internal
|
||||
virtual
|
||||
returns (uint256)
|
||||
{
|
||||
bytes32 digest = _getCollectTypedDataHash(mockCollectParams, nonce, deadline);
|
||||
|
||||
return
|
||||
_collectWithSig(
|
||||
mockCollectParams,
|
||||
_getSigStruct(delegatedSigner, signerPrivKey, digest, deadline)
|
||||
);
|
||||
}
|
||||
|
||||
function setUp() public virtual override(SigSetup, TestSetup) {
|
||||
TestSetup.setUp();
|
||||
SigSetup.setUp();
|
||||
@@ -53,11 +30,14 @@ contract CollectingTest_Base is BaseTest, CollectingHelpers, SigSetup {
|
||||
|
||||
mockCollectParams.collectorProfileId = collectorProfileId;
|
||||
}
|
||||
}
|
||||
|
||||
contract CollectingTest_Generic is CollectingTest_Base {
|
||||
function setUp() public override {
|
||||
CollectingTest_Base.setUp();
|
||||
function _collect(
|
||||
uint256, /* metaTxSignerPk */
|
||||
address transactionExecutor,
|
||||
DataTypes.CollectParams memory collectParams
|
||||
) internal virtual returns (uint256) {
|
||||
vm.prank(transactionExecutor);
|
||||
return hub.collect(collectParams);
|
||||
}
|
||||
|
||||
// NEGATIVES
|
||||
@@ -65,8 +45,7 @@ contract CollectingTest_Generic is CollectingTest_Base {
|
||||
// Also acts like a test for cannot collect specifying another (non-owned) profile as a parameter
|
||||
function testCannotCollectIfNotExecutor() public {
|
||||
vm.expectRevert(Errors.ExecutorInvalid.selector);
|
||||
vm.startPrank(otherSigner);
|
||||
_mockCollect();
|
||||
_collect(collectorProfileOwnerPk, otherSigner, mockCollectParams);
|
||||
}
|
||||
|
||||
function testCannotCollectIfNonexistantPub() public {
|
||||
@@ -80,9 +59,8 @@ contract CollectingTest_Generic is CollectingTest_Base {
|
||||
0
|
||||
);
|
||||
|
||||
vm.startPrank(collectorProfileOwner);
|
||||
vm.expectRevert(Errors.CollectNotAllowed.selector);
|
||||
_mockCollect();
|
||||
_collect(collectorProfileOwnerPk, collectorProfileOwner, mockCollectParams);
|
||||
vm.stopPrank();
|
||||
}
|
||||
|
||||
@@ -97,17 +75,15 @@ contract CollectingTest_Generic is CollectingTest_Base {
|
||||
0
|
||||
);
|
||||
|
||||
vm.startPrank(collectorProfileOwner);
|
||||
vm.expectRevert(Errors.CollectNotAllowed.selector);
|
||||
_mockCollect();
|
||||
_collect(collectorProfileOwnerPk, collectorProfileOwner, mockCollectParams);
|
||||
vm.stopPrank();
|
||||
}
|
||||
|
||||
function testCannotCollect_WithoutProfile() public {
|
||||
mockCollectParams.collectorProfileId = _getNextProfileId(); // Non-existent profile
|
||||
vm.startPrank(userWithoutProfile);
|
||||
vm.expectRevert(Errors.TokenDoesNotExist.selector);
|
||||
_mockCollect();
|
||||
_collect(userWithoutProfilePk, userWithoutProfile, mockCollectParams);
|
||||
vm.stopPrank();
|
||||
}
|
||||
|
||||
@@ -115,8 +91,7 @@ contract CollectingTest_Generic is CollectingTest_Base {
|
||||
vm.prank(profileOwner);
|
||||
hub.setBlockStatus(newProfileId, _toUint256Array(collectorProfileId), _toBoolArray(true));
|
||||
vm.expectRevert(Errors.Blocked.selector);
|
||||
vm.startPrank(collectorProfileOwner);
|
||||
_mockCollect();
|
||||
_collect(collectorProfileOwnerPk, collectorProfileOwner, mockCollectParams);
|
||||
}
|
||||
|
||||
function testCannotCollectMirror() public {
|
||||
@@ -129,9 +104,8 @@ contract CollectingTest_Generic is CollectingTest_Base {
|
||||
// Collecting the mirror
|
||||
mockCollectParams.publicationCollectedId = mirrorPubId;
|
||||
|
||||
vm.prank(collectorProfileOwner);
|
||||
vm.expectRevert(Errors.CollectNotAllowed.selector);
|
||||
_mockCollect();
|
||||
_collect(collectorProfileOwnerPk, collectorProfileOwner, mockCollectParams);
|
||||
}
|
||||
|
||||
// SCENARIOS
|
||||
@@ -139,9 +113,7 @@ contract CollectingTest_Generic is CollectingTest_Base {
|
||||
function testCollect() public {
|
||||
uint256 startNftId = _checkCollectNFTBefore();
|
||||
|
||||
vm.startPrank(collectorProfileOwner);
|
||||
uint256 nftId = _mockCollect();
|
||||
vm.stopPrank();
|
||||
uint256 nftId = _collect(collectorProfileOwnerPk, collectorProfileOwner, mockCollectParams);
|
||||
|
||||
_checkCollectNFTAfter(nftId, startNftId + 1);
|
||||
}
|
||||
@@ -152,8 +124,7 @@ contract CollectingTest_Generic is CollectingTest_Base {
|
||||
vm.prank(profileOwner);
|
||||
hub.mirror(mockMirrorParams);
|
||||
|
||||
vm.prank(collectorProfileOwner);
|
||||
uint256 nftId = _mockCollect();
|
||||
uint256 nftId = _collect(collectorProfileOwnerPk, collectorProfileOwner, mockCollectParams);
|
||||
|
||||
_checkCollectNFTAfter(nftId, startNftId + 1);
|
||||
}
|
||||
@@ -170,9 +141,7 @@ contract CollectingTest_Generic is CollectingTest_Base {
|
||||
);
|
||||
|
||||
// collect from executor
|
||||
vm.startPrank(otherSigner);
|
||||
uint256 nftId = _mockCollect();
|
||||
vm.stopPrank();
|
||||
uint256 nftId = _collect(otherSignerKey, otherSigner, mockCollectParams);
|
||||
|
||||
_checkCollectNFTAfter(nftId, startNftId + 1);
|
||||
}
|
||||
@@ -191,170 +160,58 @@ contract CollectingTest_Generic is CollectingTest_Base {
|
||||
);
|
||||
|
||||
// collect from executor
|
||||
vm.startPrank(otherSigner);
|
||||
uint256 nftId = _mockCollect();
|
||||
vm.stopPrank();
|
||||
uint256 nftId = _collect(otherSignerKey, otherSigner, mockCollectParams);
|
||||
|
||||
_checkCollectNFTAfter(nftId, startNftId + 1);
|
||||
}
|
||||
}
|
||||
|
||||
contract CollectingTest_WithSig is CollectingTest_Base {
|
||||
function setUp() public override {
|
||||
CollectingTest_Base.setUp();
|
||||
contract CollectingTestMetaTx is CollectingTest, MetaTxNegatives {
|
||||
mapping(address => uint256) cachedNonceByAddress;
|
||||
|
||||
function setUp() public override(CollectingTest, MetaTxNegatives) {
|
||||
CollectingTest.setUp();
|
||||
MetaTxNegatives.setUp();
|
||||
|
||||
cachedNonceByAddress[collectorProfileOwner] = _getSigNonce(collectorProfileOwner);
|
||||
}
|
||||
|
||||
// NEGATIVES
|
||||
|
||||
// Also acts like a test for cannot collect specifying another (non-owned) profile as a parameter
|
||||
function testCannotCollectWithSigIfNotExecutor() public {
|
||||
vm.expectRevert(Errors.ExecutorInvalid.selector);
|
||||
_mockCollectWithSig({delegatedSigner: otherSigner, signerPrivKey: otherSignerKey});
|
||||
}
|
||||
|
||||
function testCannotCollectWithSigIfNonexistantPub() public {
|
||||
mockCollectParams.publicationCollectedId = 2;
|
||||
// Check that the publication doesn't exist.
|
||||
assertEq(
|
||||
_getPub(
|
||||
mockCollectParams.publicationCollectedProfileId,
|
||||
mockCollectParams.publicationCollectedId
|
||||
).pointedProfileId,
|
||||
0
|
||||
function _collect(
|
||||
uint256 metaTxSignerPk,
|
||||
address transactionExecutor,
|
||||
DataTypes.CollectParams memory collectParams
|
||||
) internal override returns (uint256) {
|
||||
address signer = vm.addr(metaTxSignerPk);
|
||||
uint256 deadline = type(uint256).max;
|
||||
bytes32 digest = _getCollectTypedDataHash(
|
||||
collectParams,
|
||||
cachedNonceByAddress[signer],
|
||||
deadline
|
||||
);
|
||||
|
||||
vm.expectRevert(Errors.PublicationDoesNotExist.selector);
|
||||
_mockCollectWithSig({delegatedSigner: address(0), signerPrivKey: collectorProfileOwnerPk});
|
||||
return
|
||||
hub.collectWithSig(
|
||||
collectParams,
|
||||
_getSigStruct(transactionExecutor, metaTxSignerPk, digest, deadline)
|
||||
);
|
||||
}
|
||||
|
||||
function testCannotCollectWithSigIfZeroPub() public {
|
||||
mockCollectParams.publicationCollectedId = 0;
|
||||
// Check that the publication doesn't exist.
|
||||
assertEq(
|
||||
_getPub(
|
||||
mockCollectParams.publicationCollectedProfileId,
|
||||
mockCollectParams.publicationCollectedId
|
||||
).pointedProfileId,
|
||||
0
|
||||
function _executeMetaTx(
|
||||
uint256 signerPk,
|
||||
uint256 nonce,
|
||||
uint256 deadline
|
||||
) internal override {
|
||||
_collectWithSig(
|
||||
mockCollectParams,
|
||||
_getSigStruct(
|
||||
collectorProfileOwner,
|
||||
signerPk,
|
||||
_getCollectTypedDataHash(mockCollectParams, nonce, deadline),
|
||||
deadline
|
||||
)
|
||||
);
|
||||
|
||||
vm.expectRevert(Errors.PublicationDoesNotExist.selector);
|
||||
_mockCollectWithSig({delegatedSigner: address(0), signerPrivKey: collectorProfileOwnerPk});
|
||||
}
|
||||
|
||||
function testCannotCollectWithSig_WithoutProfile() public {
|
||||
mockCollectParams.collectorProfileId = _getNextProfileId(); // Non-existent profile
|
||||
vm.expectRevert(Errors.TokenDoesNotExist.selector);
|
||||
_mockCollectWithSig({delegatedSigner: address(0), signerPrivKey: userWithoutProfilePk});
|
||||
}
|
||||
|
||||
function testCannotCollectWithSigOnExpiredDeadline() public {
|
||||
deadline = block.timestamp - 1;
|
||||
vm.expectRevert(Errors.SignatureExpired.selector);
|
||||
_mockCollectWithSig({delegatedSigner: address(0), signerPrivKey: collectorProfileOwnerPk});
|
||||
}
|
||||
|
||||
function testCannotCollectWithSigOnInvalidNonce() public {
|
||||
nonce = 5;
|
||||
vm.expectRevert(Errors.SignatureInvalid.selector);
|
||||
_mockCollectWithSig({delegatedSigner: address(0), signerPrivKey: collectorProfileOwnerPk});
|
||||
}
|
||||
|
||||
function testCannotCollectIfNonceWasIncrementedWithAnotherAction() public {
|
||||
assertEq(_getSigNonce(collectorProfileOwner), nonce, 'Wrong nonce before posting');
|
||||
|
||||
uint256 expectedCollectId = _getCollectCount(
|
||||
collectorProfileId,
|
||||
mockCollectParams.publicationCollectedId
|
||||
) + 1;
|
||||
|
||||
uint256 nftId = _mockCollectWithSig({
|
||||
delegatedSigner: address(0),
|
||||
signerPrivKey: collectorProfileOwnerPk
|
||||
});
|
||||
|
||||
assertEq(nftId, expectedCollectId, 'Wrong collectId');
|
||||
|
||||
assertTrue(_getSigNonce(collectorProfileOwner) != nonce, 'Wrong nonce after collecting');
|
||||
|
||||
vm.expectRevert(Errors.SignatureInvalid.selector);
|
||||
_mockCollectWithSig({delegatedSigner: address(0), signerPrivKey: collectorProfileOwnerPk});
|
||||
}
|
||||
|
||||
function testCannotCollectWithSigIfBlocked() public {
|
||||
vm.prank(profileOwner);
|
||||
hub.setBlockStatus(newProfileId, _toUint256Array(collectorProfileId), _toBoolArray(true));
|
||||
vm.expectRevert(Errors.Blocked.selector);
|
||||
vm.startPrank(collectorProfileOwner);
|
||||
_mockCollectWithSig({delegatedSigner: address(0), signerPrivKey: collectorProfileOwnerPk});
|
||||
}
|
||||
|
||||
// SCENARIOS
|
||||
|
||||
function testCollectWithSig() public {
|
||||
uint256 startNftId = _checkCollectNFTBefore();
|
||||
|
||||
uint256 nftId = _mockCollectWithSig({
|
||||
delegatedSigner: address(0),
|
||||
signerPrivKey: collectorProfileOwnerPk
|
||||
});
|
||||
|
||||
_checkCollectNFTAfter(nftId, startNftId + 1);
|
||||
}
|
||||
|
||||
function testCollectWithSigMirror() public {
|
||||
uint256 startNftId = _checkCollectNFTBefore();
|
||||
|
||||
vm.prank(profileOwner);
|
||||
hub.mirror(mockMirrorParams);
|
||||
|
||||
uint256 nftId = _mockCollectWithSig({
|
||||
delegatedSigner: address(0),
|
||||
signerPrivKey: collectorProfileOwnerPk
|
||||
});
|
||||
|
||||
_checkCollectNFTAfter(nftId, startNftId + 1);
|
||||
}
|
||||
|
||||
function testExecutorCollectWithSig() public {
|
||||
uint256 startNftId = _checkCollectNFTBefore();
|
||||
|
||||
// delegate power to executor
|
||||
_changeDelegatedExecutorsConfig(
|
||||
collectorProfileOwner,
|
||||
collectorProfileId,
|
||||
otherSigner,
|
||||
true
|
||||
);
|
||||
|
||||
// collect from executor
|
||||
uint256 nftId = _mockCollectWithSig({
|
||||
delegatedSigner: otherSigner,
|
||||
signerPrivKey: otherSignerKey
|
||||
});
|
||||
|
||||
_checkCollectNFTAfter(nftId, startNftId + 1);
|
||||
}
|
||||
|
||||
function testExecutorCollectWithSigMirror() public {
|
||||
uint256 startNftId = _checkCollectNFTBefore();
|
||||
|
||||
// mirror, then delegate power to executor
|
||||
vm.prank(profileOwner);
|
||||
hub.mirror(mockMirrorParams);
|
||||
_changeDelegatedExecutorsConfig(
|
||||
collectorProfileOwner,
|
||||
collectorProfileId,
|
||||
otherSigner,
|
||||
true
|
||||
);
|
||||
|
||||
// collect from executor
|
||||
uint256 nftId = _mockCollectWithSig({
|
||||
delegatedSigner: otherSigner,
|
||||
signerPrivKey: otherSignerKey
|
||||
});
|
||||
|
||||
_checkCollectNFTAfter(nftId, startNftId + 1);
|
||||
function _getDefaultMetaTxSignerPk() internal pure override returns (uint256) {
|
||||
return collectorProfileOwnerPk;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,31 +64,31 @@ abstract contract PublishingTest is BaseTest, PublishingHelpers, SigSetup {
|
||||
mockPostParams.collectModule = address(0xC0FFEE);
|
||||
replicateInitData();
|
||||
vm.expectRevert(Errors.CollectModuleNotWhitelisted.selector);
|
||||
_publishWithSig({delegatedSigner: address(0), signerPrivKey: profileOwnerKey});
|
||||
_publishWithSig({delegatedSigner: profileOwner, signerPrivKey: profileOwnerKey});
|
||||
}
|
||||
|
||||
function testCannotPublishWithSigNotWhitelistedReferenceModule() public virtual {
|
||||
mockPostParams.referenceModule = address(0xC0FFEE);
|
||||
replicateInitData();
|
||||
vm.expectRevert(Errors.ReferenceModuleNotWhitelisted.selector);
|
||||
_publishWithSig({delegatedSigner: address(0), signerPrivKey: profileOwnerKey});
|
||||
_publishWithSig({delegatedSigner: profileOwner, signerPrivKey: profileOwnerKey});
|
||||
}
|
||||
|
||||
function testCannotPublishWithSigInvalidSigner() public {
|
||||
vm.expectRevert(Errors.SignatureInvalid.selector);
|
||||
_publishWithSig({delegatedSigner: address(0), signerPrivKey: otherSignerKey});
|
||||
_publishWithSig({delegatedSigner: profileOwner, signerPrivKey: otherSignerKey});
|
||||
}
|
||||
|
||||
function testCannotPublishWithSigInvalidNonce() public {
|
||||
nonce = _getSigNonce(otherSigner) + 1;
|
||||
vm.expectRevert(Errors.SignatureInvalid.selector);
|
||||
_publishWithSig({delegatedSigner: address(0), signerPrivKey: otherSignerKey});
|
||||
_publishWithSig({delegatedSigner: profileOwner, signerPrivKey: otherSignerKey});
|
||||
}
|
||||
|
||||
function testCannotPublishWithSigInvalidDeadline() public {
|
||||
vm.expectRevert(Errors.SignatureInvalid.selector);
|
||||
_publishWithSig({
|
||||
delegatedSigner: address(0),
|
||||
delegatedSigner: profileOwner,
|
||||
signerPrivKey: profileOwnerKey,
|
||||
digestDeadline: type(uint256).max,
|
||||
sigDeadline: block.timestamp + 10
|
||||
@@ -101,7 +101,7 @@ abstract contract PublishingTest is BaseTest, PublishingHelpers, SigSetup {
|
||||
uint256 expectedPubId = _getPubCount(newProfileId) + 1;
|
||||
|
||||
uint256 pubId = _publishWithSig({
|
||||
delegatedSigner: address(0),
|
||||
delegatedSigner: profileOwner,
|
||||
signerPrivKey: profileOwnerKey
|
||||
});
|
||||
assertEq(pubId, expectedPubId, 'Wrong pubId');
|
||||
@@ -109,7 +109,7 @@ abstract contract PublishingTest is BaseTest, PublishingHelpers, SigSetup {
|
||||
assertTrue(_getSigNonce(profileOwner) != nonce, 'Wrong nonce after posting');
|
||||
|
||||
vm.expectRevert(Errors.SignatureInvalid.selector);
|
||||
_publishWithSig({delegatedSigner: address(0), signerPrivKey: profileOwnerKey});
|
||||
_publishWithSig({delegatedSigner: profileOwner, signerPrivKey: profileOwnerKey});
|
||||
}
|
||||
|
||||
function testCannotPublishWithSigExpiredDeadline() public {
|
||||
@@ -117,7 +117,7 @@ abstract contract PublishingTest is BaseTest, PublishingHelpers, SigSetup {
|
||||
vm.warp(20);
|
||||
|
||||
vm.expectRevert(Errors.SignatureExpired.selector);
|
||||
_publishWithSig({delegatedSigner: address(0), signerPrivKey: otherSignerKey});
|
||||
_publishWithSig({delegatedSigner: profileOwner, signerPrivKey: otherSignerKey});
|
||||
}
|
||||
|
||||
function testCannotPublishWithSigNotExecutor() public {
|
||||
@@ -158,7 +158,7 @@ abstract contract PublishingTest is BaseTest, PublishingHelpers, SigSetup {
|
||||
uint256 expectedPubId = _getPubCount(newProfileId) + 1;
|
||||
|
||||
uint256 pubId = _publishWithSig({
|
||||
delegatedSigner: address(0),
|
||||
delegatedSigner: profileOwner,
|
||||
signerPrivKey: profileOwnerKey
|
||||
});
|
||||
assertEq(pubId, expectedPubId);
|
||||
@@ -281,7 +281,7 @@ contract CommentTest is PublishingTest {
|
||||
mockCommentParams.pointedPubId = nonExistentPubId;
|
||||
|
||||
vm.prank(profileOwner);
|
||||
vm.expectRevert(Errors.PublicationDoesNotExist.selector);
|
||||
vm.expectRevert(Errors.InvalidPointedPub.selector);
|
||||
_publish();
|
||||
}
|
||||
|
||||
@@ -291,8 +291,8 @@ contract CommentTest is PublishingTest {
|
||||
replicateInitData();
|
||||
mockCommentParams.pointedPubId = nonExistentPubId;
|
||||
|
||||
vm.expectRevert(Errors.PublicationDoesNotExist.selector);
|
||||
_publishWithSig({delegatedSigner: address(0), signerPrivKey: profileOwnerKey});
|
||||
vm.expectRevert(Errors.InvalidPointedPub.selector);
|
||||
_publishWithSig({delegatedSigner: profileOwner, signerPrivKey: profileOwnerKey});
|
||||
}
|
||||
|
||||
function testCannotCommentOnTheSamePublicationBeingCreated() public {
|
||||
@@ -302,7 +302,7 @@ contract CommentTest is PublishingTest {
|
||||
mockCommentParams.pointedPubId = nextPubId;
|
||||
|
||||
vm.prank(profileOwner);
|
||||
vm.expectRevert(Errors.PublicationDoesNotExist.selector);
|
||||
vm.expectRevert(Errors.InvalidPointedPub.selector);
|
||||
_publish();
|
||||
}
|
||||
|
||||
@@ -312,8 +312,8 @@ contract CommentTest is PublishingTest {
|
||||
replicateInitData();
|
||||
mockCommentParams.pointedPubId = nextPubId;
|
||||
|
||||
vm.expectRevert(Errors.PublicationDoesNotExist.selector);
|
||||
_publishWithSig({delegatedSigner: address(0), signerPrivKey: profileOwnerKey});
|
||||
vm.expectRevert(Errors.InvalidPointedPub.selector);
|
||||
_publishWithSig({delegatedSigner: profileOwner, signerPrivKey: profileOwnerKey});
|
||||
}
|
||||
|
||||
function testCannotCommentIfBlocked() public {
|
||||
@@ -340,7 +340,7 @@ contract CommentTest is PublishingTest {
|
||||
_toBoolArray(true)
|
||||
);
|
||||
vm.expectRevert(Errors.Blocked.selector);
|
||||
_publishWithSig({delegatedSigner: address(0), signerPrivKey: profileOwnerKey});
|
||||
_publishWithSig({delegatedSigner: profileOwner, signerPrivKey: profileOwnerKey});
|
||||
}
|
||||
|
||||
// scenarios
|
||||
@@ -358,34 +358,25 @@ contract CommentTest is PublishingTest {
|
||||
_verifyPublication(pub, _expectedPubFromInitData());
|
||||
}
|
||||
|
||||
function testCommentOnMirrorShouldPointToOriginalPost() public {
|
||||
function testCannotCommentOnMirror() public {
|
||||
mockMirrorParams.pointedPubId = postId;
|
||||
vm.prank(profileOwner);
|
||||
uint256 mirrorId = _mirror(mockMirrorParams);
|
||||
|
||||
mockCommentParams.pointedPubId = mirrorId;
|
||||
vm.expectRevert(Errors.InvalidPointedPub.selector);
|
||||
vm.prank(profileOwner);
|
||||
uint256 commentId = _publish();
|
||||
|
||||
DataTypes.PublicationStruct memory pub = _getPub(newProfileId, commentId);
|
||||
mockCommentParams.pointedPubId = postId; // We're expecting a mirror to point at the original post ID
|
||||
_verifyPublication(pub, _expectedPubFromInitData(mockCommentParams));
|
||||
_publish();
|
||||
}
|
||||
|
||||
function testCommentWithSigOnMirrorShouldPointToOriginalPost() public {
|
||||
function testCannotCommentOnMirrorWithSig() public {
|
||||
mockMirrorParams.pointedPubId = postId;
|
||||
vm.prank(profileOwner);
|
||||
uint256 mirrorId = _mirror(mockMirrorParams);
|
||||
|
||||
mockCommentParams.pointedPubId = mirrorId;
|
||||
uint256 commentId = _publishWithSig({
|
||||
delegatedSigner: address(0),
|
||||
signerPrivKey: profileOwnerKey
|
||||
});
|
||||
|
||||
DataTypes.PublicationStruct memory pub = _getPub(newProfileId, commentId);
|
||||
mockCommentParams.pointedPubId = postId; // We're expecting a mirror to point at the original post ID
|
||||
_verifyPublication(pub, _expectedPubFromInitData(mockCommentParams));
|
||||
vm.expectRevert(Errors.InvalidPointedPub.selector);
|
||||
_publishWithSig({delegatedSigner: profileOwner, signerPrivKey: profileOwnerKey});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -449,7 +440,7 @@ contract MirrorTest is PublishingTest {
|
||||
mockMirrorParams.pointedPubId = nonExistentPubId;
|
||||
|
||||
vm.prank(profileOwner);
|
||||
vm.expectRevert(Errors.PublicationDoesNotExist.selector);
|
||||
vm.expectRevert(Errors.InvalidPointedPub.selector);
|
||||
_publish();
|
||||
}
|
||||
|
||||
@@ -459,8 +450,8 @@ contract MirrorTest is PublishingTest {
|
||||
replicateInitData();
|
||||
mockMirrorParams.pointedPubId = nonExistentPubId;
|
||||
|
||||
vm.expectRevert(Errors.PublicationDoesNotExist.selector);
|
||||
_publishWithSig({delegatedSigner: address(0), signerPrivKey: profileOwnerKey});
|
||||
vm.expectRevert(Errors.InvalidPointedPub.selector);
|
||||
_publishWithSig({delegatedSigner: profileOwner, signerPrivKey: profileOwnerKey});
|
||||
}
|
||||
|
||||
function testCannotMirrorIfBlocked() public {
|
||||
@@ -487,37 +478,28 @@ contract MirrorTest is PublishingTest {
|
||||
_toBoolArray(true)
|
||||
);
|
||||
vm.expectRevert(Errors.Blocked.selector);
|
||||
_publishWithSig({delegatedSigner: address(0), signerPrivKey: profileOwnerKey});
|
||||
_publishWithSig({delegatedSigner: profileOwner, signerPrivKey: profileOwnerKey});
|
||||
}
|
||||
|
||||
// scenarios
|
||||
function testMirrorAnotherMirrorShouldPointToOriginalPost() public {
|
||||
function testCannotMirrorAMirror() public {
|
||||
mockMirrorParams.pointedPubId = postId;
|
||||
vm.prank(profileOwner);
|
||||
uint256 firstMirrorId = _publish();
|
||||
|
||||
mockMirrorParams.pointedPubId = firstMirrorId;
|
||||
vm.prank(profileOwner);
|
||||
uint256 secondMirrorId = _publish();
|
||||
|
||||
DataTypes.PublicationStruct memory pub = _getPub(newProfileId, secondMirrorId);
|
||||
mockMirrorParams.pointedPubId = postId; // We're expecting a mirror to point at the original post ID
|
||||
_verifyPublication(pub, _expectedPubFromInitData(mockMirrorParams));
|
||||
vm.expectRevert(Errors.InvalidPointedPub.selector);
|
||||
_publish();
|
||||
}
|
||||
|
||||
function testMirrorAnotherMirrorWithSigShouldPointToOriginalPost() public {
|
||||
function testCannotMirrorAMirrorWithSig() public {
|
||||
mockMirrorParams.pointedPubId = postId;
|
||||
vm.prank(profileOwner);
|
||||
uint256 firstMirrorId = _publish();
|
||||
|
||||
mockMirrorParams.pointedPubId = firstMirrorId;
|
||||
uint256 secondMirrorId = _publishWithSig({
|
||||
delegatedSigner: address(0),
|
||||
signerPrivKey: profileOwnerKey
|
||||
});
|
||||
|
||||
DataTypes.PublicationStruct memory pub = _getPub(newProfileId, secondMirrorId);
|
||||
mockMirrorParams.pointedPubId = postId; // We're expecting a mirror to point at the original post ID
|
||||
_verifyPublication(pub, _expectedPubFromInitData(mockMirrorParams));
|
||||
vm.expectRevert(Errors.InvalidPointedPub.selector);
|
||||
_publishWithSig({delegatedSigner: profileOwner, signerPrivKey: profileOwnerKey});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -163,6 +163,8 @@ contract BaseTest is TestSetup {
|
||||
string memory contentURI,
|
||||
uint256 pointedProfileId,
|
||||
uint256 pointedPubId,
|
||||
uint256 referrerProfileId,
|
||||
uint256 referrerPubId,
|
||||
bytes memory referenceModuleData,
|
||||
address collectModule,
|
||||
bytes memory collectModuleInitData,
|
||||
@@ -178,6 +180,8 @@ contract BaseTest is TestSetup {
|
||||
keccak256(bytes(contentURI)),
|
||||
pointedProfileId,
|
||||
pointedPubId,
|
||||
referrerProfileId,
|
||||
referrerPubId,
|
||||
keccak256(referenceModuleData),
|
||||
collectModule,
|
||||
keccak256(collectModuleInitData),
|
||||
@@ -201,6 +205,8 @@ contract BaseTest is TestSetup {
|
||||
contentURI: commentParams.contentURI,
|
||||
pointedProfileId: commentParams.pointedProfileId,
|
||||
pointedPubId: commentParams.pointedPubId,
|
||||
referrerProfileId: 0,
|
||||
referrerPubId: 0,
|
||||
referenceModuleData: commentParams.referenceModuleData,
|
||||
collectModule: commentParams.collectModule,
|
||||
collectModuleInitData: commentParams.collectModuleInitData,
|
||||
@@ -215,6 +221,8 @@ contract BaseTest is TestSetup {
|
||||
uint256 profileId,
|
||||
uint256 pointedProfileId,
|
||||
uint256 pointedPubId,
|
||||
uint256 referrerProfileId,
|
||||
uint256 referrerPubId,
|
||||
bytes memory referenceModuleData,
|
||||
uint256 nonce,
|
||||
uint256 deadline
|
||||
@@ -225,6 +233,8 @@ contract BaseTest is TestSetup {
|
||||
profileId,
|
||||
pointedProfileId,
|
||||
pointedPubId,
|
||||
referrerProfileId,
|
||||
referrerPubId,
|
||||
keccak256(referenceModuleData),
|
||||
nonce,
|
||||
deadline
|
||||
@@ -243,6 +253,8 @@ contract BaseTest is TestSetup {
|
||||
profileId: mirrorParams.profileId,
|
||||
pointedProfileId: mirrorParams.pointedProfileId,
|
||||
pointedPubId: mirrorParams.pointedPubId,
|
||||
referrerProfileId: 0,
|
||||
referrerPubId: 0,
|
||||
referenceModuleData: mirrorParams.referenceModuleData,
|
||||
nonce: nonce,
|
||||
deadline: deadline
|
||||
|
||||
Reference in New Issue
Block a user