feat: Added more collect tests

This commit is contained in:
Ben Sparks
2022-12-01 15:32:38 +02:00
parent b050a8e533
commit 51dd601a38
2 changed files with 19 additions and 24 deletions

View File

@@ -212,36 +212,22 @@ contract CollectingTest_WithSig is CollectingTest_Base {
_mockCollectWithSig({delegatedSigner: address(0), signerPrivKey: profileOwnerKey});
}
function testCannotCollectWithSigIfNonceWasIncrementedWithAnotherAction() public {
// TODO clean up
address delegatedSigner = address(0);
uint256 signerPrivKey = profileOwnerKey;
function testCannotCollectIfNonceWasIncrementedWithAnotherAction() public {
assertEq(_getSigNonce(profileOwner), nonce, 'Wrong nonce before posting');
// cancel with permitForAll
uint256 expectedCollectId = _getCollectCount(firstProfileId, mockCollectData.pubId) + 1;
// bytes32 collectDigest = _getCollectTypedDataHash(
// mockCollectData.profileId,
// mockCollectData.pubId,
// mockCollectData.data,
// nonce,
// deadline
// );
uint256 nftId = _mockCollectWithSig({
delegatedSigner: address(0),
signerPrivKey: profileOwnerKey
});
// hub.permitForAll();
assertEq(nftId, expectedCollectId, 'Wrong collectId');
// _collectWithSig(
// _buildCollectWithSigData(
// delegatedSigner,
// mockCollectData,
// _getSigStruct(signerPrivKey, collectDigest, deadline)
// )
// );
assertTrue(_getSigNonce(profileOwner) != nonce, 'Wrong nonce after collecting');
// // TODO fix
// vm.expectRevert(Errors.SignatureInvalid.selector);
// _mockCollectWithSig({delegatedSigner: address(0), signerPrivKey: otherSignerKey});
vm.expectRevert(Errors.SignatureInvalid.selector);
_mockCollectWithSig({delegatedSigner: address(0), signerPrivKey: profileOwnerKey});
}
// SCENARIOS

View File

@@ -393,4 +393,13 @@ contract BaseTest is TestSetup {
function _getPubCount(uint256 profileId) internal view returns (uint256) {
return hub.getPubCount(profileId);
}
function _getCollectCount(uint256 profileId, uint256 pubId) internal view returns (uint256) {
address collectNft = hub.getCollectNFT(profileId, pubId);
if (collectNft == address(0)) {
return 0;
} else {
return CollectNFT(collectNft).totalSupply();
}
}
}