Skip to content
This repository has been archived by the owner on Jun 7, 2019. It is now read-only.

Commit

Permalink
Added testing command targets to node built result
Browse files Browse the repository at this point in the history
  • Loading branch information
shuse2 committed Feb 8, 2018
1 parent 3122e4d commit e0f190f
Show file tree
Hide file tree
Showing 57 changed files with 144 additions and 81 deletions.
18 changes: 17 additions & 1 deletion .babelrc
Original file line number Diff line number Diff line change
@@ -1,12 +1,28 @@
{
"presets": ["env"],
"plugins": ["transform-runtime"],
"plugins": [
"transform-runtime",
["module-resolver", {
"root": ["./src"]
}
]
],
"env": {
"test": {
"plugins": ["istanbul", "rewire"]
},
"browsertest": {
"plugins": ["rewire"]
},
"buildcheck": {
"plugins": [
["module-resolver", {
"root": ["./dist-node"]
}
],
"istanbul",
"rewire"
]
}
}
}
19 changes: 18 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,23 @@
"curly": "off",
"indent": "off",
"no-confusing-arrow": "off",
"no-mixed-operators": "off"
"no-mixed-operators": "off",
"import/no-extraneous-dependencies": [
"error", {
"devDependencies": true,
"packageDir": "./"
}
]
},
"settings": {
"import/resolver": {
"node": {
"extensions": [".js"],
"moduleDirectory": [
"node_modules",
"src"
]
}
}
}
}
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"serve:browsertest": "http-server browsertest",
"jenkins": "grunt jenkins --verbose",
"build": "grunt build",
"build:check": "node -e \"require('./dist-node')\"",
"build:check": "BABEL_ENV=buildcheck nyc mocha test --recursive",
"build:browsertest": "grunt build-browsertest",
"precommit": "lint-staged && npm run eslint",
"prepush": "npm run eslint && npm test",
Expand All @@ -41,6 +41,7 @@
"devDependencies": {
"babel-cli": "=6.24.1",
"babel-plugin-istanbul": "=4.1.4",
"babel-plugin-module-resolver": "=3.0.0",
"babel-plugin-rewire": "=1.1.0",
"babel-plugin-transform-runtime": "=6.23.0",
"babel-preset-env": "=1.6.0",
Expand Down
3 changes: 3 additions & 0 deletions src/api/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"name": "api"
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
3 changes: 3 additions & 0 deletions src/cryptography/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"name": "cryptography"
}
File renamed without changes.
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
*/
import naclFactory from 'js-nacl';
import api from './api/liskApi';
import crypto from './crypto';
import crypto from './cryptography';
import passphrase from './passphrase';
import * as time from './transactions/utils/time';
import transaction from './transactions';
Expand Down
3 changes: 3 additions & 0 deletions src/passphrase/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"name": "passphrase"
}
2 changes: 1 addition & 1 deletion src/transactions/1_registerSecondPassphrase.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* Removal or modification of this copyright notice is prohibited.
*
*/
import cryptoModule from '../crypto';
import cryptoModule from 'cryptography';
import { SIGNATURE_FEE } from '../constants';
import { wrapTransactionCreator } from './utils';

