-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: implement browser compatibility testing (#1630)
* feat: add browser testing infastructure * feat: reorganise crypto tests * feat: refactor fs promises usage * chore: changeset * chore: remove hardlinked deps * feat: add browser and os test matrix * feat: add missing os variable to test ci * feat: add no frozen lock file to browser test ci * feat: support further packages with browser testing * feat: add no frozen lockfile to browser install script * feat: add conditional name to CI test stage * feat: fix CI test matrix stage naem * feat: implement no frozen lockfile for final install in test ci * feat: change live test stage name * chore: rebuild * chore: change live ci stage to e2e Co-authored-by: Anderson Arboleya <[email protected]> * chore: add doc to test ci name Co-authored-by: Anderson Arboleya <[email protected]> * feat: group crypto browser and node tests * chore: use array of obj for test matrix * test: add missing hasher testr * chore: add no console lint rule to browser script * chore: remove browser test hardlink script * chore: rebuild --------- Co-authored-by: Anderson Arboleya <[email protected]>
- Loading branch information
1 parent
ed0a49f
commit 2682148
Showing
69 changed files
with
1,332 additions
and
121 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,2 @@ | ||
--- | ||
--- |
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
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
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,10 @@ | ||
import { testEach } from './index'; | ||
|
||
/** | ||
* @group browser | ||
*/ | ||
describe('in:browser', () => { | ||
it('should work on browser', () => { | ||
expect(testEach()).toEqual('browser'); | ||
}); | ||
}); |
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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 |
---|---|---|
@@ -1,34 +1,27 @@ | ||
import { envs } from './envs'; | ||
import { bufferFromString } from '..'; | ||
|
||
/** | ||
* @group node | ||
* @group browser | ||
*/ | ||
describe('bufferFromString', () => { | ||
const buffer = new Uint8Array([104, 101, 108, 108, 111]); // ASCII values for "hello" | ||
|
||
it.each(envs)( | ||
'should correctly convert string to Uint8Array with base64 encoding in %s environment', | ||
({ bufferFromString }) => { | ||
const string = 'aGVsbG8='; // "hello" in Base64 | ||
const result = bufferFromString(string, 'base64'); | ||
expect(result).toStrictEqual(buffer); // ASCII values for "hello" | ||
} | ||
); | ||
it('should correctly convert string to Uint8Array with base64 encoding in a node environment', () => { | ||
const string = 'aGVsbG8='; // "hello" in Base64 | ||
const result = bufferFromString(string, 'base64'); | ||
expect(result).toStrictEqual(buffer); // ASCII values for "hello" | ||
}); | ||
|
||
it.each(envs)( | ||
'should correctly convert string to Uint8Array with utf-8 encoding in %s environment', | ||
({ bufferFromString }) => { | ||
const string = 'hello'; | ||
const result = bufferFromString(string, 'utf-8'); | ||
expect(result).toStrictEqual(buffer); // ASCII values for "hello" | ||
} | ||
); | ||
it.each(envs)( | ||
'should correctly convert string to Uint8Array with hex encoding in %s environment', | ||
({ bufferFromString }) => { | ||
const string = '68656c6c6f'; // "hello" in Hex | ||
const result = bufferFromString(string, 'hex'); | ||
expect(result).toStrictEqual(buffer); // ASCII values for "hello" | ||
} | ||
); | ||
it('should correctly convert string to Uint8Array with utf-8 encoding in a node environment', () => { | ||
const string = 'hello'; | ||
const result = bufferFromString(string, 'utf-8'); | ||
expect(result).toStrictEqual(buffer); // ASCII values for "hello" | ||
}); | ||
|
||
it('should correctly convert string to Uint8Array with hex encoding in a node environment', () => { | ||
const string = '68656c6c6f'; // "hello" in Hex | ||
const result = bufferFromString(string, 'hex'); | ||
expect(result).toStrictEqual(buffer); // ASCII values for "hello" | ||
}); | ||
}); |
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 |
---|---|---|
@@ -1,21 +1,18 @@ | ||
import { envs } from './envs'; | ||
|
||
import { encryptJsonWalletData, decryptJsonWalletData, randomBytes } from '..'; | ||
/** | ||
* @group node | ||
* @group browser | ||
*/ | ||
describe('encryptJsonWalletData', () => { | ||
it.each(envs)( | ||
'should encrypt and decrypt json wallet data correctly in %s environment', | ||
async ({ encryptJsonWalletData, decryptJsonWalletData, randomBytes }) => { | ||
const testData = new Uint8Array([104, 101, 108, 108, 111]); | ||
const testKey = randomBytes(16); | ||
const testIv = randomBytes(16); | ||
it('should encrypt and decrypt json wallet data correctly in a node environment', async () => { | ||
const testData = new Uint8Array([104, 101, 108, 108, 111]); | ||
const testKey = randomBytes(16); | ||
const testIv = randomBytes(16); | ||
|
||
const encryptedData = await encryptJsonWalletData(testData, testKey, testIv); | ||
expect(encryptedData).not.toEqual(testData); // ensure data was encrypted | ||
const encryptedData = await encryptJsonWalletData(testData, testKey, testIv); | ||
expect(encryptedData).not.toEqual(testData); // ensure data was encrypted | ||
|
||
const decryptedData = await decryptJsonWalletData(encryptedData, testKey, testIv); | ||
expect(decryptedData).toEqual(testData); // ensure data was decrypted correctly | ||
} | ||
); | ||
const decryptedData = await decryptJsonWalletData(encryptedData, testKey, testIv); | ||
expect(decryptedData).toEqual(testData); // ensure data was decrypted correctly | ||
}); | ||
}); |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.