Skip to content

Commit

Permalink
feat: add mock combination component
Browse files Browse the repository at this point in the history
  • Loading branch information
kopy-kat committed Aug 15, 2024
1 parent 145c7b7 commit 5cbfd14
Showing 1 changed file with 89 additions and 0 deletions.
89 changes: 89 additions & 0 deletions test/mocks/MockCombination.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.0;

import "src/external/IExternalResolver.sol";
import "src/external/IExternalSchemaValidator.sol";
import { IRegistry, SchemaUID, AttestationRequest } from "src/IRegistry.sol";

contract MockCombination is IExternalResolver, IExternalSchemaValidator {
bool immutable returnVal;

bool public onAttestCalled;
bool public onRevokeCalled;
bool public onModuleCalled;

constructor(bool ret) {
returnVal = ret;
}

/*//////////////////////////////////////////////////////////////////////////
RESOLVER
//////////////////////////////////////////////////////////////////////////*/

function reset() public {
onAttestCalled = false;
onRevokeCalled = false;
onModuleCalled = false;
}

function supportsInterface(bytes4 interfaceId) public pure override returns (bool) {
if (interfaceId == type(IExternalResolver).interfaceId || interfaceId == type(IExternalSchemaValidator).interfaceId) return true;
}

function resolveAttestation(AttestationRecord calldata attestation) external payable override returns (bool) {
onAttestCalled = true;
return returnVal;
}

function resolveAttestation(AttestationRecord[] calldata attestation) external payable override returns (bool) {
onAttestCalled = true;
return returnVal;
}

function resolveRevocation(AttestationRecord calldata attestation) external payable override returns (bool) {
revert();
onRevokeCalled = true;
return returnVal;
}

function resolveRevocation(AttestationRecord[] calldata attestation) external payable override returns (bool) {
revert();
onRevokeCalled = true;
return returnVal;
}

function resolveModuleRegistration(
address sender,
address moduleRecord,
ModuleRecord calldata record,
bytes calldata resolverContext
)
external
payable
override
returns (bool)
{
onModuleCalled = true;
return returnVal;
}

/*//////////////////////////////////////////////////////////////////////////
SCHEMA VALIDATOR
//////////////////////////////////////////////////////////////////////////*/

function validateSchema(AttestationRecord calldata attestation) external view override returns (bool) {
return returnVal;
}

function validateSchema(AttestationRecord[] calldata attestations) external view override returns (bool) {
return returnVal;
}

/*//////////////////////////////////////////////////////////////////////////
MOCK ATTESTER
//////////////////////////////////////////////////////////////////////////*/

function attest(IRegistry registry, SchemaUID schemaUID, AttestationRequest calldata request) external payable returns (bool) {
registry.attest(schemaUID, request);
}
}

0 comments on commit 5cbfd14

Please sign in to comment.