-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
77a5e25
commit d23d6a4
Showing
2 changed files
with
95 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
packages/massa-web3/test/experimental/unit/passwordSeal.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { PasswordSeal } from '../../../src/experimental/crypto/passwordSeal' | ||
import randomUint8Array from 'secure-random' | ||
|
||
describe('Password Seal tests', () => { | ||
test('creates Sealer from env variable', async () => { | ||
process.env.PASSWORD = 'unsecurePassword' | ||
process.env.SALT = Buffer.from(randomUint8Array(16)).toString('base64') | ||
process.env.NONCE = Buffer.from(randomUint8Array(12)).toString('base64') | ||
|
||
const sealer = PasswordSeal.fromEnv() | ||
expect(sealer).toBeDefined() | ||
|
||
const originalData = Uint8Array.from([1, 2, 3, 4, 5]) | ||
const encryptedData = await sealer.seal(originalData) | ||
const decryptedData = await sealer.unseal(encryptedData) | ||
|
||
expect(originalData).toEqual(Uint8Array.from(decryptedData)) | ||
}) | ||
}) |
d23d6a4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Coverage report for experimental massa-web3
Test suite run success
51 tests passing in 8 suites.
Report generated by 🧪jest coverage report action from d23d6a4