Skip to content

Commit 8cc0ea3

Browse files
committed
Validate decrypted response from LA
1 parent 602658d commit 8cc0ea3

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

packages/artillery/src/processors/multi-endpoints.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -264,14 +264,15 @@ export async function runExecuteJSTest(context: any, _events: any) {
264264
const builder = createAccBuilder();
265265
let accs: any;
266266
let encryptedData: any;
267+
let dataToEncrypt: string;
267268
if (variant === 'decryptToSingleNode') {
268269
accs = builder
269270
.requireWalletOwnership(authContext.account.address)
270271
.on('ethereum')
271272
.build();
272273

273274
// Encrypt data with the access control conditions
274-
const dataToEncrypt = 'Hello from encrypt-decrypt test!';
275+
dataToEncrypt = 'Hello from encrypt-decrypt test!';
275276
encryptedData = await litClient.encrypt({
276277
dataToEncrypt,
277278
unifiedAccessControlConditions: accs,
@@ -305,9 +306,19 @@ export async function runExecuteJSTest(context: any, _events: any) {
305306
const endTime = Date.now();
306307
const duration = endTime - startTime;
307308

309+
if (
310+
variant === 'decryptToSingleNode' &&
311+
// Strip quote marks at the ends
312+
validatedResult.response.substring(
313+
1,
314+
validatedResult.response.length - 1
315+
) !== dataToEncrypt!
316+
) {
317+
throw new Error('❌ Decrypted data does not match the original data');
318+
}
319+
308320
console.log(`✅ executeJs successful in ${duration}ms`);
309321
console.log('✅ executeJs result:', validatedResult);
310-
311322
// For Artillery, just return - no need to call next()
312323
return;
313324
} catch (error) {

0 commit comments

Comments
 (0)