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

Update to Lisk Core 1.0.0 API - Closes #341 #1032

Merged
merged 50 commits into from
May 15, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
ca1e6fb
Update lisk core to 1.0.0
slaweet Jan 22, 2018
5ad1431
Disable e2e tests with other networks
slaweet Jan 23, 2018
27f59fc
Replace all uses of account.secondSecret with account.secondPublicKey
slaweet Jan 23, 2018
c59ae6e
Test against core 1.0.0-alpha.3 from lisk-docker
francoilol Mar 23, 2018
147d158
Update translatiion strings
yasharAyari Apr 20, 2018
f04566e
Use new api of lisk-js in peers middleware
yasharAyari Apr 20, 2018
45ce9f5
Update lisk-js to version 1.0.0
yasharAyari Apr 20, 2018
3c26fda
Use new api of lisk-js in DecryptMessage and EncryptMessage
yasharAyari Apr 20, 2018
e37b34e
Use new api of lisk-js in middlewares
yasharAyari Apr 20, 2018
5c4b600
Use new api of lisk-js in SignMessage and VerifyMessage
yasharAyari Apr 20, 2018
f25d671
Use new api of lisk-js in voting component
yasharAyari Apr 20, 2018
1302a30
Fix a bug in notice component
yasharAyari Apr 20, 2018
1dcb6d5
Use new api of lisk-js in voteAutocomplete component
yasharAyari Apr 20, 2018
ada307b
Use new api of lisk-js in reducers
yasharAyari Apr 20, 2018
5a5f0fb
Use new api of lisk-js in api utils
yasharAyari Apr 20, 2018
59f68c5
Fix a bug in account component
yasharAyari Apr 20, 2018
ca2e4ce
Merge branch 'development' into 341-update-lisk-core-to-1-0-0
slaweet Apr 26, 2018
198ce82
Test against lisk/development:1.0.0-beta.7.1
francoilol Apr 30, 2018
344ac37
Use new api of lisk-js in forging
yasharAyari May 2, 2018
38e8d01
Change pending transactions to work with new api of lisk-js
yasharAyari May 2, 2018
7f28554
Fix a bug in login middleware
yasharAyari May 2, 2018
74f7987
Merge branch '341-update-lisk-core-to-1-0-0' of https://github.com/Li…
yasharAyari May 2, 2018
d20b5d3
Remove nethash and peers api utils
yasharAyari May 7, 2018
6603b9a
Update some unit test files to work with new version of lisk-js
yasharAyari May 7, 2018
9a28d06
Use new api of lisk-js in unconfirmedTransactions method
yasharAyari May 7, 2018
3c64904
Fix some bugs in peers action
yasharAyari May 7, 2018
817de55
Fix delegate username bug in address component
yasharAyari May 7, 2018
1ededa8
Update protractor config
yasharAyari May 7, 2018
8ac17f3
Fix a translation string in peers action
yasharAyari May 7, 2018
7aae8e1
Fix a bug in account api
yasharAyari May 7, 2018
2b27613
Increase limit in listAccountDelegates api to 101
yasharAyari May 8, 2018
e700064
Update signMessage and verifyMessage e2e tests to work with api changes
yasharAyari May 8, 2018
4987103
Comment transactions infiniteScroll e2e tests
yasharAyari May 8, 2018
55847d6
Fix a bug in delegate utils unit test
yasharAyari May 8, 2018
8417ca9
Increase waiting time after delegate registration
yasharAyari May 8, 2018
507e403
Add pending tag to some e2e tests
yasharAyari May 8, 2018
139a33c
Fix a bug in account api utils
yasharAyari May 9, 2018
1acce09
Comment some e2e tests
yasharAyari May 9, 2018
247006a
Add lolex as devDependency to package.json
yasharAyari May 11, 2018
66e0909
Fix a bug in register delegate feature file
yasharAyari May 11, 2018
3b12faf
Merge branch 'development' into 341-update-lisk-core-to-1-0-0
yasharAyari May 14, 2018
a51ffca
Sort list of delegates by rank
yasharAyari May 14, 2018
15e9ad4
Use loading actions in api calls
yasharAyari May 14, 2018
3f4e9d4
Fix a bug in delegate api utils
yasharAyari May 14, 2018
f967009
Update some translation strings
yasharAyari May 14, 2018
f8bfeb3
Improve verfiyMessage component
yasharAyari May 14, 2018
bad6413
Fix a bug in login middleware
yasharAyari May 14, 2018
10da982
Use loadingFinished in all api calls failed status
yasharAyari May 15, 2018
3e0daad
Fix s bug in peers action
yasharAyari May 15, 2018
46f448e
Fix a bug in voting e2e tests
yasharAyari May 15, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 20 additions & 31 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -40,34 +40,6 @@ node('lisk-nano') {
echo "Error: ${err}"
fail('Stopping build: checkout failed')
}

