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

dapp staking v3 - part 2 #991

Merged
merged 13 commits into from
Sep 21, 2023
Prev Previous commit
Next Next commit
Check era when adding chunk
Dinonard committed Sep 11, 2023

Verified

This commit was signed with the committer’s verified signature.
addaleax Anna Henningsen
commit 88cf0398a7d7918b4638ed4ed5b8e83add08018c
3 changes: 3 additions & 0 deletions pallets/dapp-staking-v3/src/test/tests_types.rs
Original file line number Diff line number Diff line change
@@ -98,6 +98,9 @@ fn account_ledger_add_lock_amount_works() {
assert_eq!(acc_ledger.lock_era(), first_era);
assert_eq!(acc_ledger.locked.0.len(), 1);

// Adding to previous era should fail
assert!(acc_ledger.add_lock_amount(addition, first_era - 1).is_err());

// Add up to storage limit
for i in 2..=LockedDummy::get() {
assert!(acc_ledger.add_lock_amount(addition, first_era + i).is_ok());
3 changes: 1 addition & 2 deletions pallets/dapp-staking-v3/src/types.rs
Original file line number Diff line number Diff line change
@@ -95,9 +95,8 @@ where
return Ok(());
}

// TODO: there should be a check to ensure that the era is greater or equal than the last one in vector.

let mut chunk = if let Some(&chunk) = self.0.last() {
ensure!(chunk.get_era() <= era, ());
chunk
} else {
P::default()