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

initialize kton tests #33

Merged
merged 3 commits into from
Jul 8, 2019
Merged
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
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion node/executor/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ runtime_primitives = { package = "sr-primitives", git = 'https://github.com/pari
runtime_support = { package = "srml-support", git = 'https://github.com/paritytech/substrate.git' }
balances = { package = "srml-balances",git = 'https://github.com/paritytech/substrate.git' }
session = { package = "srml-session", git = 'https://github.com/paritytech/substrate.git' }
staking = { package = "srml-staking", git = 'https://github.com/paritytech/substrate.git' }
staking = { package = "evo-staking", path = '../../srml/staking' }
system = { package = "srml-system", git = 'https://github.com/paritytech/substrate.git' }
timestamp = { package = "srml-timestamp", git = 'https://github.com/paritytech/substrate.git' }
treasury = { package = "srml-treasury", git = 'https://github.com/paritytech/substrate.git' }
Expand Down
50 changes: 16 additions & 34 deletions node/executor/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

pub use substrate_executor::NativeExecutor;
use substrate_executor::native_executor_instance;
pub use node_runtime::{SessionsPerEra, BondingDuration, ErasPerEpoch, CAP};

// Declare an instance of the native executor named `Executor`. Include the wasm binary as the
// equivalent wasm code.
Expand Down Expand Up @@ -54,7 +55,7 @@ mod tests {
use system::{EventRecord, Phase};
use node_runtime::{Header, Block, UncheckedExtrinsic, CheckedExtrinsic, Call, Runtime, Balances,
BuildStorage, GenesisConfig, BalancesConfig, SessionConfig, StakingConfig, System,
SystemConfig, GrandpaConfig, IndicesConfig, Event, SessionKeys};
SystemConfig, GrandpaConfig, IndicesConfig, KtonConfig, Event, SessionKeys};
use wabt;
use primitives::map;

Expand Down Expand Up @@ -361,6 +362,18 @@ mod tests {
creation_fee: 0,
vesting: vec![],
}),
kton: Some(KtonConfig {
balances: vec![
(alice(), 111),
(bob(), 100),
(charlie(), 100_000_000),
(dave(), 111),
(eve(), 101),
(ferdie(), 100),
],
vesting: vec![],
sys_acc: ferdie(),
}),
session: Some(SessionConfig {
validators: vec![AccountKeyring::One.into(), AccountKeyring::Two.into(), three],
keys: vec![
Expand All @@ -371,6 +384,8 @@ mod tests {
}),
staking: Some(StakingConfig {
current_era: 0,
current_era_total_reward: 1,
epoch_index: 0,
stakers: vec![
(dave(), alice(), 111, staking::StakerStatus::Validator),
(eve(), bob(), 100, staking::StakerStatus::Validator),
Expand All @@ -384,10 +399,7 @@ mod tests {
offline_slash_grace: 0,
invulnerables: vec![alice(), bob(), charlie()],
}),
democracy: Some(Default::default()),
council_seats: Some(Default::default()),
timestamp: Some(Default::default()),
treasury: Some(Default::default()),
contracts: Some(Default::default()),
sudo: Some(Default::default()),
grandpa: Some(GrandpaConfig {
Expand Down Expand Up @@ -582,21 +594,6 @@ mod tests {
event: Event::system(system::Event::ExtrinsicSuccess),
topics: vec![],
},
EventRecord {
phase: Phase::Finalization,
event: Event::treasury(treasury::RawEvent::Spending(0)),
topics: vec![],
},
EventRecord {
phase: Phase::Finalization,
event: Event::treasury(treasury::RawEvent::Burnt(0)),
topics: vec![],
},
EventRecord {
phase: Phase::Finalization,
event: Event::treasury(treasury::RawEvent::Rollover(0)),
topics: vec![],
},
]);
});

Expand Down Expand Up @@ -654,21 +651,6 @@ mod tests {
event: Event::system(system::Event::ExtrinsicSuccess),
topics: vec![],
},
EventRecord {
phase: Phase::Finalization,
event: Event::treasury(treasury::RawEvent::Spending(0)),
topics: vec![],
},
EventRecord {
phase: Phase::Finalization,
event: Event::treasury(treasury::RawEvent::Burnt(0)),
topics: vec![],
},
EventRecord {
phase: Phase::Finalization,
event: Event::treasury(treasury::RawEvent::Rollover(0)),
topics: vec![],
},
]);
});
}
Expand Down
2 changes: 1 addition & 1 deletion srml/token/kton/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ decl_event!(


decl_storage! {
trait Store for Module<T: Trait> as KtonBalances {
Copy link
Contributor

@hackfisher hackfisher Jul 5, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are there storage compatible issues here? If true, does substrate have methods(e.g. migration design). To verify this question, maybe need do some testing

trait Store for Module<T: Trait> as Kton {

pub DepositLedger get(deposit_ledger): map T::AccountId => Option<Deposit<CurrencyOf<T>, T::Moment>>;

Expand Down
7 changes: 7 additions & 0 deletions srml/token/ring/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ impl system::Trait for Runtime {
type Header = Header;
type Event = ();
}

impl timestamp::Trait for Runtime {
type Moment = u64;
type OnTimestampSet = ();
}

impl Trait for Runtime {
type Balance = u64;
type OnFreeBalanceZero = ();
Expand Down Expand Up @@ -129,4 +135,5 @@ impl ExtBuilder {
}

pub type System = system::Module<Runtime>;
pub type Timestamp = timestamp::Module<Runtime>;
pub type Balances = Module<Runtime>;
2 changes: 1 addition & 1 deletion srml/try/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ decl_module! {
list.push(value);
<List<T>>::insert(1, list);
} else {
list.remove(value);
list.remove(value as usize);
}

}
Expand Down
4 changes: 2 additions & 2 deletions srml/try/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,9 @@ fn check_default_value() {
#[test]
fn check_delete() {
with_externalities(&mut new_test_ext(), || {
Try::update_list(1);
Try::update_list(1, true);
assert_eq!(Try::list(1), vec![1]);
Try::update_list(2);
Try::update_list(2, true);
assert_eq!(Try::list(1), vec![1, 2]);
});
}