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

update: sync tests and runtime primitives #102

Merged
merged 50 commits into from
Nov 27, 2019
Merged
Changes from 1 commit
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
8c800d1
update: sync tests and runtime primitives
aurexav Nov 22, 2019
a6a3ef1
fix: `clear_mature_deposits` logic
aurexav Nov 22, 2019
ec53209
hanging: bakcup
aurexav Nov 22, 2019
4c847fd
Merge remote-tracking branch 'upstream/develop' into update-test
aurexav Nov 22, 2019
77852bb
hanging: backup
aurexav Nov 22, 2019
fe248b7
hanging: backup
aurexav Nov 22, 2019
c4de14b
Merge remote-tracking branch 'upstream/develop' into update-test
aurexav Nov 22, 2019
ecafdd0
fix: `normal_unbond_should_work`
aurexav Nov 22, 2019
a30ff73
hanging: backup
aurexav Nov 22, 2019
a652a20
Merge remote-tracking branch 'upstream/develop' into update-test
aurexav Nov 22, 2019
9f80a33
update: currency primitives
aurexav Nov 23, 2019
af5d88d
remove: useless import
aurexav Nov 23, 2019
e7064cc
remove: useless lifetime bound
aurexav Nov 23, 2019
2f6ff75
hanging: backup
aurexav Nov 23, 2019
7202e66
fix: `punished_claim_should_work`
aurexav Nov 23, 2019
928a1aa
remove: clone on copy, useless field
aurexav Nov 23, 2019
3f67e3a
hanging: bakcup
aurexav Nov 23, 2019
1b780cf
fix: `transform_to_deposited_ring_should_work`
aurexav Nov 23, 2019
1c7ea90
hanging: backup
aurexav Nov 23, 2019
e9bd448
fix: `expired_ring_should_capable_to_promise_again`
aurexav Nov 23, 2019
48ba6c2
fix: `inflation_should_be_correct`
aurexav Nov 23, 2019
93cff5d
add: TODO
aurexav Nov 23, 2019
ab0cb5a
add: comment for `reward_validator`
aurexav Nov 25, 2019
2bb337f
fix: `set_controller_should_not_change_ledger`
aurexav Nov 25, 2019
77219c0
fix: remove dangling comma
aurexav Nov 25, 2019
5d728eb
rename: `set_controller_should_remove_old_ledger` to `set_controller_…
aurexav Nov 25, 2019
f82d4b0
fix: `check_stash_already_bonded_and_controller_already_paired`
aurexav Nov 25, 2019
333db3a
fix: `bond_over_max_promise_month_should_fail`
aurexav Nov 25, 2019
a93aba2
add: comment for `slash_validator`
aurexav Nov 25, 2019
ac33c71
fix: typo
aurexav Nov 25, 2019
a8a9b98
update: `set_controller_should_work`
aurexav Nov 25, 2019
08f95cc
fix: `pool_should_be_increased_and_decreased_correctly`
aurexav Nov 25, 2019
eaab535
fix: typo
aurexav Nov 25, 2019
d76be29
hanging: backup
aurexav Nov 25, 2019
0c0aca9
Merge remote-tracking branch 'upstream/develop' into update-test
aurexav Nov 25, 2019
8619dfc
fix: `unbond_over_max_unbondings_chunks_should_fail`
aurexav Nov 25, 2019
920b338
fix: bug with `ensure!` parser
aurexav Nov 25, 2019
9dcdcef
add: `unbond_zero`
aurexav Nov 26, 2019
bb332ba
fix: `promise_extra_should_not_remove_unexpired_items`
aurexav Nov 26, 2019
b0cdc1e
update: avoid unnecessary `insert` operation
aurexav Nov 26, 2019
46be1dd
remove: `total_deposit_should_be_increased_and_decreased_correctly`
aurexav Nov 26, 2019
d4b6eb2
remove: `unlock_value_should_be_increased_and_decreased_correctly`
aurexav Nov 26, 2019
7ad23af
fix: `yakio_q1`
aurexav Nov 26, 2019
129416a
update: `ValidatorPrefs`
aurexav Nov 26, 2019
b77c505
fix: `yakio_q2`
aurexav Nov 26, 2019
8fefeb9
fix: `pool_should_be_increased_and_decreased_correctly`
aurexav Nov 26, 2019
840be95
fix: `slash_should_not_touch_unbondings`
aurexav Nov 26, 2019
9fb732f
udpate: format
aurexav Nov 26, 2019
5dc44fd
add: `FIXME: slash strategy`
aurexav Nov 26, 2019
45729fd
Merge remote-tracking branch 'upstream/develop' into update-test
aurexav Nov 26, 2019
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
Prev Previous commit
Next Next commit
hanging: backup
  • Loading branch information
aurexav committed Nov 22, 2019
commit 77852bb52be9de4b904b867254bf6bfe5baf950f
116 changes: 66 additions & 50 deletions srml/staking/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,72 +212,88 @@ fn normal_kton_should_work() {
}

#[test]
fn time_deposit_ring_can_not_be_unbond() {
fn time_deposit_ring_unbond_and_withdraw_automactically_should_work() {
ExtBuilder::default().existential_deposit(0).build().execute_with(|| {
let locks = vec![BalanceLock {
id: STAKING_ID,
withdraw_lock: WithdrawLock::WithStaking(StakingLock {
staking_amount: 100 * MILLICENTS,
unbondings: vec![],
}),
reasons: WithdrawReasons::all(),
}];
let ledger = StakingLedger {
stash: 11,
active_ring: 100 * MILLICENTS,
active_deposit_ring: 100 * MILLICENTS,
active_kton: 0,
deposit_items: vec![TimeDepositItem {
value: 100 * MILLICENTS,
start_time: 0,
expire_time: 12 * MONTH_IN_SECONDS as u64,
}],
ring_staking_lock: StakingLock {
staking_amount: 100 * MILLICENTS,
unbondings: vec![],
},
kton_staking_lock: StakingLock {
staking_amount: 0,
unbondings: vec![],
},
};
{
let locks = vec![BalanceLock {
id: STAKING_ID,
withdraw_lock: WithdrawLock::WithStaking(StakingLock {
staking_amount: 100 * MILLICENTS,
unbondings: vec![],
}),
reasons: WithdrawReasons::all(),
}];
let ledger = StakingLedger {
stash: 11,
active_ring: 100 * MILLICENTS,
active_deposit_ring: 100 * MILLICENTS,
active_kton: 0,
deposit_items: vec![TimeDepositItem {
value: 100 * MILLICENTS,
start_time: 0,
expire_time: 12 * MONTH_IN_SECONDS as u64,
}],
ring_staking_lock: StakingLock {
staking_amount: 100 * MILLICENTS,
unbondings: vec![],
},
kton_staking_lock: StakingLock {
staking_amount: 0,
unbondings: vec![],
},
};

Timestamp::set_timestamp(13 * MONTH_IN_SECONDS as u64);
assert_ok!(Staking::unbond(
Origin::signed(10),
StakingBalance::Ring(10 * MILLICENTS)
));
assert_eq!(Ring::locks(11), locks);
assert_eq!(Staking::ledger(&10).unwrap(), ledger,);

assert_ok!(Staking::unbond(
Origin::signed(10),
StakingBalance::Ring(10 * MILLICENTS)
));
assert_eq!(Ring::locks(11), locks);
assert_eq!(Staking::ledger(&10).unwrap(), ledger,);
assert_ok!(Staking::unbond(
Origin::signed(10),
StakingBalance::Ring(120 * MILLICENTS)
));
assert_eq!(Ring::locks(11), locks);
assert_eq!(Staking::ledger(&10).unwrap(), ledger);
}

assert_ok!(Staking::unbond(
Origin::signed(10),
StakingBalance::Ring(20 * MILLICENTS)
));
assert_eq!(Ring::locks(11), locks);
assert_eq!(Staking::ledger(&10).unwrap(), ledger);
let mut ts = 13 * MONTH_IN_SECONDS as u64;
Timestamp::set_timestamp(ts);

assert_ok!(Staking::unbond(
Origin::signed(10),
StakingBalance::Ring(120 * MILLICENTS)
StakingBalance::Ring(10 * MILLICENTS)
));
assert_eq!(Ring::locks(11), locks);
assert_eq!(Staking::ledger(&10).unwrap(), ledger);

assert_ok!(Staking::claim_mature_deposits(Origin::signed(10)));
// assert_eq!(Ring::locks(11), locks);
ts += BondingDuration::get();
assert_eq!(
Ring::locks(11),
vec![BalanceLock {
id: STAKING_ID,
withdraw_lock: WithdrawLock::WithStaking(StakingLock {
staking_amount: 90 * MILLICENTS,
unbondings: vec![NormalLock {
amount: 10 * MILLICENTS,
until: ts,
}],
}),
reasons: WithdrawReasons::all()
}]
);
assert_eq!(
Staking::ledger(&10).unwrap(),
StakingLedger {
stash: 11,
active_ring: 100 * MILLICENTS,
active_ring: 90 * MILLICENTS,
active_deposit_ring: 0,
active_kton: 0,
deposit_items: vec![],
ring_staking_lock: StakingLock {
staking_amount: 100 * MILLICENTS,
unbondings: vec![],
staking_amount: 90 * MILLICENTS,
unbondings: vec![NormalLock {
amount: 10 * MILLICENTS,
until: ts,
}],
},
kton_staking_lock: StakingLock {
staking_amount: 0,
Expand Down