-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: separate out and disable keychain integration tests (#15)
- Loading branch information
Showing
7 changed files
with
956 additions
and
2,395 deletions.
There are no files selected for viewing
File renamed without changes.
128 changes: 128 additions & 0 deletions
128
features/keychain/module/__tests__/key-identifier.integration-test.js
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,128 @@ | ||
import { assets } from './fixtures/assets' | ||
|
||
import { KeyIdentifier, createKeyIdentifierForExodus } from '../key-identifier' | ||
|
||
describe('KeyIdentifier', () => { | ||
it('should fail on incorrect construction', () => { | ||
const failures = [ | ||
{ | ||
derivationAlgorithm: 'BIP32', | ||
asset: assets.ethereum, | ||
}, | ||
{ | ||
derivationPath: "m/44'/60'/0'/0/0", | ||
asset: assets.ethereum, | ||
}, | ||
{ | ||
asset: assets.ethereum, | ||
}, | ||
{ | ||
derivationAlgorithm: 0, | ||
asset: assets.ethereum, | ||
derivationPath: "m/44'/60'/0'/0/0", | ||
}, | ||
{ | ||
derivationAlgorithm: 'BIP32', | ||
asset: assets.ethereum, | ||
derivationPath: 0, | ||
}, | ||
{ | ||
derivationAlgorithm: 'BIP32', | ||
asset: assets.ethereum, | ||
derivationPath: "m/44'/60'/0'/0/0dddd", | ||
}, | ||
{ | ||
derivationAlgorithm: 'BIP32', | ||
asset: assets.ethereum, | ||
derivationPath: "m\\44'/60'/0'/0/0", | ||
}, | ||
{ | ||
derivationAlgorithm: 'BIP32', | ||
asset: assets.ethereum, | ||
derivationPath: "m44'/60'/0'/0/0", | ||
}, | ||
] | ||
|
||
const failuresAsFunctions = failures.map((failure) => () => { | ||
return new KeyIdentifier(failure) | ||
}) | ||
failuresAsFunctions.forEach((failureFunc) => { | ||
expect(failureFunc).toThrow() | ||
}) | ||
}) | ||
|
||
it('validates KeyIdentifier-likes', () => { | ||
const valid = [ | ||
new KeyIdentifier({ | ||
derivationAlgorithm: 'BIP32', | ||
assetName: 'ethereum', | ||
derivationPath: "m/44'/60'/0'/0/0", | ||
}), | ||
new KeyIdentifier({ | ||
derivationAlgorithm: 'SLIP10', | ||
assetName: 'solana', | ||
derivationPath: "m/44'/501'/0'", | ||
}), | ||
{ | ||
derivationAlgorithm: 'BIP32', | ||
assetName: 'ethereum', | ||
derivationPath: "m/44'/60'/0'/0/0", | ||
}, | ||
] | ||
|
||
const invalid = [ | ||
{ | ||
derivationAlgorithm: 'BIP32', | ||
assetName: 'ethereum', | ||
}, | ||
] | ||
|
||
valid.forEach((item) => expect(KeyIdentifier.validate(item)).toEqual(true)) | ||
invalid.forEach((item) => expect(KeyIdentifier.validate(item)).toEqual(false)) | ||
}) | ||
|
||
describe('.compare()', () => { | ||
it('should return true when equal', () => { | ||
const keyIdA = new KeyIdentifier({ | ||
derivationAlgorithm: 'BIP32', | ||
assetName: 'ethereum', | ||
derivationPath: "m/44'/60'/0'/0/0", | ||
}) | ||
|
||
const keyIdB = new KeyIdentifier({ | ||
derivationAlgorithm: 'BIP32', | ||
assetName: 'ethereum', | ||
derivationPath: "m/44'/60'/0'/0/0", | ||
}) | ||
|
||
expect(KeyIdentifier.compare(keyIdA, keyIdB)).toBe(true) | ||
}) | ||
|
||
it('should return false when not equal', () => { | ||
const keyIdA = new KeyIdentifier({ | ||
derivationAlgorithm: 'BIP32', | ||
assetName: 'ethereum', | ||
derivationPath: "m/44'/60'/0'/0/0", | ||
}) | ||
|
||
const keyIdB = new KeyIdentifier({ | ||
derivationAlgorithm: 'BIP32', | ||
assetName: 'ethereum', | ||
derivationPath: "m/44'/60'/0'/0/1", | ||
}) | ||
|
||
expect(KeyIdentifier.compare(keyIdA, keyIdB)).toBe(false) | ||
expect(KeyIdentifier.compare('not-an-object', keyIdB)).toBe(false) | ||
}) | ||
}) | ||
}) | ||
|
||
describe('createKeyIdentifierForExodus', () => { | ||
it('should work', () => { | ||
expect(() => createKeyIdentifierForExodus({ exoType: 'FUSION' })).not.toThrow() | ||
}) | ||
|
||
it('should throw when incorrect exoType', async () => { | ||
expect(() => createKeyIdentifierForExodus({ exoType: 'INVALID' })).toThrow() | ||
}) | ||
}) |
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
File renamed without changes.
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
Oops, something went wrong.