Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
6cafc77
refactor: Remove deprecated CreationFee, OnNewAccount, and TransferPa…
ltfschoen Feb 20, 2020
7f306f9
refactor: Remove deprecated vesting from balances::GenesisConfig
ltfschoen Feb 20, 2020
6d02fa7
refactor: Add to system trait AccountData, OnNewAccount, OnReapAccoun…
ltfschoen Feb 20, 2020
bed4570
fix: Remove incorrectly used types
ltfschoen Feb 20, 2020
9dda287
balance AccountStore is System in runtime
ltfschoen Feb 20, 2020
c988b0c
WIP
ltfschoen Feb 20, 2020
ed910f5
use System like in the Substrate repo
ltfschoen Feb 20, 2020
f128e98
fix: In runtime the balance module uses system module. So in test mod…
ltfschoen Feb 20, 2020
ea570be
fix: Add ExistentialDeposit to parameter_types
ltfschoen Feb 21, 2020
f875cfd
test: Fix all tests
ltfschoen Feb 21, 2020
7167ee7
refactor: Fix linting
ltfschoen Feb 21, 2020
49be315
run cargo check using nightly
ltfschoen Feb 21, 2020
fbde050
docs: Add FAQ of why need install rust nightly
ltfschoen Feb 21, 2020
5411b1d
Merge branch 'master' into luke/fix-build-to-latest-substrate-master
ltfschoen Feb 21, 2020
781e005
test: Update CI to run all integration tests and unit tests
ltfschoen Feb 21, 2020
6e37b47
test: Use specific older Rust Nightly version that does not break our…
ltfschoen Feb 21, 2020
0fa9495
docs: Update FAQ with CI Rust Nightly info
ltfschoen Feb 21, 2020
9aa7df4
test: Run CI using specific version of Rust Nightly
ltfschoen Feb 21, 2020
07bc2a1
fix indentation
ltfschoen Feb 21, 2020
1c816a2
fix command
ltfschoen Feb 21, 2020
f08955d
test: more tweaks to try make it work
ltfschoen Feb 21, 2020
e1c8fe9
remote use of getsubstrate
ltfschoen Feb 21, 2020
808fd4f
test: Try harder..
ltfschoen Feb 21, 2020
a34ebfc
test: Try fix clippy
ltfschoen Feb 21, 2020
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
66 changes: 51 additions & 15 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,13 @@ jobs:

- name: Initialize WASM build environment
run: |
rustup update nightly
rustup update stable
rustup target add wasm32-unknown-unknown --toolchain nightly
rustup toolchain install nightly-2020-02-17
rustup default nightly-2020-02-17
rustup target add wasm32-unknown-unknown --toolchain nightly-2020-02-17

- name: Run cargo check
uses: actions-rs/cargo@v1
with:
command: check
run: cargo +nightly-2020-02-17 check

test:
name: Test Suite
Expand All @@ -56,14 +55,44 @@ jobs:

- name: Initialize WASM build environment
run: |
rustup update nightly
rustup update stable
rustup target add wasm32-unknown-unknown --toolchain nightly
rustup toolchain install nightly-2020-02-17
rustup default nightly-2020-02-17
rustup target add wasm32-unknown-unknown --toolchain nightly-2020-02-17

- name: Run cargo test
uses: actions-rs/cargo@v1
with:
command: test
# Runs integration tests in the runtime/tests folder
- name: Run Integration Tests across all runtime modules
run: |
cargo +nightly-2020-02-17 test -p node-runtime

