Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Develop #206

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
10 changes: 6 additions & 4 deletions rustfmt.toml → .rustfmt.toml
Original file line number Diff line number Diff line change
@@ -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"
35 changes: 15 additions & 20 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
# Check how much free disk space left after the build
- df -h
5 changes: 3 additions & 2 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
11 changes: 4 additions & 7 deletions ci/script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,29 @@
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

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
2 changes: 1 addition & 1 deletion core/merkle-patricia-trie/src/proof.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion node/cli/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion node/cli/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
3 changes: 2 additions & 1 deletion node/runtime/src/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,8 @@ impl<T: Get<Perbill>> Convert<Fixed64, Fixed64> for TargetedFeeAdjustment<T> {
} 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
Expand Down
41 changes: 37 additions & 4 deletions srml/staking/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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);
Expand Down Expand Up @@ -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));
});
}
Expand Down Expand Up @@ -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(|| {
Expand Down