Skip to content

Commit 49f8393

Browse files
author
Aleix Morgadas
committed
changed tslint to not thrown error when unused-expression
changed PublicAccount to not thrown error when empty data
1 parent a589b13 commit 49f8393

File tree

4 files changed

+6
-15
lines changed

4 files changed

+6
-15
lines changed

src/model/account/PublicAccount.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ import { convert, KeyPair } from 'nem2-library';
1818
import { NetworkType } from '../blockchain/NetworkType';
1919
import { Address } from './Address';
2020

21+
const Hash512 = 64;
22+
2123
/**
2224
* The public account structure contains account's address and public key.
2325
*/
@@ -63,11 +65,11 @@ export class PublicAccount {
6365
* @return {boolean} - True if the signature is valid, false otherwise.
6466
*/
6567
public verifySignature(data: string, signature: string): boolean {
66-
if (!data || !signature) {
68+
if (!signature) {
6769
throw new Error('Missing argument');
6870
}
6971

70-
if (signature.length !== 128) {
72+
if (signature.length / 2 !== Hash512) {
7173
throw new Error('Signature length is incorrect');
7274
}
7375

test/model/account/Account.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,6 @@ describe('Account', () => {
5454
const publicAccount = account.publicAccount;
5555
const signed = account.signData('catapult rocks!');
5656
expect(publicAccount.verifySignature('catapult rocks!', signed))
57-
.to.be.equal(true);
57+
.to.be.true;
5858
});
5959
});

test/model/account/PublicAccount.spec.ts

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -96,15 +96,4 @@ describe('Signature verification', () => {
9696
// Act & Assert:
9797
expect(signerPublicAccount.verifySignature(data, signature)).equal(false);
9898
});
99-
100-
it('Throw error if signature verification is missing a parameter', () => {
101-
// Arrange:
102-
const signerPublicAccount = PublicAccount.createFromPublicKey('22816F825B4CACEA334723D51297D8582332D8B875A5829908AAE85831ABB508',
103-
NetworkType.MIJIN_TEST);
104-
const data = '';
105-
const signature = 'B01DCA6484026C2ECDF3C822E64DEAAFC15EBCCE337EEE209C28513CB5351CDED8863A8E7B855CD471B55C91FAE611C548625C9A5916A555A24F72F3526FA508';// tslint:disable-line
106-
107-
// Act & Assert:
108-
expect(() => { signerPublicAccount.verifySignature(data, signature); }).to.throw('Missing argument');
109-
});
11099
});

tslint.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373
"no-switch-case-fall-through": true,
7474
"no-trailing-whitespace": true,
7575
"no-unnecessary-initializer": true,
76-
"no-unused-expression": true,
76+
"no-unused-expression": false,
7777
"no-use-before-declare": true,
7878
"no-var-keyword": true,
7979
"object-literal-sort-keys": false,

0 commit comments

Comments
 (0)