Skip to content

Commit 9e77c3b

Browse files
committed
change test flow(only use A1 trigger error event)
1 parent 19145ac commit 9e77c3b

File tree

2 files changed

+24
-20
lines changed

2 files changed

+24
-20
lines changed

tee-worker/ts-tests/indirect_error_calls.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -161,27 +161,28 @@ export async function requestErrorVCs(
161161
aesKey: HexString,
162162
listening: boolean,
163163
mrEnclave: HexString,
164-
assertion: Assertion
164+
assertion: Assertion,
165+
keys: string[]
165166
): Promise<Event[] | undefined> {
166167
let txs: TransactionSubmit[] = [];
167-
let len = 0;
168168
const nonce = await context.substrate.rpc.system.accountNextIndex(signer.address);
169169

170-
for (const key in assertion) {
171-
len++;
170+
for (let index = 0; index < keys.length; index++) {
171+
const key = keys[index];
172172
const tx = context.substrate.tx.vcManagement.requestVc(mrEnclave, {
173173
[key]: assertion[key as keyof Assertion],
174174
});
175-
176-
let newNonce = nonce.toNumber() + (len - 1);
175+
let newNonce = nonce.toNumber() + index;
177176
txs.push({ tx, nonce: newNonce });
178177
}
179178

179+
180+
180181
await sendTxUntilInBlockList(context.substrate, txs, signer);
181182

182183
if (listening) {
183184
const events = (await listenEvent(context.substrate, 'vcManagement', ['StfError'])) as Event[];
184-
expect(events.length).to.be.equal(len);
185+
expect(events.length).to.be.equal(keys.length);
185186
return events;
186187
}
187188
return undefined;

tee-worker/ts-tests/vc.test.ts

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ const assertion = <Assertion>{
1919
A10: [10],
2020
A11: [10],
2121
};
22+
23+
24+
// it doesn't make much difference test A1 only vs test A1 - A11, one VC type is enough.
25+
//So only use A1 to trigger the wrong event
2226
describeLitentry('VC test', async (context) => {
2327
const aesKey = '0x22fc82db5b606998ad45099b7978b5b4f9dd4ea6017e57370ac56141caaabd12';
2428
var indexList: HexString[] = [];
@@ -60,14 +64,15 @@ describeLitentry('VC test', async (context) => {
6064
indexList.push(res[k].index);
6165
}
6266
});
63-
step('Request Error VC', async () => {
67+
step('Request Error VC(A1)', async () => {
6468
const resp_request_error = (await requestErrorVCs(
6569
context,
6670
context.defaultSigner[1],
6771
aesKey,
6872
true,
6973
context.mrEnclave,
70-
assertion
74+
assertion,
75+
['A1']
7176
)) as Event[];
7277

7378
await checkFailReason(resp_request_error, 'User shielding key is missing', true);
@@ -80,13 +85,14 @@ describeLitentry('VC test', async (context) => {
8085
assert.equal(registry.toHuman()!['status'], 'Disabled');
8186
}
8287
});
83-
step('Disable error VC', async () => {
84-
//Alice has already disabled the VC
88+
step('Disable error VC(A1)', async () => {
89+
//Alice has already disabled the A1 VC
8590
const resp_disable_error = (await disableErrorVCs(
8691
context,
8792
context.defaultSigner[0],
8893
true,
89-
indexList
94+
95+
[indexList[0]]
9096
)) as HexString[];
9197
await checkFailReason(resp_disable_error, 'vcManagement.VCAlreadyDisabled', false);
9298
});
@@ -100,14 +106,11 @@ describeLitentry('VC test', async (context) => {
100106
}
101107
});
102108

103-
step('Revoke Error VC', async () => {
104-
//Alice has already revoked the VC
105-
const resp_revoke_error = (await revokeErrorVCs(
106-
context,
107-
context.defaultSigner[0],
108-
true,
109-
indexList
110-
)) as string[];
109+
step('Revoke Error VC(A1)', async () => {
110+
//Alice has already revoked the A1 VC
111+
const resp_revoke_error = (await revokeErrorVCs(context, context.defaultSigner[0], true, [
112+
indexList[0],
113+
])) as string[];
111114
await checkFailReason(resp_revoke_error, 'vcManagement.VCNotExist', false);
112115
});
113116
});

0 commit comments

Comments
 (0)