-
Notifications
You must be signed in to change notification settings - Fork 154
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1412 from privacy-scaling-explorations/test/mock-…
…gatekeepers test(eas): mock gatekeeper tests
- Loading branch information
Showing
3 changed files
with
135 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.20; | ||
|
||
import { IEAS } from "../interfaces/IEAS.sol"; | ||
|
||
/// @title MockEAS | ||
/// @notice A mock contract to test the EASGatekeeper | ||
contract MockEAS is IEAS { | ||
address public immutable attester; | ||
bytes32 public immutable schema; | ||
|
||
address public recipient; | ||
|
||
constructor(address _attester, bytes32 _schema, address _recipient) { | ||
attester = _attester; | ||
schema = _schema; | ||
recipient = _recipient; | ||
} | ||
|
||
/// @notice Set the attestation recipient (mock) | ||
function setRecipient(address _recipient) public { | ||
recipient = _recipient; | ||
} | ||
|
||
/// @inheritdoc IEAS | ||
function getAttestation(bytes32 attestationId) external view override returns (Attestation memory) { | ||
// revoked | ||
if (attestationId == 0x0000000000000000000000000000000000000000000000000000000000000001) { | ||
return | ||
Attestation({ | ||
uid: "0x000000000000000000000000000001", | ||
schema: schema, | ||
time: 0, | ||
expirationTime: 0, | ||
revocationTime: 1, | ||
refUID: "0x000000000000000000000000000001", | ||
recipient: recipient, | ||
attester: attester, | ||
revocable: true, | ||
data: "" | ||
}); | ||
// invalid schema | ||
} else if (attestationId == 0x0000000000000000000000000000000000000000000000000000000000000002) { | ||
return | ||
Attestation({ | ||
uid: "0x000000000000000000000000000001", | ||
schema: "0x000000000000000000000000000001", | ||
time: 0, | ||
expirationTime: 0, | ||
revocationTime: 0, | ||
refUID: "0x000000000000000000000000000001", | ||
recipient: recipient, | ||
attester: attester, | ||
revocable: false, | ||
data: "" | ||
}); | ||
// invalid recipient | ||
} else if (attestationId == 0x0000000000000000000000000000000000000000000000000000000000000003) { | ||
return | ||
Attestation({ | ||
uid: "0x000000000000000000000000000001", | ||
schema: schema, | ||
time: 0, | ||
expirationTime: 0, | ||
revocationTime: 0, | ||
refUID: "0x000000000000000000000000000001", | ||
recipient: address(0), | ||
attester: attester, | ||
revocable: false, | ||
data: "" | ||
}); | ||
// invalid attester | ||
} else if (attestationId == 0x0000000000000000000000000000000000000000000000000000000000000004) { | ||
return | ||
Attestation({ | ||
uid: "0x000000000000000000000000000001", | ||
schema: schema, | ||
time: 0, | ||
expirationTime: 0, | ||
revocationTime: 0, | ||
refUID: "0x000000000000000000000000000001", | ||
recipient: recipient, | ||
attester: address(0), | ||
revocable: false, | ||
data: "" | ||
}); | ||
// valid | ||
} else { | ||
return | ||
Attestation({ | ||
uid: "0x000000000000000000000000000001", | ||
schema: schema, | ||
time: 0, | ||
expirationTime: 0, | ||
revocationTime: 0, | ||
refUID: "0x000000000000000000000000000001", | ||
recipient: recipient, | ||
attester: attester, | ||
revocable: false, | ||
data: "" | ||
}); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters