diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 8df41550c..4a7ba9d44 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -348,15 +348,22 @@ darwin: - stable - triggers script: + - cargo build --release -p ethstore $CARGOFLAGS - cargo build --release $CARGOFLAGS - rm -rf parity.md5 - md5sum target/release/parity > parity.md5 + - packagesbuild -v mac/Parity.pkgproj + - export VER=$(grep -m 1 version Cargo.toml | awk '{print $3}' | tr -d '"' | tr -d "\n") + - mv target/release/Parity\ Ethereum.pkg "parity-"$VER"-osx-installer-EXPERIMENTAL.pkg" + - md5sum "parity-"$VER"-osx-installer-EXPERIMENTAL.pkg" >> "parity-"$VER"-osx-installer-EXPERIMENTAL.pkg.md5" - aws configure set aws_access_key_id $s3_key - aws configure set aws_secret_access_key $s3_secret - if [[ $CI_BUILD_REF_NAME =~ ^(master|beta|stable)$ ]]; then export S3_BUCKET=builds-parity-published; else export S3_BUCKET=builds-parity; fi - aws s3 rm --recursive s3://$S3_BUCKET/$CI_BUILD_REF_NAME/x86_64-apple-darwin - aws s3api put-object --bucket $S3_BUCKET --key $CI_BUILD_REF_NAME/x86_64-apple-darwin/parity --body target/release/parity - aws s3api put-object --bucket $S3_BUCKET --key $CI_BUILD_REF_NAME/x86_64-apple-darwin/parity.md5 --body parity.md5 + - aws s3api put-object --bucket $S3_BUCKET --key $CI_BUILD_REF_NAME/x86_64-apple-darwin/"parity-"$VER"-osx-installer-EXPERIMENTAL.pkg" --body "parity-"$VER"-osx-installer-EXPERIMENTAL.pkg" + - aws s3api put-object --bucket $S3_BUCKET --key $CI_BUILD_REF_NAME/x86_64-apple-darwin/"parity-"$VER"-osx-installer-EXPERIMENTAL.pkg.md5" --body "parity-"$VER"-osx-installer-EXPERIMENTAL.pkg.md5" tags: - osx artifacts: @@ -453,11 +460,26 @@ test-rust-stable: - git submodule update --init --recursive - export JS_FILES_MODIFIED=$(git --no-pager diff --name-only $CI_BUILD_REF^ $CI_BUILD_REF | grep \.js | wc -l) - echo $JS_FILES_MODIFIED - - if [ -z $JS_FILES_MODIFIED ]; then echo "skip js test"; fi + - if [ "$JS_FILES_MODIFIED" = 0 ]; then echo "skip js test"; else ./js/scripts/install-deps.sh;fi script: - export RUST_BACKTRACE=1 - echo $JS_FILES_MODIFIED - - if [ -z $JS_FILES_MODIFIED ]; then echo "skip js test"; else ./test.sh $CARGOFLAGS --no-release; fi + - if [ "$JS_FILES_MODIFIED" = 0 ]; then echo "skip js test"&./test.sh $CARGOFLAGS --no-release; else echo "skip rust test"&./js/scripts/lint.sh&./js/scripts/test.sh&./js/scripts/build.sh; fi + tags: + - rust + - rust-stable +js-test: + stage: test + image: ethcore/rust:stable + before_script: + - git submodule update --init --recursive + - export JS_FILES_MODIFIED=$(git --no-pager diff --name-only $CI_BUILD_REF^ $CI_BUILD_REF | grep \.js | wc -l) + - echo $JS_FILES_MODIFIED + - if [ "$JS_FILES_MODIFIED" = 0 ]; then echo "skip js test"; else ./js/scripts/install-deps.sh;fi + script: + - export RUST_BACKTRACE=1 + - echo $JS_FILES_MODIFIED + - if [ "$JS_FILES_MODIFIED" = 0 ]; then echo "skip js test"; else echo "skip rust test"&./js/scripts/lint.sh&./js/scripts/test.sh&./js/scripts/build.sh; fi tags: - rust - rust-stable @@ -468,13 +490,10 @@ test-rust-beta: image: ethcore/rust:beta before_script: - git submodule update --init --recursive - - export JS_FILES_MODIFIED=$(git --no-pager diff --name-only $CI_BUILD_REF^ $CI_BUILD_REF | grep \.js | wc -l) - - echo $JS_FILES_MODIFIED - - if [ -z $JS_FILES_MODIFIED ]; then echo "skip js test"; fi script: - export RUST_BACKTRACE=1 - echo $JS_FILES_MODIFIED - - if [ -z $JS_FILES_MODIFIED ]; then echo "skip js test"; else ./test.sh $CARGOFLAGS --no-release; fi + - ./test.sh $CARGOFLAGS --no-release tags: - rust - rust-beta @@ -486,28 +505,13 @@ test-rust-nightly: image: ethcore/rust:nightly before_script: - git submodule update --init --recursive - - export JS_FILES_MODIFIED=$(git --no-pager diff --name-only $CI_BUILD_REF^ $CI_BUILD_REF | grep \.js | wc -l) - - echo $JS_FILES_MODIFIED - - if [ -z $JS_FILES_MODIFIED ]; then echo "skip js test"; fi script: - export RUST_BACKTRACE=1 - - echo $JS_FILES_MODIFIED - - if [ -z $JS_FILES_MODIFIED ]; then echo "skip js test"; else ./test.sh $CARGOFLAGS --no-release; fi + - ./test.sh $CARGOFLAGS --no-release tags: - rust - rust-nightly allow_failure: true -js-tests: - stage: test - image: ethcore/rust:stable - before_script: - - ./js/scripts/install-deps.sh - script: - - ./js/scripts/lint.sh - - ./js/scripts/test.sh - - ./js/scripts/build.sh - tags: - - javascript-test js-release: stage: js-build only: @@ -516,9 +520,11 @@ js-release: - stable image: ethcore/rust:stable before_script: - - if [[ $NIGHTLY != "master" ]]; then ./js/scripts/install-deps.sh; fi + - export JS_FILES_MODIFIED=$(git --no-pager diff --name-only $CI_BUILD_REF^ $CI_BUILD_REF | grep \.js | wc -l) + - echo $JS_FILES_MODIFIED + - if [ "$JS_FILES_MODIFIED" = 0 ]; then echo "skip js build"; else ./js/scripts/install-deps.sh;fi script: - - if [[ $NIGHTLY != "master" ]]; then ./js/scripts/build.sh; fi - - if [[ $NIGHTLY != "master" ]]; then ./js/scripts/release.sh; fi + - echo $JS_FILES_MODIFIED + - if [ "$JS_FILES_MODIFIED" = 0 ]; then echo "skip js build"; else ./js/scripts/build.sh&&./js/scripts/release.sh; fi tags: - javascript diff --git a/Cargo.lock b/Cargo.lock index c8920f522..71b2fcdaf 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1266,7 +1266,7 @@ dependencies = [ [[package]] name = "parity-ui-precompiled" version = "1.4.0" -source = "git+https://github.com/ethcore/js-precompiled.git#bed8cd5ea70b002300ed934f77f6fa3812fb380a" +source = "git+https://github.com/ethcore/js-precompiled.git#7cb42b0c636f76eb478c9270a1e507ac3c3ba434" dependencies = [ "parity-dapps-glue 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", ] diff --git a/ethcore/res/ethereum/tests b/ethcore/res/ethereum/tests index e8f4624b7..d509c7593 160000 --- a/ethcore/res/ethereum/tests +++ b/ethcore/res/ethereum/tests @@ -1 +1 @@ -Subproject commit e8f4624b7f1a15c63674eecf577c7ab76c3b16be +Subproject commit d509c75936ec6cbba683ee1916aa0bca436bc376 diff --git a/ethstore/src/random.rs b/ethstore/src/random.rs index 1d050e422..954ec500f 100644 --- a/ethstore/src/random.rs +++ b/ethstore/src/random.rs @@ -47,7 +47,7 @@ impl Random for [u8; 32] { pub fn random_phrase(words: usize) -> String { lazy_static! { static ref WORDS: Vec = String::from_utf8_lossy(include_bytes!("../res/wordlist.txt")) - .split("\n") + .lines() .map(|s| s.to_owned()) .collect(); } @@ -55,8 +55,19 @@ pub fn random_phrase(words: usize) -> String { (0..words).map(|_| rng.choose(&WORDS).unwrap()).join(" ") } -#[test] -fn should_produce_right_number_of_words() { - let p = random_phrase(10); - assert_eq!(p.split(" ").count(), 10); -} \ No newline at end of file +#[cfg(test)] +mod tests { + use super::random_phrase; + + #[test] + fn should_produce_right_number_of_words() { + let p = random_phrase(10); + assert_eq!(p.split(" ").count(), 10); + } + + #[test] + fn should_not_include_carriage_return() { + let p = random_phrase(10); + assert!(!p.contains('\r'), "Carriage return should be trimmed."); + } +} diff --git a/js/package.json b/js/package.json index f71ddfc1c..12b0cd9c6 100644 --- a/js/package.json +++ b/js/package.json @@ -1,6 +1,6 @@ { "name": "parity.js", - "version": "0.2.70", + "version": "0.2.74", "main": "release/index.js", "jsnext:main": "src/index.js", "author": "Parity Team ", diff --git a/js/src/api/format/input.js b/js/src/api/format/input.js index 55c85e4f3..80f3bc0eb 100644 --- a/js/src/api/format/input.js +++ b/js/src/api/format/input.js @@ -15,9 +15,9 @@ // along with Parity. If not, see . import BigNumber from 'bignumber.js'; -import { range } from 'lodash'; import { isArray, isHex, isInstanceOf, isString } from '../util/types'; +import { padLeft } from '../util/format'; export function inAddress (address) { // TODO: address validation if we have upper-lower addresses @@ -51,19 +51,20 @@ export function inHash (hash) { return inHex(hash); } -export function pad (input, length) { - const value = inHex(input).substr(2, length * 2); - return '0x' + value + range(length * 2 - value.length).map(() => '0').join(''); -} - export function inTopics (_topics) { let topics = (_topics || []) .filter((topic) => topic === null || topic) - .map((topic) => topic === null ? null : pad(topic, 32)); + .map((topic) => { + if (topic === null) { + return null; + } - // while (topics.length < 4) { - // topics.push(null); - // } + if (Array.isArray(topic)) { + return inTopics(topic); + } + + return padLeft(topic, 32); + }); return topics; } diff --git a/js/src/api/transport/error.js b/js/src/api/transport/error.js index 341839f69..6cb0dac17 100644 --- a/js/src/api/transport/error.js +++ b/js/src/api/transport/error.js @@ -36,7 +36,8 @@ export const ERROR_CODES = { REQUEST_NOT_FOUND: -32042, COMPILATION_ERROR: -32050, ENCRYPTION_ERROR: -32055, - FETCH_ERROR: -32060 + FETCH_ERROR: -32060, + INVALID_PARAMS: -32602 }; export default class TransportError extends ExtendableError { diff --git a/js/src/api/transport/ws/ws.js b/js/src/api/transport/ws/ws.js index c30c910e6..53600b6d3 100644 --- a/js/src/api/transport/ws/ws.js +++ b/js/src/api/transport/ws/ws.js @@ -79,7 +79,7 @@ export default class Ws extends JsonRpcBase { this._ws.onclose = this._onClose; this._ws.onmessage = this._onMessage; - // Get counts in dev mode + // Get counts in dev mode only if (process.env.NODE_ENV === 'development') { this._count = 0; this._lastCount = { @@ -93,8 +93,13 @@ export default class Ws extends JsonRpcBase { const s = Math.round(1000 * n / t) / 1000; if (this._debug) { - console.log('::parityWS', `speed: ${s} req/s`, `count: ${this._count}`); + console.log('::parityWS', `speed: ${s} req/s`, `count: ${this._count}`, `(+${n})`); } + + this._lastCount = { + timestamp: Date.now(), + count: this._count + }; }, 5000); window._parityWS = this; @@ -117,6 +122,7 @@ export default class Ws extends JsonRpcBase { this._connected = false; this._connecting = false; + event.timestamp = Date.now(); this._lastError = event; if (this._autoConnect) { @@ -144,6 +150,8 @@ export default class Ws extends JsonRpcBase { window.setTimeout(() => { if (this._connected) { console.error('ws:onError', event); + + event.timestamp = Date.now(); this._lastError = event; } }, 50); diff --git a/js/src/api/util/format.js b/js/src/api/util/format.js index 93f31a161..f1909748d 100644 --- a/js/src/api/util/format.js +++ b/js/src/api/util/format.js @@ -14,6 +14,9 @@ // You should have received a copy of the GNU General Public License // along with Parity. If not, see . +import { range } from 'lodash'; +import { inHex } from '../format/input'; + export function bytesToHex (bytes) { return '0x' + bytes.map((b) => ('0' + b.toString(16)).slice(-2)).join(''); } @@ -33,3 +36,13 @@ export function hex2Ascii (_hex) { export function asciiToHex (string) { return '0x' + string.split('').map((s) => s.charCodeAt(0).toString(16)).join(''); } + +export function padRight (input, length) { + const value = inHex(input).substr(2, length * 2); + return '0x' + value + range(length * 2 - value.length).map(() => '0').join(''); +} + +export function padLeft (input, length) { + const value = inHex(input).substr(2, length * 2); + return '0x' + range(length * 2 - value.length).map(() => '0').join('') + value; +} diff --git a/js/src/dapps/dappreg/ButtonBar/buttonBar.js b/js/src/dapps/dappreg/ButtonBar/buttonBar.js index 289def0ea..074c527d0 100644 --- a/js/src/dapps/dappreg/ButtonBar/buttonBar.js +++ b/js/src/dapps/dappreg/ButtonBar/buttonBar.js @@ -50,12 +50,12 @@ export default class ButtonBar extends Component { key='delete' label='Delete' warning - disabled={ !this.dappsStore.currentApp.isOwner && !this.dappsStore.isContractOwner } + disabled={ !this.dappsStore.currentApp || (!this.dappsStore.currentApp.isOwner && !this.dappsStore.isContractOwner) } onClick={ this.onDeleteClick } />,