Skip to content

Commit bf0cdb7

Browse files
committed
updated naming in tests
1 parent 044003e commit bf0cdb7

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

sdk/tests/wasm.test.ts

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ describe('WASM Objects', () => {
353353
});
354354

355355
it('can be decrypted with a valid record view key', () => {
356-
const recordViewKey = ciphertext.generateRecordViewKey(viewKey);
356+
const recordViewKey = ciphertext.recordViewKey(viewKey);
357357
const plaintext = ciphertext.decryptWithRecordViewKey(recordViewKey);
358358
const isOwner = ciphertext.isOwner(viewKey);
359359

@@ -363,7 +363,8 @@ describe('WASM Objects', () => {
363363
})
364364

365365
it ('cannot be decrypted with an invalid record view key', () => {
366-
const badRecordViewKey = ciphertext.generateRecordViewKey(foreignViewKeyString);
366+
const foreignViewKey = ViewKey.from_string(foreignViewKeyString);
367+
const badRecordViewKey = ciphertext.recordViewKey(foreignViewKey);
367368

368369
// Ensure the record ciphertext cannot be decrypted with an invalid record view key
369370
expect(() => ciphertext.decryptWithRecordViewKey(badRecordViewKey)).throw();
@@ -390,21 +391,22 @@ describe('WASM Objects', () => {
390391
const invalidTransitionViewKeyString = "5089075468761042335883809641276568724119791331127957254389204093712358605127field"
391392
const transitionViewKey = Field.fromString(transitionViewKeyString);
392393
const invalidTransitionViewKey = Field.fromString(invalidTransitionViewKeyString);
393-
const viewKeyString = "AViewKey1ccEt8A2Ryva5rxnKcAbn7wgTaTsb79tzkKHFpeKsm9NX";
394-
const viewKey = ViewKey.from_string(viewKeyString);
394+
const privateKey = PrivateKey.from_string("APrivateKey1zkp6rE5FSWGD3jxrsAT64aZutFs3w6xvF8uQzGZKJEKsN8j");
395+
const viewKey = privateKey.to_view_key();
396+
const tvk = transition.tvk(viewKey);
395397

396398
it('can be decrypted with a valid transition view key', () => {
397-
const transitionDecryptedWithTVK = transition.decryptWithTransitionViewKey(transitionViewKey);
399+
const transitionDecryptedWithTVK = transition.decryptTransition(tvk);
398400
// Ensure the transition is valid
399-
expect(transitionDecryptedWithTVK).equal(transitionDecrypted);
401+
expect(transitionDecryptedWithTVK.toString()).equal(transitionDecrypted.toString());
400402
});
401403

402404
it('cannot be decrypted with an invalid transition view key', () => {
403-
expect(() => transition.decryptWithTransitionViewKey(invalidTransitionViewKey).toThrow());
405+
expect(() => transition.decryptTransition(invalidTransitionViewKey).toThrow());
404406
});
405407

406408
it('can generate a transition view key from a valid view key', () => {
407-
const generatedTransitionViewKey = transition.generateTransitionViewKey(viewKey);
409+
const generatedTransitionViewKey = transition.tvk(viewKey);
408410
// Ensure the generated transition view key is the same as the one used to decrypt
409411
expect(generatedTransitionViewKey.toString()).equal(transitionViewKeyString);
410412
});
@@ -425,16 +427,16 @@ owner: aleo1j7qxyunfldj2lp8hsvy7mw5k8zaqgjfyr72x2gh3x4ewgae8v5gscf5jh3.private,
425427
const recordViewKey = Field.fromString(recordViewKeyString);
426428

427429
it('can generate a record view key from a view key and a record ciphertext', () => {
428-
const generatedRecordViewKey = EncryptionToolkit.generateRecordViewKey(viewKey, recordCiphertext);
430+
const generatedRecordViewKey = EncryptionToolkit.generateRecordViewkey(viewKey, recordCiphertext);
429431
// Ensure the generated record view key is the same as the one used to decrypt
430-
expect(generatedRecordViewKey).equal(recordViewKey);
432+
expect(generatedRecordViewKey.toString()).equal(recordViewKey.toString());
431433
});
432434
it('can decrypt a record ciphertext with the record view key', () => {
433435
const decryptedRecord = EncryptionToolkit.decryptRecordWithRVk(recordViewKey, recordCiphertext);
434436
// Ensure the decrypted record is the same as the plaintext
435437
expect(decryptedRecord).equal(recordPlaintext);
436438
});
437-
it('caanot decrypt a record ciphertext with an invalid record view key', () => {
439+
it('cannot decrypt a record ciphertext with an invalid record view key', () => {
438440
const invalidRecordViewKey = Field.fromString("4445718830394614891114647247073357114867447866913203502139893824059966201724field");
439441
expect(() => EncryptionToolkit.decryptRecordWithRVk(invalidRecordViewKey, recordCiphertext)).to.throw();
440442
});

0 commit comments

Comments
 (0)