# Runs unit tests in each runtime module of the pallet folder
- name: Run Unit Tests in each runtime module
run: |
cargo +nightly-2020-02-17 test -p roaming-operators &&
cargo +nightly-2020-02-17 test -p roaming-networks &&
cargo +nightly-2020-02-17 test -p roaming-organizations &&
cargo +nightly-2020-02-17 test -p roaming-network-servers &&
cargo +nightly-2020-02-17 test -p roaming-devices &&
cargo +nightly-2020-02-17 test -p roaming-routing-profiles &&
cargo +nightly-2020-02-17 test -p roaming-service-profiles &&
cargo +nightly-2020-02-17 test -p roaming-accounting-policies &&
cargo +nightly-2020-02-17 test -p roaming-agreement-policies &&
cargo +nightly-2020-02-17 test -p roaming-network-profiles &&
cargo +nightly-2020-02-17 test -p roaming-device-profiles &&
cargo +nightly-2020-02-17 test -p roaming-sessions &&
cargo +nightly-2020-02-17 test -p roaming-billing-policies &&
cargo +nightly-2020-02-17 test -p roaming-charging-policies &&
cargo +nightly-2020-02-17 test -p roaming-packet-bundles &&
cargo +nightly-2020-02-17 test -p mining-speed-boosts-configuration-token-mining &&
cargo +nightly-2020-02-17 test -p mining-speed-boosts-configuration-hardware-mining &&
cargo +nightly-2020-02-17 test -p mining-speed-boosts-rates-token-mining &&
cargo +nightly-2020-02-17 test -p mining-speed-boosts-rates-hardware-mining &&
cargo +nightly-2020-02-17 test -p mining-speed-boosts-sampling-token-mining &&
cargo +nightly-2020-02-17 test -p mining-speed-boosts-sampling-hardware-mining &&
cargo +nightly-2020-02-17 test -p mining-speed-boosts-eligibility-token-mining &&
cargo +nightly-2020-02-17 test -p mining-speed-boosts-eligibility-hardware-mining &&
cargo +nightly-2020-02-17 test -p mining-speed-boosts-claims-token-mining &&
cargo +nightly-2020-02-17 test -p mining-speed-boosts-claims-hardware-mining

lints:
name: Lints
Expand All @@ -88,19 +117,26 @@ jobs:
override: true
components: rustfmt, clippy

# nightly-2020-02-17-x86_64-unknown-linux-gnu
- name: Initialize WASM build environment
run: |
rustup update nightly
rustup update stable
rustup target add wasm32-unknown-unknown --toolchain nightly
rustup toolchain install nightly-2020-02-17
rustup default nightly-2020-02-17
rustup target add wasm32-unknown-unknown --toolchain nightly-2020-02-17

- name: Run cargo fmt
run: cargo +nightly fmt --all -- --check
run: |
rustup component add rustfmt --toolchain nightly-2020-02-17-x86_64-unknown-linux-gnu
cargo +nightly-2020-02-17 fmt --all -- --check

