diff --git a/rustfmt.toml b/.rustfmt.toml similarity index 77% rename from rustfmt.toml rename to .rustfmt.toml index 5463be9e1..ba7d698ec 100644 --- a/rustfmt.toml +++ b/.rustfmt.toml @@ -1,7 +1,9 @@ -max_width = 120 -tab_spaces = 4 +hard_tabs = true reorder_imports = true reorder_modules = true -use_try_shorthand = true -hard_tabs = true +use_field_init_shorthand = true + +max_width = 120 +tab_spaces = 4 + newline_style = "Unix" \ No newline at end of file diff --git a/.travis.yml b/.travis.yml index 7fb85b105..0ed1db7ec 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,32 +3,27 @@ sudo: true language: minimal -cache: - cargo: true - directories: - - $HOME/build/darwinia-network/darwinia/node/runtime/wasm/target/wasm32-unknown-unknown/release +cache: cargo branches: - only: - - master - - develop + only: + - master + - develop env: - global: - - RUST_BACKTRACE=1 + global: + - RUST_BACKTRACE=1 + matrix: + - RUST_TOOLCHAIN=nightly TARGET=wasm + - RUST_TOOLCHAIN=nightly TARGET=native before_install: - # Check how much space we've got on this machine. - - df -h - - ls $HOME/build/darwinia-network/darwinia/node/runtime/wasm/target/wasm32-unknown-unknown/release + # Check how much space we've got on this machine. + - df -h -jobs: - include: - - stage: Install - script: ./ci/script.sh nightly wasm - - stage: Test - script: ./ci/script.sh stable native +script: + - ./ci/script.sh after_script: - # Check how much free disk space left after the build - - df -h \ No newline at end of file + # Check how much free disk space left after the build + - df -h \ No newline at end of file diff --git a/README.adoc b/README.adoc index c855a8573..58235fecc 100644 --- a/README.adoc +++ b/README.adoc @@ -4,9 +4,10 @@ :toc: :sectnums: -== Darwinia Relay Chain +image:https://travis-ci.org/AurevoirXavier/darwinia.svg[Build Status (Travis CI),link=https://travis-ci.org/AurevoirXavier/darwinia] +image:https://img.shields.io/badge/License-Apache%202.0-blue.svg[License,link=https://opensource.org/licenses/Apache-2.0] -image:https://github.com/darwinia-network/rfcs/raw/master/logo/darwinia.png[image] +== Darwinia Relay Chain Darwinia Relay Chain is the hub relay chain connecting different Darwinia AppChains and can be connected to Polkadot as a Polkadot Parachain. diff --git a/ci/script.sh b/ci/script.sh index a136777f3..3b902f0e0 100755 --- a/ci/script.sh +++ b/ci/script.sh @@ -3,14 +3,11 @@ set -eux # Install rustup and the specified rust toolchain. -curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain=$1 -y +curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain=$RUST_TOOLCHAIN -y # Load cargo environment. Specifically, put cargo into PATH. source ~/.cargo/env -# Make sure using the nightly toolchain -rustup default nightly - # Install wasm toolchain rustup target add wasm32-unknown-unknown @@ -18,17 +15,17 @@ rustup --version cargo --version rustc --version -case $2 in +case $TARGET in "native") sudo apt-get -y update sudo apt-get install -y cmake pkg-config libssl-dev # Unit test - cargo test --release --all --locked + cargo test --release --all --locked "$@" ;; "wasm") # Build test - cargo build + cargo build --locked "$@" ;; esac \ No newline at end of file diff --git a/core/merkle-patricia-trie/src/proof.rs b/core/merkle-patricia-trie/src/proof.rs index 1d0e6758b..cd54a98a6 100644 --- a/core/merkle-patricia-trie/src/proof.rs +++ b/core/merkle-patricia-trie/src/proof.rs @@ -43,7 +43,7 @@ mod tests { #[test] fn test_encode_decode() { let nodes = vec![vec![0u8], vec![1], vec![2]]; - let expected = Proof { nodes: nodes }; + let expected = Proof { nodes }; let rlp_proof = rlp::encode(&expected); let out_proof: Proof = rlp::decode(&rlp_proof).unwrap(); println!("{:?}", out_proof); diff --git a/node/cli/src/chain_spec.rs b/node/cli/src/chain_spec.rs index 41578b625..6a26ce124 100644 --- a/node/cli/src/chain_spec.rs +++ b/node/cli/src/chain_spec.rs @@ -334,7 +334,7 @@ pub fn local_testnet_config() -> ChainSpec { ) } -/// c￿rayfish testnet config (multivalidator Alice + Bob) +/// IceFrog testnet config (multivalidator Alice + Bob) pub fn icefrog_testnet_config() -> ChainSpec { fn icefrog_config_genesis() -> GenesisConfig { darwinia_genesis( diff --git a/node/cli/src/service.rs b/node/cli/src/service.rs index 4ad0841c5..7bf554096 100644 --- a/node/cli/src/service.rs +++ b/node/cli/src/service.rs @@ -201,7 +201,7 @@ macro_rules! new_full { (true, false) => { // start the full GRANDPA voter let grandpa_config = grandpa::GrandpaParams { - config: config, + config, link: grandpa_link, network: service.network(), inherent_data_providers: inherent_data_providers.clone(), diff --git a/node/runtime/src/impls.rs b/node/runtime/src/impls.rs index c23ef634e..dd847e772 100644 --- a/node/runtime/src/impls.rs +++ b/node/runtime/src/impls.rs @@ -112,7 +112,8 @@ impl> Convert for TargetedFeeAdjustment { } else { // Proof: first_term > second_term. Safe subtraction. let negative = first_term - second_term; - multiplier.saturating_sub(negative) + multiplier + .saturating_sub(negative) // despite the fact that apply_to saturates weight (final fee cannot go below 0) // it is crucially important to stop here and don't further reduce the weight fee // multiplier. While at -1, it means that the network is so un-congested that all diff --git a/srml/staking/src/tests.rs b/srml/staking/src/tests.rs index 1815d8556..20053a4c1 100644 --- a/srml/staking/src/tests.rs +++ b/srml/staking/src/tests.rs @@ -450,12 +450,20 @@ fn staking_should_work() { assert_eq_uvec!(validator_controllers(), vec![20, 10]); // Put some money in account that we'll use. - for i in 1..5 { let _ = Ring::make_free_balance_be(&i, 2000); } + for i in 1..5 { + let _ = Ring::make_free_balance_be(&i, 2000); + } // --- Block 1: start_session(1); // Add a new candidate for being a validator. account 3 controlled by 4. - assert_ok!(Staking::bond(Origin::signed(3), 4, StakingBalances::RingBalance(1500), RewardDestination::Controller, 0)); + assert_ok!(Staking::bond( + Origin::signed(3), + 4, + StakingBalances::RingBalance(1500), + RewardDestination::Controller, + 0, + )); assert_ok!(Staking::validate( Origin::signed(4), ValidatorPrefs { @@ -473,7 +481,6 @@ fn staking_should_work() { // No effects will be seen so far. Era has not been yet triggered. assert_eq_uvec!(validator_controllers(), vec![20, 10]); - // --- Block 3: the validators will now be queued. start_session(3); assert_eq!(Staking::current_era(), 1); @@ -511,7 +518,10 @@ fn staking_should_work() { }, ); // e.g. It cannot spend more than 500 that it has free from the total 2000. - assert_noop!(Ring::reserve(&3, 501), "account liquidity restrictions prevent withdrawal"); + assert_noop!( + Ring::reserve(&3, 501), + "account liquidity restrictions prevent withdrawal", + ); assert_ok!(Ring::reserve(&3, 409)); }); } @@ -2230,6 +2240,29 @@ fn dont_slash_if_fraction_is_zero() { // custom tests +#[test] +fn bond_zero_should_work() { + ExtBuilder::default().build().execute_with(|| { + let (stash, controller) = (123, 456); + assert_ok!(Staking::bond( + Origin::signed(stash), + controller, + StakingBalances::RingBalance(0), + RewardDestination::Stash, + 0, + )); + + let (stash, controller) = (234, 567); + assert_ok!(Staking::bond( + Origin::signed(stash), + controller, + StakingBalances::KtonBalance(0), + RewardDestination::Stash, + 0, + )); + }); +} + #[test] fn normal_kton_should_work() { ExtBuilder::default().build().execute_with(|| {