test: Updated foundry tests to match new changes.

This commit is contained in:
Peter Michael
2022-09-27 17:04:24 -04:00
parent 3e98c69ae4
commit b51f9b69ab
6 changed files with 25 additions and 10 deletions

View File

@@ -58,7 +58,6 @@ library Errors {
error CannotCommentOnSelf();
error NotWhitelisted();
error CallerInvalid();
error ExecutorInvalid();
// Module Errors
error InitParamsInvalid();

View File

@@ -169,6 +169,6 @@ library GeneralHelpers {
let slot := keccak256(0, 64)
invalidExecutor := iszero(sload(slot))
}
if (invalidExecutor) revert Errors.ExecutorInvalid();
if (invalidExecutor) revert Errors.CallerInvalid();
}
}

View File

@@ -115,9 +115,10 @@ contract CollectTest is BaseTest {
uint256 nonce = 0;
uint256 deadline = type(uint256).max;
bytes32 digest = _getCollectTypedDataHash(firstProfileId, 1, '', nonce, deadline);
vm.expectRevert(Errors.CallerInvalid.selector);
vm.expectRevert(Errors.SignatureInvalid.selector);
hub.collectWithSig(
DataTypes.CollectWithSigData({
delegatedSigner: address(0),
collector: profileOwner,
profileId: firstProfileId,
pubId: 1,
@@ -134,6 +135,7 @@ contract CollectTest is BaseTest {
bytes32 digest = _getCollectTypedDataHash(firstProfileId, 1, '', nonce, deadline);
uint256 nftId = hub.collectWithSig(
DataTypes.CollectWithSigData({
delegatedSigner: address(0),
collector: otherSigner,
profileId: firstProfileId,
pubId: 1,
@@ -166,6 +168,7 @@ contract CollectTest is BaseTest {
uint256 nftId = hub.collectWithSig(
DataTypes.CollectWithSigData({
delegatedSigner: address(0),
collector: otherSigner,
profileId: firstProfileId,
pubId: 2,
@@ -192,6 +195,7 @@ contract CollectTest is BaseTest {
bytes32 digest = _getCollectTypedDataHash(firstProfileId, 1, '', nonce, deadline);
uint256 nftId = hub.collectWithSig(
DataTypes.CollectWithSigData({
delegatedSigner: profileOwner,
collector: otherSigner,
profileId: firstProfileId,
pubId: 1,
@@ -227,6 +231,7 @@ contract CollectTest is BaseTest {
uint256 nftId = hub.collectWithSig(
DataTypes.CollectWithSigData({
delegatedSigner: profileOwner,
collector: otherSigner,
profileId: firstProfileId,
pubId: 2,

View File

@@ -59,9 +59,10 @@ contract FollowTest is BaseTest {
uint256 deadline = type(uint256).max;
bytes32 digest = _getFollowTypedDataHash(profileIds, datas, nonce, deadline);
vm.expectRevert(Errors.CallerInvalid.selector);
vm.expectRevert(Errors.SignatureInvalid.selector);
hub.followWithSig(
DataTypes.FollowWithSigData({
delegatedSigner: address(0),
follower: profileOwner,
profileIds: profileIds,
datas: datas,
@@ -84,6 +85,7 @@ contract FollowTest is BaseTest {
uint256[] memory nftIds = hub.followWithSig(
DataTypes.FollowWithSigData({
delegatedSigner: address(0),
follower: otherSigner,
profileIds: profileIds,
datas: datas,
@@ -118,6 +120,7 @@ contract FollowTest is BaseTest {
uint256[] memory nftIds = hub.followWithSig(
DataTypes.FollowWithSigData({
delegatedSigner: profileOwner,
follower: otherSigner,
profileIds: profileIds,
datas: datas,

View File

@@ -12,7 +12,7 @@ contract MiscTest is BaseTest {
function testSetDefaultProfileInvalidCallerFails() public {
vm.expectRevert(Errors.CallerInvalid.selector);
hub.setDefaultProfile(profileOwner, firstProfileId);
}
// Positives
@@ -37,9 +37,10 @@ contract MiscTest is BaseTest {
deadline
);
vm.expectRevert(Errors.CallerInvalid.selector);
vm.expectRevert(Errors.SignatureInvalid.selector);
hub.setFollowModuleWithSig(
DataTypes.SetFollowModuleWithSigData({
delegatedSigner: address(0),
profileId: firstProfileId,
followModule: address(0),
followModuleInitData: '',
@@ -65,6 +66,7 @@ contract MiscTest is BaseTest {
hub.setFollowModuleWithSig(
DataTypes.SetFollowModuleWithSigData({
delegatedSigner: otherSigner,
profileId: firstProfileId,
followModule: address(0),
followModuleInitData: '',

View File

@@ -74,9 +74,10 @@ contract PublishingTest is BaseTest {
deadline
);
vm.expectRevert(Errors.CallerInvalid.selector);
vm.expectRevert(Errors.SignatureInvalid.selector);
hub.postWithSig(
DataTypes.PostWithSigData({
delegatedSigner: address(0),
profileId: firstProfileId,
contentURI: mockURI,
collectModule: address(freeCollectModule),
@@ -108,9 +109,10 @@ contract PublishingTest is BaseTest {
deadline
);
vm.expectRevert(Errors.CallerInvalid.selector);
vm.expectRevert(Errors.SignatureInvalid.selector);
hub.commentWithSig(
DataTypes.CommentWithSigData({
delegatedSigner: address(0),
profileId: firstProfileId,
contentURI: mockURI,
profileIdPointed: firstProfileId,
@@ -142,9 +144,10 @@ contract PublishingTest is BaseTest {
deadline
);
vm.expectRevert(Errors.CallerInvalid.selector);
vm.expectRevert(Errors.SignatureInvalid.selector);
hub.mirrorWithSig(
DataTypes.MirrorWithSigData({
delegatedSigner: address(0),
profileId: firstProfileId,
profileIdPointed: firstProfileId,
pubIdPointed: 1,
@@ -176,13 +179,14 @@ contract PublishingTest is BaseTest {
uint256 pubId = hub.postWithSig(
DataTypes.PostWithSigData({
delegatedSigner: otherSigner,
profileId: firstProfileId,
contentURI: mockURI,
collectModule: address(freeCollectModule),
collectModuleInitData: abi.encode(false),
referenceModule: address(0),
referenceModuleInitData: '',
sig: _getSigStruct(profileOwnerKey, digest, deadline)
sig: _getSigStruct(otherSignerKey, digest, deadline)
})
);
assertEq(pubId, 1);
@@ -212,6 +216,7 @@ contract PublishingTest is BaseTest {
uint256 pubId = hub.commentWithSig(
DataTypes.CommentWithSigData({
delegatedSigner: otherSigner,
profileId: firstProfileId,
contentURI: mockURI,
profileIdPointed: firstProfileId,
@@ -248,6 +253,7 @@ contract PublishingTest is BaseTest {
uint256 pubId = hub.mirrorWithSig(
DataTypes.MirrorWithSigData({
delegatedSigner: otherSigner,
profileId: firstProfileId,
profileIdPointed: firstProfileId,
pubIdPointed: 1,