- name: Run cargo clippy
# uses: actions-rs/cargo@v1
# with:
# command: clippy
# args: --release -- -D warnings
# FIXME - temporary fix below. See https://github.com/rust-lang/rust-clippy/issues/5094#issuecomment-579116431
run: cargo +nightly clippy-preview -Zunstable-options
run: |
rustup component add clippy --toolchain nightly-2020-02-17-x86_64-unknown-linux-gnu
rustup component add clippy-preview --toolchain nightly-2020-02-17-x86_64-unknown-linux-gnu
cargo +nightly-2020-02-17 clippy-preview -Zunstable-options
36 changes: 35 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ __WARNING__: This implementation is a proof-of-concept prototype and is not read
* [Run multiple node PoA testnet using custom blockchain configuration](#chapter-f21efd)
* [Linting](#chapter-c345d7)
* [Continuous integration](#chapter-27d8c5)
* [FAQ](#chapter-a0dda5)

Note: Generate a new chapter with `openssl rand -hex 3`

Expand Down Expand Up @@ -319,6 +320,13 @@ cargo test -p mining-speed-boosts-claims-hardware-mining
cargo test -p node-runtime
```

#### Specific Integration Tests

Example
```
cargo test -p node-runtime --test cli_integration_tests_mining_tokens
```

### Check

```
Expand Down Expand Up @@ -452,7 +460,7 @@ rustup component add rustfmt --toolchain nightly
Check that you agree with all the formating changes that RustFmt will apply to identify anything that you do not agree with.

```bash
cargo fmt --all -- --check
cargo +nightly fmt --all -- --check
```

### Apply Formating Changes
Expand All @@ -472,3 +480,29 @@ Install an [EditorConfig Plugin](https://editorconfig.org/) for your code editor
## Continuous integration<a id="chapter-27d8c5"></a>

* Reference: https://help.github.com/en/actions/configuring-and-managing-workflows/configuring-a-workflow

## FAQ<a id="chapter-a0dda5"></a>

* Question: Why do we need to install Rust Stable and Rust Nightly?
* Answer: In .github/workflows/rust.yml, we need to run the following,
because Substrate builds two binaries: 1) Wasm binary of your Runtime;
and 2) Native executable containing all your other Substrate components
including your runtimes too. The Wasm build requires rust nightly and
wasm32-unknown-unknown to be installed. Note that we do not use
`rustup update nightly` since the latest Rust Nightly may break our build,
so we must manually change this to the latest Rust Nightly version only
when it is known to work.
```bash
rustup toolchain install nightly-2020-02-17
rustup update stable
rustup target add wasm32-unknown-unknown --toolchain nightly
```

* Question: Why do we install a specific version of Rust Nightly in the CI?
* Answer: Since the latest version of Rust Nightly may break our build,
and because developers may forget to update to the latest version of Rust
Nightly locally. So the solution is to install a specific version of
Rust Nightly in .github/workflows/rust.yml (i.e.
`rustup toolchain install nightly-2020-02-17`), since for example
the latest Rust Nightly version nightly-2020-02-20 may cause our CI tests
to fail (i.e. https://github.com/DataHighway-DHX/node/issues/32)
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,7 @@ mod tests {
pub const AvailableBlockRatio: Perbill = Perbill::from_percent(75);
}
impl system::Trait for Test {
type AccountData = balances::AccountData<u64>;
type AccountId = u64;
type AvailableBlockRatio = AvailableBlockRatio;
type BlockHashCount = BlockHashCount;
Expand All @@ -479,17 +480,20 @@ mod tests {
type MaximumBlockLength = MaximumBlockLength;
type MaximumBlockWeight = MaximumBlockWeight;
type ModuleToIndex = ();
type OnNewAccount = ();
type OnReapAccount = ();
type Origin = Origin;
type Version = ();
}
parameter_types! {
pub const ExistentialDeposit: u64 = 1;
}
impl balances::Trait for Test {
type AccountStore = System;
type Balance = u64;
type CreationFee = ();
type DustRemoval = ();
type Event = ();
type ExistentialDeposit = ();
type OnNewAccount = ();
type TransferPayment = ();
type ExistentialDeposit = ExistentialDeposit;
}
impl transaction_payment::Trait for Test {
type Currency = Balances;
Expand Down Expand Up @@ -552,7 +556,7 @@ mod tests {
type MiningSpeedBoostClaimsHardwareMiningClaimDateRedeemed = u64;
type MiningSpeedBoostClaimsHardwareMiningIndex = u64;
}
// type System = system::Module<Test>;
type System = system::Module<Test>;
type Balances = balances::Module<Test>;
type MiningSpeedBoostClaimsHardwareMiningTestModule = Module<Test>;
type Randomness = randomness_collective_flip::Module<Test>;
Expand All @@ -563,7 +567,6 @@ mod tests {
let mut t = system::GenesisConfig::default().build_storage::<Test>().unwrap();
balances::GenesisConfig::<Test> {
balances: vec![(1, 10), (2, 20), (3, 30), (4, 40), (5, 50), (6, 60)],
vesting: vec![],
}
.assimilate_storage(&mut t)
.unwrap();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -563,6 +563,7 @@ mod tests {
pub const AvailableBlockRatio: Perbill = Perbill::from_percent(75);
}
impl system::Trait for Test {
type AccountData = balances::AccountData<u64>;
type AccountId = u64;
type AvailableBlockRatio = AvailableBlockRatio;
type BlockHashCount = BlockHashCount;
Expand All @@ -578,17 +579,20 @@ mod tests {
type MaximumBlockLength = MaximumBlockLength;
type MaximumBlockWeight = MaximumBlockWeight;
type ModuleToIndex = ();
type OnNewAccount = ();
type OnReapAccount = ();
type Origin = Origin;
type Version = ();
}
parameter_types! {
pub const ExistentialDeposit: u64 = 1;
}
impl balances::Trait for Test {
type AccountStore = System;
type Balance = u64;
type CreationFee = ();
type DustRemoval = ();
type Event = ();
type ExistentialDeposit = ();
type OnNewAccount = ();
type TransferPayment = ();
type ExistentialDeposit = ExistentialDeposit;
}
impl transaction_payment::Trait for Test {
type Currency = Balances;
Expand Down Expand Up @@ -651,7 +655,7 @@ mod tests {
type MiningSpeedBoostClaimsTokenMiningClaimDateRedeemed = u64;
type MiningSpeedBoostClaimsTokenMiningIndex = u64;
}
// type System = system::Module<Test>;
type System = system::Module<Test>;
type Balances = balances::Module<Test>;
type MiningSpeedBoostClaimsTokenMiningTestModule = Module<Test>;
type Randomness = randomness_collective_flip::Module<Test>;
Expand All @@ -662,7 +666,6 @@ mod tests {
let mut t = system::GenesisConfig::default().build_storage::<Test>().unwrap();
balances::GenesisConfig::<Test> {
balances: vec![(1, 10), (2, 20), (3, 30), (4, 40), (5, 50), (6, 60)],
vesting: vec![],
}
.assimilate_storage(&mut t)
.unwrap();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,7 @@ mod tests {
pub const AvailableBlockRatio: Perbill = Perbill::from_percent(75);
}
impl system::Trait for Test {
type AccountData = balances::AccountData<u64>;
type AccountId = u64;
type AvailableBlockRatio = AvailableBlockRatio;
type BlockHashCount = BlockHashCount;
Expand All @@ -443,17 +444,20 @@ mod tests {
type MaximumBlockLength = MaximumBlockLength;
type MaximumBlockWeight = MaximumBlockWeight;
type ModuleToIndex = ();
type OnNewAccount = ();
type OnReapAccount = ();
type Origin = Origin;
type Version = ();
}
parameter_types! {
pub const ExistentialDeposit: u64 = 1;
}
impl balances::Trait for Test {
type AccountStore = System;
type Balance = u64;
type CreationFee = ();
type DustRemoval = ();
type Event = ();
type ExistentialDeposit = ();
type OnNewAccount = ();
type TransferPayment = ();
type ExistentialDeposit = ExistentialDeposit;
}
impl transaction_payment::Trait for Test {
type Currency = Balances;
Expand Down Expand Up @@ -484,7 +488,7 @@ mod tests {
type MiningSpeedBoostConfigurationHardwareMiningHardwareType = Vec<u8>;
type MiningSpeedBoostConfigurationHardwareMiningIndex = u64;
}
// type System = system::Module<Test>;
type System = system::Module<Test>;
type Balances = balances::Module<Test>;
type MiningSpeedBoostConfigurationHardwareMiningTestModule = Module<Test>;
type Randomness = randomness_collective_flip::Module<Test>;
Expand All @@ -495,7 +499,6 @@ mod tests {
let mut t = system::GenesisConfig::default().build_storage::<Test>().unwrap();
balances::GenesisConfig::<Test> {
balances: vec![(1, 10), (2, 20), (3, 30), (4, 40), (5, 50), (6, 60)],
vesting: vec![],
}
.assimilate_storage(&mut t)
.unwrap();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,7 @@ mod tests {
pub const AvailableBlockRatio: Perbill = Perbill::from_percent(75);
}
impl system::Trait for Test {
type AccountData = balances::AccountData<u64>;
type AccountId = u64;
type AvailableBlockRatio = AvailableBlockRatio;
type BlockHashCount = BlockHashCount;
Expand All @@ -506,17 +507,20 @@ mod tests {
type MaximumBlockLength = MaximumBlockLength;
type MaximumBlockWeight = MaximumBlockWeight;
type ModuleToIndex = ();
type OnNewAccount = ();
type OnReapAccount = ();
type Origin = Origin;
type Version = ();
}
parameter_types! {
pub const ExistentialDeposit: u64 = 1;
}
impl balances::Trait for Test {
type AccountStore = System;
type Balance = u64;
type CreationFee = ();
type DustRemoval = ();
type Event = ();
type ExistentialDeposit = ();
type OnNewAccount = ();
type TransferPayment = ();
type ExistentialDeposit = ExistentialDeposit;
}
impl transaction_payment::Trait for Test {
type Currency = Balances;
Expand Down Expand Up @@ -545,7 +549,7 @@ mod tests {
// FIXME - how to use this enum from std? (including importing `use std::str::FromStr;`)
type MiningSpeedBoostConfigurationTokenMiningTokenType = Vec<u8>;
}
// type System = system::Module<Test>;
type System = system::Module<Test>;
type Balances = balances::Module<Test>;
type MiningSpeedBoostConfigurationTokenMiningTestModule = Module<Test>;
type Randomness = randomness_collective_flip::Module<Test>;
Expand All @@ -556,7 +560,6 @@ mod tests {
let mut t = system::GenesisConfig::default().build_storage::<Test>().unwrap();
balances::GenesisConfig::<Test> {
balances: vec![(1, 10), (2, 20), (3, 30), (4, 40), (5, 50), (6, 60)],
vesting: vec![],
}
.assimilate_storage(&mut t)
.unwrap();
Expand Down
Loading