Skip to content
This repository has been archived by the owner on Dec 18, 2024. It is now read-only.

Commit

Permalink
Fix tests (#10)
Browse files Browse the repository at this point in the history
* wip - tests

* t

* t

* wf

* wf

* fix branch name

* made default branch `main` for consistency with other repos

# Conflicts:
#	.github/.workflows/test.yaml

* rm wf

* fix wf
  • Loading branch information
coffeexcoin authored Oct 30, 2024
1 parent 3dbd62b commit c1f887a
Show file tree
Hide file tree
Showing 20 changed files with 458 additions and 230 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ jobs:

- name: Set up Node.js
uses: actions/setup-node@v4
- name: Install dependencies
run: |
npm install
- name: Build
run: |
npm run compile
Expand Down
30 changes: 15 additions & 15 deletions test/accounts/managers/hookmanager.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ describe('Clave Contracts - Hook Manager tests', () => {
let deployer: ClaveDeployer;
let provider: Provider;
let richWallet: Wallet;
let teeValidator: Contract;
let eoaValidator: Contract;
let account: Contract;
let wallet: HDNodeWallet;

Expand All @@ -31,10 +31,10 @@ describe('Clave Contracts - Hook Manager tests', () => {
cacheTimeout: -1,
});

[, , , , teeValidator, account, wallet] = await fixture(
({ eoaValidator, account, wallet } = await fixture(
deployer,
VALIDATORS.EOA,
);
));

const accountAddress = await account.getAddress();

Expand Down Expand Up @@ -64,7 +64,7 @@ describe('Clave Contracts - Hook Manager tests', () => {
await addHook(
provider,
account,
teeValidator,
eoaValidator,
validationHook,
HOOKS.VALIDATION,
wallet,
Expand Down Expand Up @@ -108,7 +108,7 @@ describe('Clave Contracts - Hook Manager tests', () => {
provider,
account,
transfer,
await teeValidator.getAddress(),
await eoaValidator.getAddress(),
wallet,
hookData,
);
Expand All @@ -130,7 +130,7 @@ describe('Clave Contracts - Hook Manager tests', () => {
await removeHook(
provider,
account,
teeValidator,
eoaValidator,
validationHook,
HOOKS.VALIDATION,
wallet,
Expand Down Expand Up @@ -162,7 +162,7 @@ describe('Clave Contracts - Hook Manager tests', () => {
await addHook(
provider,
account,
teeValidator,
eoaValidator,
executionHook,
HOOKS.EXECUTION,
wallet,
Expand All @@ -184,7 +184,7 @@ describe('Clave Contracts - Hook Manager tests', () => {
await removeHook(
provider,
account,
teeValidator,
eoaValidator,
executionHook,
HOOKS.EXECUTION,
wallet,
Expand Down Expand Up @@ -247,7 +247,7 @@ describe('Clave Contracts - Hook Manager tests', () => {
await addHook(
provider,
account,
teeValidator,
eoaValidator,
new Contract(await noInterfaceHook.getAddress(), []),
HOOKS.VALIDATION,
wallet,
Expand All @@ -259,7 +259,7 @@ describe('Clave Contracts - Hook Manager tests', () => {
await addHook(
provider,
account,
teeValidator,
eoaValidator,
new Contract(await noInterfaceHook.getAddress(), []),
HOOKS.EXECUTION,
wallet,
Expand All @@ -282,7 +282,7 @@ describe('Clave Contracts - Hook Manager tests', () => {
provider,
account,
addHookTx,
await teeValidator.getAddress(),
await eoaValidator.getAddress(),
wallet,
);

Expand All @@ -300,7 +300,7 @@ describe('Clave Contracts - Hook Manager tests', () => {
await addHook(
provider,
account,
teeValidator,
eoaValidator,
validationHook,
HOOKS.VALIDATION,
wallet,
Expand All @@ -320,7 +320,7 @@ describe('Clave Contracts - Hook Manager tests', () => {
await addHook(
provider,
account,
teeValidator,
eoaValidator,
executionHook,
HOOKS.EXECUTION,
wallet,
Expand Down Expand Up @@ -370,7 +370,7 @@ describe('Clave Contracts - Hook Manager tests', () => {
provider,
account,
transfer,
await teeValidator.getAddress(),
await eoaValidator.getAddress(),
wallet,
hookData,
);
Expand All @@ -396,7 +396,7 @@ describe('Clave Contracts - Hook Manager tests', () => {
provider,
account,
transfer,
await teeValidator.getAddress(),
await eoaValidator.getAddress(),
wallet,
hookData,
);
Expand Down
16 changes: 8 additions & 8 deletions test/accounts/managers/modulemanager.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ describe('Clave Contracts - Module Manager tests', () => {
let deployer: ClaveDeployer;
let provider: Provider;
let richWallet: Wallet;
let teeValidator: Contract;
let eoaValidator: Contract;
let account: Contract;
let wallet: HDNodeWallet;

Expand All @@ -31,10 +31,10 @@ describe('Clave Contracts - Module Manager tests', () => {
cacheTimeout: -1,
});

[, , , , teeValidator, account, wallet] = await fixture(
({eoaValidator, account, wallet} = await fixture(
deployer,
VALIDATORS.EOA,
);
));

const accountAddress = await account.getAddress();

Expand Down Expand Up @@ -64,7 +64,7 @@ describe('Clave Contracts - Module Manager tests', () => {
await addModule(
provider,
account,
teeValidator,
eoaValidator,
mockModule,
initData,
wallet,
Expand Down Expand Up @@ -116,7 +116,7 @@ describe('Clave Contracts - Module Manager tests', () => {
await removeModule(
provider,
account,
teeValidator,
eoaValidator,
mockModule,
wallet,
);
Expand Down Expand Up @@ -164,7 +164,7 @@ describe('Clave Contracts - Module Manager tests', () => {
await addModule(
provider,
account,
teeValidator,
eoaValidator,
newMockModule,
initData,
wallet,
Expand Down Expand Up @@ -192,7 +192,7 @@ describe('Clave Contracts - Module Manager tests', () => {
provider,
account,
addModuleTx,
await teeValidator.getAddress(),
await eoaValidator.getAddress(),
wallet,
);

Expand All @@ -216,7 +216,7 @@ describe('Clave Contracts - Module Manager tests', () => {
await addModule(
provider,
account,
teeValidator,
eoaValidator,
new Contract(await noInterfaceModule.getAddress(), []),
initData,
wallet,
Expand Down
36 changes: 25 additions & 11 deletions test/accounts/managers/ownermanager.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,13 @@ import {
import { VALIDATORS } from '../../utils/names';
import { encodePublicKey, genKey } from '../../utils/p256';
import { ethTransfer, prepareEOATx, prepareTeeTx } from '../../utils/transactions';
import { addR1Validator } from '../../utils/managers/validatormanager';

describe('Clave Contracts - Owner Manager tests', () => {
let deployer: ClaveDeployer;
let provider: Provider;
let richWallet: Wallet;
let eoaValidator: Contract;
let teeValidator: Contract;
let account: Contract;
let wallet: HDNodeWallet;
Expand All @@ -40,10 +42,10 @@ describe('Clave Contracts - Owner Manager tests', () => {
cacheTimeout: -1,
});

[, , , , teeValidator, account, wallet] = await fixture(
({eoaValidator, teeValidator, account, wallet}= await fixture(
deployer,
VALIDATORS.EOA,
);
));

const accountAddress = await account.getAddress();

Expand All @@ -63,12 +65,20 @@ describe('Clave Contracts - Owner Manager tests', () => {
newKeyPair = genKey();
newPublicKey = encodePublicKey(newKeyPair);

await addR1Validator(
provider,
account,
eoaValidator,
teeValidator,
wallet,
);

expect(await account.r1IsOwner(newPublicKey)).to.be.false;

await addR1Key(
provider,
account,
teeValidator,
eoaValidator,
newPublicKey,
wallet,
);
Expand All @@ -90,12 +100,13 @@ describe('Clave Contracts - Owner Manager tests', () => {
);

const txData = ethTransfer(richAddress, amount);
const tx = await prepareEOATx(

const tx = await prepareTeeTx(
provider,
account,
txData,
await teeValidator.getAddress(),
wallet,
newKeyPair,
);
const txReceipt = await provider.broadcastTransaction(
utils.serializeEip712(tx),
Expand All @@ -114,7 +125,7 @@ describe('Clave Contracts - Owner Manager tests', () => {
await removeR1Key(
provider,
account,
teeValidator,
eoaValidator,
newPublicKey,
wallet,
);
Expand Down Expand Up @@ -157,7 +168,7 @@ describe('Clave Contracts - Owner Manager tests', () => {
await addK1Key(
provider,
account,
teeValidator,
eoaValidator,
newK1Address,
wallet,
);
Expand All @@ -174,7 +185,7 @@ describe('Clave Contracts - Owner Manager tests', () => {
await removeK1Key(
provider,
account,
teeValidator,
eoaValidator,
newK1Address,
wallet,
);
Expand All @@ -194,7 +205,7 @@ describe('Clave Contracts - Owner Manager tests', () => {
await addR1Key(
provider,
account,
teeValidator,
eoaValidator,
newPublicKey,
wallet,
);
Expand All @@ -203,7 +214,7 @@ describe('Clave Contracts - Owner Manager tests', () => {
await addK1Key(
provider,
account,
teeValidator,
eoaValidator,
newK1Address,
wallet,
);
Expand All @@ -223,7 +234,7 @@ describe('Clave Contracts - Owner Manager tests', () => {
await resetOwners(
provider,
account,
teeValidator,
eoaValidator,
newPublicKey,
wallet,
);
Expand All @@ -232,6 +243,7 @@ describe('Clave Contracts - Owner Manager tests', () => {
const expectedNewR1Owners = [encodePublicKey(replacedKeyPair)];
const expectedNewK1Owners: Array<BytesLike> = [];

expect(await account.r1IsOwner(encodePublicKey(replacedKeyPair))).to.be.true;
expect(await account.r1ListOwners()).to.deep.eq(
expectedNewR1Owners,
);
Expand Down Expand Up @@ -284,6 +296,8 @@ describe('Clave Contracts - Owner Manager tests', () => {
const newKeyPair = genKey();
const newPublicKey = encodePublicKey(newKeyPair);

expect(await account.r1IsOwner(encodePublicKey(replacedKeyPair))).to.be.true;

await addR1Key(
provider,
account,
Expand Down
10 changes: 5 additions & 5 deletions test/accounts/managers/upgrademanager.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ describe('Clave Contracts - Upgrade Manager tests', () => {
let deployer: ClaveDeployer;
let provider: Provider;
let richWallet: Wallet;
let teeValidator: Contract;
let eoaValidator: Contract;
let account: Contract;
let wallet: HDNodeWallet;

Expand All @@ -31,10 +31,10 @@ describe('Clave Contracts - Upgrade Manager tests', () => {
cacheTimeout: -1,
});

[, , , , teeValidator, account, wallet] = await fixture(
({eoaValidator, account, wallet} = await fixture(
deployer,
VALIDATORS.EOA,
);
));

const accountAddress = await account.getAddress();

Expand Down Expand Up @@ -65,7 +65,7 @@ describe('Clave Contracts - Upgrade Manager tests', () => {
await upgradeTx(
provider,
account,
teeValidator,
eoaValidator,
mockImplementation,
wallet,
);
Expand All @@ -84,7 +84,7 @@ describe('Clave Contracts - Upgrade Manager tests', () => {
await upgradeTx(
provider,
account,
teeValidator,
eoaValidator,
mockImplementation,
wallet,
);
Expand Down
Loading

0 comments on commit c1f887a

Please sign in to comment.