try {
sh '''
N=${EXECUTOR_NUMBER:-0}; N=$((N+1))
cd ~/lisk-Linux-x86_64
# work around core bug: config.json gets overwritten; use backup
cp .config.json config_$N.json
# change core port, listen only on 127.0.0.1
sed -i -r -e "s/^(.*ort\\":) 4000,/\\1 400$N,/" config_$N.json
sed -i -r -e "s/^(.*\\"address\\":) \\"0.0.0.0\\",/\\1 \\"127.0.0.1\\",/" config_$N.json
# disable redis
sed -i -r -e "s/^(\\s*\\"cacheEnabled\\":) true/\\1 false/" config_$N.json
# change postgres databse
sed -i -r -e "s/^(\\s*\\"database\\": \\"lisk_test)\\",/\\1_$N\\",/" config_$N.json
cp etc/pm2-lisk.json etc/pm2-lisk_$N.json
sed -i -r -e "s/config.json/config_$N.json/" etc/pm2-lisk_$N.json
sed -i -r -e "s/(lisk.app)/\\1_$N/" etc/pm2-lisk_$N.json
# logs
sed -i -r -e "s/lisk.log/lisk_${JOB_BASE_NAME}_${BUILD_ID}.log/" config_$N.json
sed -i -r -e "s/lisk.app_$N/lisk.app_$N_${JOB_BASE_NAME}_${BUILD_ID}/" etc/pm2-lisk_$N.json
#
JENKINS_NODE_COOKIE=dontKillMe bash lisk.sh start_db -p etc/pm2-lisk_$N.json
bash lisk.sh rebuild -p etc/pm2-lisk_$N.json -f blockchain_explorer.db.gz
'''
} catch (err) {
echo "Error: ${err}"
fail('Stopping build: Lisk Core failed to start')
}
}

