-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove reference to eosjs-ecc and add tests for new logic
some change Refactor New version Fix linting
- Loading branch information
Jon La Marr
committed
Dec 11, 2019
1 parent
43c02aa
commit 8a4d0fd
Showing
5 changed files
with
173 additions
and
215 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
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,58 @@ | ||
import { Signature } from 'eosjs/dist/eosjs-jssig' | ||
import { convertSignatures } from './LedgerUtils' | ||
|
||
const mockedConvertedSignatureValue = 'mockedConvertedSignatureValue' | ||
|
||
describe('JsSignatureProvider', () => { | ||
it('should not convert signature given string with length < 130 characters', async () => { | ||
const signature = 'someSignature' | ||
const result = convertSignatures([signature], mockConvertSignature) | ||
|
||
expect(result[0]).toBe(signature) | ||
}) | ||
|
||
it('should not convert signature given string with length > 130 characters', async () => { | ||
const signature = '4cf0909aa10f10341cd7ca013630492d09b65e50c80974e962d94bbc95df635e90afb2e4dd22eb254cb451ca26a6aeb0b88e9b031a2233b2a16d56252dba83f9632-more-than-130-characters' | ||
const result = convertSignatures([signature], mockConvertSignature) | ||
|
||
expect(result[0]).toBe(signature) | ||
}) | ||
|
||
it('should convert signature given string with length === 130 characters', () => { | ||
const signature = 'SIG_K1_HKkqi3zray76i63ZQwAHWMjoLk3wTa1ajZWPcUnrhgmSWQYEHDJsxkny6VDTWEmVdfktxpGoTA81qe6QuCrDmazeQndmxhktxpGoTA81qe6QuCrDmazeQndmxhD' | ||
const result = convertSignatures([signature], mockConvertSignature) | ||
|
||
expect(result[0]).toBe(mockedConvertedSignatureValue) | ||
}) | ||
|
||
it('should convert signature given string with length === 130 characters, but not another signature with length < 130 characters', () => { | ||
const signature1 = 'SIG_K1_HKkqi3zray76i63ZQwAHWMjoLk3wTa1ajZWPcUnrhgmSWQYEHDJsxkny6VDTWEmVdfktxpGoTA81qe6QuCrDmazeQndmxhktxpGoTA81qe6QuCrDmazeQndmxhD' | ||
const signature2 = 'someSignature' | ||
const result = convertSignatures([signature1, signature2], mockConvertSignature) | ||
|
||
expect(result[0]).toBe(mockedConvertedSignatureValue) | ||
expect(result[1]).toBe(signature2) | ||
}) | ||
|
||
it('should convert signature given string with length === 130 characters, but not another signature with length > 130 characters', () => { | ||
const signature1 = 'SIG_K1_HKkqi3zray76i63ZQwAHWMjoLk3wTa1ajZWPcUnrhgmSWQYEHDJsxkny6VDTWEmVdfktxpGoTA81qe6QuCrDmazeQndmxhktxpGoTA81qe6QuCrDmazeQndmxhD' | ||
const signature2 = '4cf0909aa10f10341cd7ca013630492d09b65e50c80974e962d94bbc95df635e90afb2e4dd22eb254cb451ca26a6aeb0b88e9b031a2233b2a16d56252dba83f9632-more-than-130-characters' | ||
const result = convertSignatures([signature1, signature2], mockConvertSignature) | ||
|
||
expect(result[0]).toBe(mockedConvertedSignatureValue) | ||
expect(result[1]).toBe(signature2) | ||
}) | ||
|
||
it('should convert multiple signatures given string with length === 130 characters', () => { | ||
const signature1 = 'SIG_K1_HKkqi3zray76i63ZQwAHWMjoLk3wTa1ajZWPcUnrhgmSWQYEHDJsxkny6VDTWEmVdfktxpGoTA81qe6QuCrDmazeQndmxhktxpGoTA81qe6QuCrDmazeQndmxhD' | ||
const signature2 = 'SIG_K1_HKkqi3zray76i63ZQwAHWMjoLk3wTa1ajZWPcUnrhgmSWQYEHDJsxkny6VDTWEmVdfktxpGoTA81qe6QuCrDmazeQndmxhktxpGoTA81qe6QuCrDmazeQndmxhD' | ||
const result = convertSignatures([signature1, signature2], mockConvertSignature) | ||
|
||
expect(result[0]).toBe(mockedConvertedSignatureValue) | ||
expect(result[1]).toBe(mockedConvertedSignatureValue) | ||
}) | ||
}) | ||
|
||
function mockConvertSignature(signature: string) { | ||
return mockedConvertedSignatureValue | ||
} |
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.