diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 366b89d20..4a7ba9d44 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -468,6 +468,21 @@ test-rust-stable: 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 test-rust-beta: stage: test only: @@ -475,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 [ "$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"&./test.sh $CARGOFLAGS --no-release; else echo "skip rust test"&./js/scripts/lint.sh&./js/scripts/test.sh&./js/scripts/build.sh; fi + - ./test.sh $CARGOFLAGS --no-release tags: - rust - rust-beta @@ -493,13 +505,9 @@ 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 [ "$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"&./test.sh $CARGOFLAGS --no-release; else echo "skip rust test"&./js/scripts/lint.sh&./js/scripts/test.sh&./js/scripts/build.sh; fi + - ./test.sh $CARGOFLAGS --no-release tags: - rust - rust-nightly @@ -517,6 +525,6 @@ js-release: - if [ "$JS_FILES_MODIFIED" = 0 ]; then echo "skip js build"; else ./js/scripts/install-deps.sh;fi script: - echo $JS_FILES_MODIFIED - - if [ "$JS_FILES_MODIFIED" = 0 ]; then echo "skip js build"; else ./js/scripts/build.sh&./js/scripts/release.sh; fi + - 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 809e5a07a..62ef5ea11 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1263,7 +1263,7 @@ dependencies = [ [[package]] name = "parity-ui-precompiled" version = "1.4.0" -source = "git+https://github.com/ethcore/js-precompiled.git#f1de5e5612d8237143b37aebf237a49475c2c4e6" +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 97066e40c..d509c7593 160000 --- a/ethcore/res/ethereum/tests +++ b/ethcore/res/ethereum/tests @@ -1 +1 @@ -Subproject commit 97066e40ccd061f727deb5cd860e4d9135aa2551 +Subproject commit d509c75936ec6cbba683ee1916aa0bca436bc376 diff --git a/ethcore/src/json_tests/transaction.rs b/ethcore/src/json_tests/transaction.rs index 438852124..12e82bca2 100644 --- a/ethcore/src/json_tests/transaction.rs +++ b/ethcore/src/json_tests/transaction.rs @@ -34,7 +34,7 @@ fn do_json_test(json_data: &[u8]) -> Vec { Some(x) if x < 1_150_000 => &old_schedule, Some(_) => &new_schedule }; - let allow_network_id_of_one = number.map_or(false, |n| n >= 3_500_000); + let allow_network_id_of_one = number.map_or(false, |n| n >= 2_675_000); let rlp: Vec = test.rlp.into(); let res = UntrustedRlp::new(&rlp) 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 6d8c37165..12b0cd9c6 100644 --- a/js/package.json +++ b/js/package.json @@ -1,6 +1,6 @@ { "name": "parity.js", - "version": "0.2.73", + "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 } />,