-
Notifications
You must be signed in to change notification settings - Fork 305
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
Showing
2 changed files
with
37 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { randomBytes } from '../crypto/index.js'; | ||
import { from2Fields, to2Fields } from './free_funcs.js'; | ||
|
||
describe('buffer to fields and back', () => { | ||
it('should correctly serialize and deserialize a buffer', () => { | ||
// Generate a random 32-byte buffer | ||
const originalBuffer = randomBytes(32); | ||
|
||
// Serialize the buffer to two fields | ||
const [field1, field2] = to2Fields(originalBuffer); | ||
|
||
// Deserialize the fields back to a buffer | ||
const reconstructedBuffer = from2Fields(field1, field2); | ||
|
||
// Check if the original buffer and reconstructed buffer are identical | ||
expect(reconstructedBuffer).toEqual(originalBuffer); | ||
}); | ||
}); |
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