Skip to content

Commit

Permalink
test: add tests for LSP1 hook
Browse files Browse the repository at this point in the history
  • Loading branch information
b00ste committed Aug 15, 2023
1 parent 9cbca0f commit 266c594
Showing 1 changed file with 48 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ethers } from 'hardhat';
import { ethers, network } from 'hardhat';
import { expect } from 'chai';
import { SignerWithAddress } from '@nomiclabs/hardhat-ethers/signers';

Expand Down Expand Up @@ -33,7 +33,7 @@ import { ERC725YDataKeys, INTERFACE_IDS, OPERATION_TYPES, LSP1_TYPE_IDS } from '
// fixtures
import { callPayload, getLSP5MapAndArrayKeysValue, setupKeyManager } from '../utils/fixtures';
import { LSP6TestContext } from '../utils/context';
import { BigNumber, BytesLike, Transaction } from 'ethers';
import { BigNumber, BytesLike, ContractTransaction, Transaction } from 'ethers';

Check warning on line 36 in tests/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateUP.behaviour.ts

View workflow job for this annotation

GitHub Actions / build

'ContractTransaction' is defined but never used

export type LSP1TestAccounts = {
owner1: SignerWithAddress;
Expand Down Expand Up @@ -2420,6 +2420,52 @@ export const shouldBehaveLikeLSP1Delegate = (
});
});

describe('When renouncing Ownership of VaultC from UP2', () => {
let tx: Transaction;
before(async () => {
const renounceOwnershipCalldata =
lsp9VaultC.interface.encodeFunctionData('renounceOwnership');

// Call renounceOwnership for the first time
await context.universalProfile2
.connect(context.accounts.owner2)
.execute(OPERATION_TYPES.CALL, lsp9VaultC.address, 0, renounceOwnershipCalldata);

// Skip 199 block to reach the time where renouncing ownership can happen
await network.provider.send('hardhat_mine', [ethers.utils.hexValue(199)]);

// Call renounceOwnership for the second time
tx = await context.universalProfile2
.connect(context.accounts.owner2)
.execute(OPERATION_TYPES.CALL, lsp9VaultC.address, 0, renounceOwnershipCalldata);
});

it('Should emit `UnviersalReceiver` event', async () => {
await expect(tx)
.to.emit(context.universalProfile2, 'UniversalReceiver')
.withArgs(
lsp9VaultC.address,
0,
LSP1_TYPE_IDS.LSP9OwnershipTransferred_SenderNotification,
'0x',
ethers.utils.defaultAbiCoder.encode(['bytes', 'bytes'], ['0x', '0x']),
);
});

it('should remove all lsp10keys : arrayLength 0, no map, no VaultC address in UP2', async () => {
const [mapValue, arrayLength, elementAddress] =
await context.universalProfile2.getDataBatch([
ERC725YDataKeys.LSP10.LSP10VaultsMap + lsp9VaultC.address.substring(2),
ERC725YDataKeys.LSP10['LSP10Vaults[]'].length,
ERC725YDataKeys.LSP10['LSP10Vaults[]'].index + '00000000000000000000000000000000',
]);

expect(mapValue).to.equal('0x');
expect(arrayLength).to.equal(ARRAY_LENGTH.ZERO);
expect(elementAddress).to.equal('0x');
});
});

describe('when deploying vault to a UP directly', () => {
let lsp9VaultD: LSP9Vault;

Expand Down

0 comments on commit 266c594

Please sign in to comment.