Skip to content

Commit

Permalink
test: fix tests of LSP1Delegate InterfaceId (#757)
Browse files Browse the repository at this point in the history
* test: fix tests of LSP1Delegate InterfaceId

* chore: remove .only

* test: add solidity tests for LSP1Delegate InterfaceId
  • Loading branch information
YamenMerhi authored Oct 24, 2023
1 parent e2ec65a commit 9ed3d2c
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 6 deletions.
19 changes: 18 additions & 1 deletion contracts/Mocks/ERC165Interfaces.sol
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ import {
ILSP1UniversalReceiver as ILSP1
} from "../LSP1UniversalReceiver/ILSP1UniversalReceiver.sol";

import {
ILSP1UniversalReceiverDelegate as ILSP1Delegate
} from "../LSP1UniversalReceiver/ILSP1UniversalReceiverDelegate.sol";

import {ILSP6KeyManager as ILSP6} from "../LSP6KeyManager/ILSP6KeyManager.sol";
import {
ILSP7DigitalAsset as ILSP7
Expand All @@ -57,7 +61,10 @@ import {

// constants
import {_INTERFACEID_LSP0} from "../LSP0ERC725Account/LSP0Constants.sol";
import {_INTERFACEID_LSP1} from "../LSP1UniversalReceiver/LSP1Constants.sol";
import {
_INTERFACEID_LSP1,
_INTERFACEID_LSP1_DELEGATE
} from "../LSP1UniversalReceiver/LSP1Constants.sol";
import {_INTERFACEID_LSP6} from "../LSP6KeyManager/LSP6Constants.sol";
import {_INTERFACEID_LSP7} from "../LSP7DigitalAsset/LSP7Constants.sol";
import {
Expand Down Expand Up @@ -119,6 +126,16 @@ contract CalculateLSPInterfaces {
return interfaceId;
}

function calculateInterfaceLSP1Delegate() public pure returns (bytes4) {
bytes4 interfaceId = type(ILSP1Delegate).interfaceId;
require(
interfaceId == _INTERFACEID_LSP1_DELEGATE,
"hardcoded _INTERFACEID_LSP1_DELEGATE does not match type(ILSP1Delegate).interfaceId"
);

return interfaceId;
}

function calculateInterfaceLSP6KeyManager() public pure returns (bytes4) {
bytes4 interfaceId = type(ILSP6).interfaceId ^
type(IERC1271).interfaceId ^
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3156,15 +3156,17 @@ export const shouldInitializeLikeLSP1Delegate = (

describe('when the contract was initialized', () => {
it('should have registered the ERC165 interface', async () => {
expect(await context.lsp1universalReceiverDelegateUP.supportsInterface(INTERFACE_IDS.ERC165));
const result = await context.lsp1universalReceiverDelegateUP.supportsInterface(
INTERFACE_IDS.ERC165,
);
expect(result).to.be.true;
});

it('should have registered the LSP1 interface', async () => {
expect(
await context.lsp1universalReceiverDelegateUP.supportsInterface(
INTERFACE_IDS.LSP1UniversalReceiver,
),
const result = await context.lsp1universalReceiverDelegateUP.supportsInterface(
INTERFACE_IDS.LSP1UniversalReceiverDelegate,
);
expect(result).to.be.true;
});
});
};
5 changes: 5 additions & 0 deletions tests/Mocks/ERC165Interfaces.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ describe('Calculate LSP interfaces', () => {
expect(result).to.equal(INTERFACE_IDS.LSP1UniversalReceiver);
});

it('LSP1Delegate', async () => {
const result = await contract.calculateInterfaceLSP1Delegate();
expect(result).to.equal(INTERFACE_IDS.LSP1UniversalReceiverDelegate);
});

it('LSP6', async () => {
const result = await contract.calculateInterfaceLSP6KeyManager();
expect(result).to.equal(INTERFACE_IDS.LSP6KeyManager);
Expand Down

0 comments on commit 9ed3d2c

Please sign in to comment.