stage ('Install npm dependencies') {
Expand Down Expand Up @@ -142,6 +114,13 @@ node('lisk-nano') {
export DISPLAY=:1$N
Xvfb :1$N -ac -screen 0 1280x1024x24 &

cp -r ~/lisk-docker/examples/development $WORKSPACE/$BRANCH_NAME
cd $WORKSPACE/$BRANCH_NAME
cp /home/lisk/blockchain_explorer.db.gz ./blockchain.db.gz
LISK_VERSION=1.0.0-beta.7.1 make coldstart
LISK_PORT=$( docker-compose port lisk 4000 |cut -d ":" -f 2 )
cd -

# Run end-to-end tests

npm run serve -- $WORKSPACE/app/build -p 300$N -a 127.0.0.1 &>server.log &
Expand All @@ -150,7 +129,7 @@ node('lisk-nano') {
else
echo "Skipping @testnet end-to-end tests because we're not on 'development' branch"
fi
npm run --silent e2e-test -- --params.baseURL http://127.0.0.1:300$N --params.liskCoreURL http://127.0.0.1:400$N
npm run --silent e2e-test -- --params.baseURL http://127.0.0.1:300$N --params.liskCoreURL http://127.0.0.1:$LISK_PORT
if [ -z $CHANGE_BRANCH ]; then
npm run --silent e2e-test -- --params.baseURL http://127.0.0.1:300$N --cucumberOpts.tags @testnet --params.useTestnetPassphrase true --params.network testnet
else
Expand All @@ -166,11 +145,21 @@ node('lisk-nano') {
}
} catch(err) {
echo "Error: ${err}"
ansiColor('xterm') {
sh '''
cd $WORKSPACE/$BRANCH_NAME
docker-compose logs
'''
}
} finally {
ansiColor('xterm') {
sh '''
cd $WORKSPACE/$BRANCH_NAME
make mrproper
'''
}
sh '''
N=${EXECUTOR_NUMBER:-0}; N=$((N+1))
curl --verbose http://127.0.0.1:400$N/api/blocks/getNethash || true
( cd ~/lisk-Linux-x86_64 && bash lisk.sh stop_node -p etc/pm2-lisk_$N.json ) || true
pgrep --list-full -f "Xvfb :1$N" || true
pkill --echo -f "Xvfb :1$N" -9 || echo "pkill returned code $?"

Expand Down
4 changes: 3 additions & 1 deletion i18n/locales/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@
"Message decryption failed": "Message decryption failed",
"Message encryption failed": "Message encryption failed",
"Message is decrypted successfully": "Message is decrypted successfully",
"Message not verified": "Message not verified",
"Message verified": "Message verified",
"Minimize": "Minimize",
"Move your mouse to generate random bytes": "Move your mouse to generate random bytes",
"Multisignature Creation": "Multisignature Creation",
Expand All @@ -96,7 +98,6 @@
"Note: After the registration is complete, your second passphrase will be required for all outgoing transactions from this account.": "Note: After the registration is complete, your second passphrase will be required for all outgoing transactions from this account.",
"Note: Digital Signatures and signed messages are not encrypted!": "Note: Digital Signatures and signed messages are not encrypted!",
"Ok": "Ok",
"Original Message": "Original Message",
"Passphrase": "Passphrase",
"Passphrase contains extra whitespace between words": "Passphrase contains extra whitespace between words",
"Passphrase contains unnecessary whitespace at the beginning": "Passphrase contains unnecessary whitespace at the beginning",
Expand Down Expand Up @@ -155,6 +156,7 @@
"Sign message": "Sign message",
"Signature": "Signature",
"Signing a message with this tool indicates ownership of a privateKey (secret) and provides a level of proof that you are the owner of the key. Its important to bear in mind that this is not a 100% proof as computer systems can be compromised, but is still an effective tool for proving ownership of a particular publicKey/address pair.": "Signing a message with this tool indicates ownership of a privateKey (secret) and provides a level of proof that you are the owner of the key. Its important to bear in mind that this is not a 100% proof as computer systems can be compromised, but is still an effective tool for proving ownership of a particular publicKey/address pair.",
"Status": "Status",
"Submit": "Submit",
"Success": "Success",
"Switch": "Switch",
Expand Down
9 changes: 6 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"i18next": "=10.0.3",
"i18next-localstorage-cache": "=1.1.1",
"i18next-xhr-backend": "=1.4.2",
"lisk-js": "0.5.1",
"lisk-js": "1.0.0-beta.1",
"moment": "2.20.1",
"numeral": "=2.0.6",
"postcss": "6.0.12",
Expand Down Expand Up @@ -106,8 +106,10 @@
"extract-text-webpack-plugin": "3.0.0",
"file-loader": "1.1.0",
"glob": "=7.1.2",
"http-server": "0.11.1",
"i18next-scanner": "=2.0.0",
"imports-loader": "0.7.1",
"install": "0.11.0",
"js-nacl": "=1.2.2",
"json-loader": "0.5.7",
"karma": "1.7.1",
Expand All @@ -120,8 +122,10 @@
"karma-sourcemap-loader": "=0.3.7",
"karma-verbose-reporter": "=0.0.6",
"karma-webpack": "2.0.4",
"lolex": "=2.3.2",
"mocha": "3.5.3",
"mocha-steps": "1.1.0",
"npm": "6.0.1",
"postcss-for": "=2.1.1",
"postcss-loader": "=2.0.6",
"postcss-partial-import": "=4.1.0",
Expand All @@ -144,8 +148,7 @@
"url-loader": "0.5.9",
"webpack": "3.6.0",
"webpack-bundle-analyzer": "2.9.0",
"webpack-dev-server": "2.8.2",
"http-server": "0.11.1"
"webpack-dev-server": "2.8.2"
},
"build": {
"appId": "io.lisk.nano",
Expand Down
2 changes: 1 addition & 1 deletion protractor.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ exports.config = {
params: {
screenshotFolder: 'e2e-test-screenshots',
baseURL: 'http://localhost:8080/',
liskCoreURL: 'http://localhost:4000/',
liskCoreURL: 'http://localhost:4000',
testnetPassphrase: process.env.TESTNET_PASSPHRASE,
useTestnetPassphrase: false,
network: 'customNode',
Expand Down
16 changes: 13 additions & 3 deletions src/actions/account.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { errorAlertDialogDisplayed } from './dialog';
import Fees from '../constants/fees';
import { toRawLsk } from '../utils/lsk';
import transactionTypes from '../constants/transactionTypes';
import { loadingStarted, loadingFinished } from '../utils/loading';

/**
* Trigger this action to update the account object
Expand Down Expand Up @@ -52,17 +53,20 @@ export const passphraseUsed = data => ({
*/
export const secondPassphraseRegistered = ({ activePeer, secondPassphrase, account }) =>
(dispatch) => {
loadingStarted('secondPassphraseRegistered');
setSecondPassphrase(activePeer, secondPassphrase, account.publicKey, account.passphrase)
.then((data) => {
loadingFinished('secondPassphraseRegistered');
dispatch(transactionAdded({
id: data.transactionId,
id: data.id,
senderPublicKey: account.publicKey,
senderId: account.address,
amount: 0,
fee: Fees.setSecondPassphrase,
type: transactionTypes.setSecondPassphrase,
}));
}).catch((error) => {
loadingFinished('secondPassphraseRegistered');
const text = (error && error.message) ? error.message : i18next.t('An error occurred while registering your second passphrase. Please try again.');
dispatch(errorAlertDialogDisplayed({ text }));
});
Expand All @@ -75,11 +79,13 @@ export const secondPassphraseRegistered = ({ activePeer, secondPassphrase, accou
export const delegateRegistered = ({
activePeer, account, passphrase, username, secondPassphrase }) =>
(dispatch) => {
loadingStarted('delegateRegistered');
registerDelegate(activePeer, username, passphrase, secondPassphrase)
.then((data) => {
loadingFinished('delegateRegistered');
// dispatch to add to pending transaction
dispatch(transactionAdded({
id: data.transactionId,
id: data.id,
senderPublicKey: account.publicKey,
senderId: account.address,
username,
Expand All @@ -89,6 +95,7 @@ export const delegateRegistered = ({
}));
})
.catch((error) => {
loadingFinished('delegateRegistered');
const text = error && error.message ? `${error.message}.` : i18next.t('An error occurred while registering as delegate.');
const actionObj = errorAlertDialogDisplayed({ text });
dispatch(actionObj);
Expand All @@ -101,10 +108,12 @@ export const delegateRegistered = ({
*/
export const sent = ({ activePeer, account, recipientId, amount, passphrase, secondPassphrase }) =>
(dispatch) => {
loadingStarted('sent');
send(activePeer, recipientId, toRawLsk(amount), passphrase, secondPassphrase)
.then((data) => {
loadingFinished('sent');
dispatch(transactionAdded({
id: data.transactionId,
id: data.id,
senderPublicKey: account.publicKey,
senderId: account.address,
recipientId,
Expand All @@ -114,6 +123,7 @@ export const sent = ({ activePeer, account, recipientId, amount, passphrase, sec
}));
})
.catch((error) => {
loadingFinished('sent');
const text = error && error.message ? `${error.message}.` : i18next.t('An error occurred while creating the transaction.');
dispatch(errorAlertDialogDisplayed({ text }));
});
Expand Down
6 changes: 3 additions & 3 deletions src/actions/account.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ describe('actions: account', () => {
});

it('should dispatch transactionAdded action if resolved', () => {
accountApiMock.returnsPromise().resolves({ transactionId: '15626650747375562521' });
accountApiMock.returnsPromise().resolves({ id: '15626650747375562521' });
const expectedAction = {
id: '15626650747375562521',
senderPublicKey: 'test_public-key',
Expand Down Expand Up @@ -122,7 +122,7 @@ describe('actions: account', () => {
});

it('should dispatch transactionAdded action if resolved', () => {
delegateApiMock.returnsPromise().resolves({ transactionId: '15626650747375562521' });
delegateApiMock.returnsPromise().resolves({ id: '15626650747375562521' });
const expectedAction = {
id: '15626650747375562521',
senderPublicKey: 'test_public-key',
Expand Down Expand Up @@ -184,7 +184,7 @@ describe('actions: account', () => {
});

it('should dispatch transactionAdded action if resolved', () => {
accountApiMock.returnsPromise().resolves({ transactionId: '15626650747375562521' });
accountApiMock.returnsPromise().resolves({ id: '15626650747375562521' });
const expectedAction = {
id: '15626650747375562521',
senderPublicKey: 'test_public-key',
Expand Down
19 changes: 13 additions & 6 deletions src/actions/forging.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import actionTypes from '../constants/actions';
import { getForgedBlocks, getForgedStats } from '../utils/api/forging';
import { errorAlertDialogDisplayed } from './dialog';
import { loadingStarted, loadingFinished } from '../utils/loading';

export const forgedBlocksUpdated = data => ({
data,
Expand All @@ -9,11 +10,14 @@ export const forgedBlocksUpdated = data => ({

export const fetchAndUpdateForgedBlocks = ({ activePeer, limit, offset, generatorPublicKey }) =>
(dispatch) => {
loadingStarted('fetchAndUpdateForgedBlocks');
getForgedBlocks(activePeer, limit, offset, generatorPublicKey)
.then(response =>
dispatch(forgedBlocksUpdated(response.blocks)),
)
.then((response) => {
loadingFinished('fetchAndUpdateForgedBlocks');
return dispatch(forgedBlocksUpdated(response.data));
})
.catch((error) => {
loadingFinished('fetchAndUpdateForgedBlocks');
dispatch(errorAlertDialogDisplayed({ text: error.message }));
});
};
Expand All @@ -25,11 +29,14 @@ export const forgingStatsUpdated = data => ({

export const fetchAndUpdateForgedStats = ({ activePeer, key, startMoment, generatorPublicKey }) =>
(dispatch) => {
loadingStarted('fetchAndUpdateForgedStats');
getForgedStats(activePeer, startMoment, generatorPublicKey)
.then(response =>
dispatch(forgingStatsUpdated({ [key]: response.forged })),
)
.then((response) => {
loadingFinished('fetchAndUpdateForgedStats');
return dispatch(forgingStatsUpdated({ [key]: response.data.forged }));
})
.catch((error) => {
loadingFinished('fetchAndUpdateForgedStats');
dispatch(errorAlertDialogDisplayed({ text: error.message }));
});
};
4 changes: 2 additions & 2 deletions src/actions/forging.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ describe('actions', () => {
});

it('should dispatch forgedBlocksUpdated action if resolved', () => {
forgingApiMock.returnsPromise().resolves({ blocks: 'value' });
forgingApiMock.returnsPromise().resolves({ data: 'value' });

actionFunction(dispatch);
expect(dispatch).to.have.been.calledWith(forgedBlocksUpdated('value'));
Expand Down Expand Up @@ -100,7 +100,7 @@ describe('actions', () => {
});

it('should dispatch forgingStatsUpdated action if resolved', () => {
forgingApiMock.returnsPromise().resolves({ forged: 'value' });
forgingApiMock.returnsPromise().resolves({ data: { forged: 'value' } });

actionFunction(dispatch);
expect(dispatch).to.have.been.calledWith(forgingStatsUpdated({ [key]: 'value' }));
Expand Down
19 changes: 13 additions & 6 deletions src/actions/peers.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
import i18next from 'i18next';
import Lisk from 'lisk-js';
import actionTypes from '../constants/actions';
import { getNethash } from './../utils/api/nethash';
// import { getNethash } from './../utils/api/nethash';
import { errorToastDisplayed } from './toaster';
import netHashes from '../constants/netHashes';
import { loadingStarted, loadingFinished } from '../utils/loading';

const peerSet = (data, config) => ({
data: Object.assign({
passphrase: data.passphrase,
publicKey: data.publicKey,
activePeer: Lisk.api(config),
activePeer: new Lisk.APIClient(config.nodes, config.nethash, {}),
options: config,
}),
type: actionTypes.activePeerSet,
});
Expand All @@ -36,18 +38,23 @@ export const activePeerSet = data =>
config.node = hostname;
config.ssl = protocol === 'https:';
config.port = port || (config.ssl ? 443 : 80);
config.nodes = [`${protocol}//${hostname}:${port}`];
}
if (config.testnet === undefined && config.port !== undefined) {
config.testnet = config.port === '7000';
}
if (config.custom) {
getNethash(Lisk.api(config)).then((response) => {
config.testnet = response.nethash === netHashes.testnet;
if (!config.testnet && response.nethash !== netHashes.mainnet) {
config.nethash = response.nethash;
const getNethash = new Lisk.APIClient(config.nodes, config.nethash, {});
loadingStarted('getConstants');
getNethash.node.getConstants().then((response) => {
loadingFinished('getConstants');
config.testnet = response.data.nethash === netHashes.testnet;
if (!config.testnet && response.data.nethash !== netHashes.mainnet) {
config.nethash = response.data.nethash;
}
dispatch(peerSet(data, config));
}).catch(() => {
loadingFinished('getConstants');
dispatch(errorToastDisplayed({ label: i18next.t('Unable to connect to the node') }));
});
} else {
Expand Down
Loading