Expand Down
2 changes: 1 addition & 1 deletion src/transactions/3_castVotes.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* Removal or modification of this copyright notice is prohibited.
*
*/
import cryptoModule from '../crypto';
import cryptoModule from 'cryptography';
import { VOTE_FEE } from '../constants';
import {
prependMinusToPublicKeys,
Expand Down
3 changes: 3 additions & 0 deletions src/transactions/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"name": "transactions"
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* Removal or modification of this copyright notice is prohibited.
*
*/
import crypto from '../../crypto';
import crypto from 'cryptography';

const getAddressAndPublicKeyFromRecipientData = ({
recipientId,
Expand Down
2 changes: 1 addition & 1 deletion src/transactions/utils/getTransactionBytes.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
*
*/
import bignum from 'browserify-bignum';
import cryptoModule from '../../crypto';
import cryptoModule from 'cryptography';

export const isValidValue = value => ![undefined, false, NaN].includes(value);

Expand Down
4 changes: 2 additions & 2 deletions src/transactions/utils/getTransactionHash.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
* Removal or modification of this copyright notice is prohibited.
*
*/
import crypto from '../../crypto';
import cryptoModule from 'cryptography';
import getTransactionBytes from './getTransactionBytes';

const getTransactionHash = transaction => {
const bytes = getTransactionBytes(transaction);
return crypto.hash(bytes);
return cryptoModule.hash(bytes);
};

export default getTransactionHash;
2 changes: 1 addition & 1 deletion src/transactions/utils/getTransactionId.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* Removal or modification of this copyright notice is prohibited.
*
*/
import cryptoModule from '../../crypto';
import cryptoModule from 'cryptography';
import getTransactionBytes from './getTransactionBytes';

const getTransactionId = transaction => {
Expand Down
12 changes: 8 additions & 4 deletions src/transactions/utils/signAndVerify.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
* Removal or modification of this copyright notice is prohibited.
*
*/
import crypto from '../../crypto';
import cryptoModule from 'cryptography';
import getTransactionHash from './getTransactionHash';

export const signTransaction = (transaction, passphrase) => {
const transactionHash = getTransactionHash(transaction);
return crypto.signData(transactionHash, passphrase);
return cryptoModule.signData(transactionHash, passphrase);
};

export const multiSignTransaction = (transaction, passphrase) => {
Expand All @@ -27,7 +27,7 @@ export const multiSignTransaction = (transaction, passphrase) => {

const transactionHash = getTransactionHash(transactionToSign);

return crypto.signData(transactionHash, passphrase);
return cryptoModule.signData(transactionHash, passphrase);
};

export const verifyTransaction = (transaction, secondPublicKey) => {
Expand All @@ -53,7 +53,11 @@ export const verifyTransaction = (transaction, secondPublicKey) => {
? transaction.signSignature
: transaction.signature;

const verified = crypto.verifyData(transactionHash, signature, publicKey);
const verified = cryptoModule.verifyData(
transactionHash,
signature,
publicKey,
);

return secondSignaturePresent
? verified && verifyTransaction(transactionWithoutSignature)
Expand Down
12 changes: 7 additions & 5 deletions src/transactions/utils/signRawTransaction.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* Removal or modification of this copyright notice is prohibited.
*
*/
import crypto from '../../crypto';
import cryptoModule from 'cryptography';
import { getTimeWithOffset } from './time';
import prepareTransaction from './prepareTransaction';

Expand All @@ -22,11 +22,13 @@ export default function signRawTransaction({
secondPassphrase,
timeOffset,
}) {
const { publicKey, address } = crypto.getAddressAndPublicKeyFromPassphrase(
passphrase,
);
const {
publicKey,
address,
} = cryptoModule.getAddressAndPublicKeyFromPassphrase(passphrase);
const senderSecondPublicKey = secondPassphrase
? crypto.getPrivateAndPublicKeyFromPassphrase(secondPassphrase).publicKey
? cryptoModule.getPrivateAndPublicKeyFromPassphrase(secondPassphrase)
.publicKey
: null;

const propertiesToAdd = {
Expand Down
2 changes: 1 addition & 1 deletion src/transactions/utils/validation.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* Removal or modification of this copyright notice is prohibited.
*
*/
import { bufferToHex, hexToBuffer } from '../../crypto/convert';
import { bufferToHex, hexToBuffer } from 'cryptography/convert';

export const validatePublicKey = publicKey => {
const publicKeyBuffer = hexToBuffer(publicKey);
Expand Down
2 changes: 1 addition & 1 deletion src/transactions/utils/wrapTransactionCreator.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* Removal or modification of this copyright notice is prohibited.
*
*/
import cryptoModule from '../../crypto';
import cryptoModule from 'cryptography';
import prepareTransaction from './prepareTransaction';
import { getTimeWithOffset } from './time';

Expand Down
11 changes: 11 additions & 0 deletions test/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,16 @@
},
"rules": {
"arrow-body-style": "off"
},
"settings": {
"import/resolver": {
"node": {
"extensions": [".js"],
"moduleDirectory": [
"node_modules",
"src"
]
}
}
}
}
6 changes: 3 additions & 3 deletions test/api/liskApi.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
* Removal or modification of this copyright notice is prohibited.
*
*/
import LiskAPI from '../../src/api/liskApi';
import LiskAPI from 'api/liskApi';

const privateApi = require('../../src/api/privateApi');
const utils = require('../../src/api/utils');
const privateApi = require('api/privateApi');
const utils = require('api/utils');

describe('Lisk API module', () => {
const fixedPoint = 10 ** 8;
Expand Down
2 changes: 1 addition & 1 deletion test/api/privateApi.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
*
*/
const popsicle = require('popsicle');
const privateApi = require('../../src/api/privateApi');
const privateApi = require('api/privateApi');

describe('privateApi module', () => {
const port = 7000;
Expand Down
2 changes: 1 addition & 1 deletion test/api/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* Removal or modification of this copyright notice is prohibited.
*
*/
const utils = require('../../src/api/utils');
const utils = require('api/utils');

describe('api utils module', () => {
const POST = 'POST';
Expand Down
4 changes: 2 additions & 2 deletions test/crypto/convert.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ import {
convertPrivateKeyEd2Curve,
bigNumberToBuffer,
bufferToBigNumberString,
} from '../../src/crypto/convert';
} from 'cryptography/convert';

const hash = require('../../src/crypto/hash');
const hash = require('cryptography/hash');

describe('convert', () => {
// keys for passphrase 'secret';
Expand Down
10 changes: 5 additions & 5 deletions test/crypto/encrypt.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@
* Removal or modification of this copyright notice is prohibited.
*
*/
import { version } from '../../package.json';
import {
encryptMessageWithPassphrase,
decryptMessageWithPassphrase,
encryptPassphraseWithPassword,
decryptPassphraseWithPassword,
} from '../../src/crypto/encrypt';
} from 'cryptography/encrypt';
import { version } from '../../package.json';

const convert = require('../../src/crypto/convert');
const keys = require('../../src/crypto/keys');
const hash = require('../../src/crypto/hash');
const convert = require('cryptography/convert');
const keys = require('cryptography/keys');
const hash = require('cryptography/hash');

describe('encrypt', () => {
const defaultPassphrase =
Expand Down
2 changes: 1 addition & 1 deletion test/crypto/hash.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* Removal or modification of this copyright notice is prohibited.
*
*/
import hashFunction from '../../src/crypto/hash';
import hashFunction from 'cryptography/hash';

describe('hash', () => {
const defaultText = 'text123*';
Expand Down
2 changes: 1 addition & 1 deletion test/crypto/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* Removal or modification of this copyright notice is prohibited.
*
*/
import cryptoModule from '../../src/crypto/index';
import cryptoModule from 'cryptography/index';

describe('crypto index.js', () => {
it('should export an object', () => {
Expand Down
6 changes: 3 additions & 3 deletions test/crypto/keys.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ import {
getPrivateAndPublicKeyBytesFromPassphrase,
getKeys,
getAddressAndPublicKeyFromPassphrase,
} from '../../src/crypto/keys';
} from 'cryptography/keys';

const convert = require('../../src/crypto/convert');
const hash = require('../../src/crypto/hash');
const convert = require('cryptography/convert');
const hash = require('cryptography/hash');

describe('keys', () => {
const defaultPassphrase = 'secret';
Expand Down
4 changes: 2 additions & 2 deletions test/crypto/sign.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ import {
signAndPrintMessage,
signData,
verifyData,
} from '../../src/crypto/sign';
} from 'cryptography/sign';

const keys = require('../../src/crypto/keys');
const keys = require('cryptography/keys');

const makeInvalid = str => {
const char = str[0] === '0' ? '1' : '0';
Expand Down
2 changes: 1 addition & 1 deletion test/passphrase/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* Removal or modification of this copyright notice is prohibited.
*
*/
import passphrase from '../../src/passphrase/index';
import passphrase from 'passphrase/index';

describe('passphrase index.js', () => {
it('should export an object', () => {
Expand Down
2 changes: 1 addition & 1 deletion test/passphrase/validation.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import {
getPassphraseValidationErrors,
locateUppercaseCharacters,
locateWhitespaces,
} from '../../src/passphrase/validation';
} from 'passphrase/validation';

describe('passphrase validation', () => {
describe('countPassphraseWhitespaces', () => {
Expand Down
4 changes: 2 additions & 2 deletions test/transactions/0_transfer.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
* Removal or modification of this copyright notice is prohibited.
*
*/
import transfer from '../../src/transactions/0_transfer';
import transfer from 'transactions/0_transfer';

const time = require('../../src/transactions/utils/time');
const time = require('transactions/utils/time');

describe('#transfer transaction', () => {
const fixedPoint = 10 ** 8;
Expand Down

0 comments on commit e0f190f

Please sign in to comment.