Skip to content

Commit

Permalink
change VotingFor to VotingForV2 and ReferendumTimeout to ReferendumTi…
Browse files Browse the repository at this point in the history
…meoutV2
  • Loading branch information
SunTiebing committed Dec 11, 2024
1 parent 0aa13de commit fe256a5
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 21 deletions.
8 changes: 4 additions & 4 deletions pallets/vtoken-voting/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ mod benchmarks {
response.clone(),
)?;
}
let votes = match VotingFor::<T>::get(vtoken, &caller) {
let votes = match VotingForV2::<T>::get(vtoken, &caller) {
Voting::Casting(Casting { votes, .. }) => votes,
_ => return Err("Votes are not direct".into()),
};
Expand All @@ -97,7 +97,7 @@ mod benchmarks {
Pallet::<T>::vote(RawOrigin::Signed(caller.clone()), vtoken, poll_index, vote);

assert_matches!(
VotingFor::<T>::get(vtoken, &caller),
VotingForV2::<T>::get(vtoken, &caller),
Voting::Casting(Casting { votes, .. }) if votes.len() == (r + 1) as usize
);

Expand All @@ -124,7 +124,7 @@ mod benchmarks {
response.clone(),
)?;
}
let votes = match VotingFor::<T>::get(vtoken, &caller) {
let votes = match VotingForV2::<T>::get(vtoken, &caller) {
Voting::Casting(Casting { votes, .. }) => votes,
_ => return Err("Votes are not direct".into()),
};
Expand All @@ -136,7 +136,7 @@ mod benchmarks {
Pallet::<T>::vote(RawOrigin::Signed(caller.clone()), vtoken, poll_index, new_vote);

assert_matches!(
VotingFor::<T>::get(vtoken, &caller),
VotingForV2::<T>::get(vtoken, &caller),
Voting::Casting(Casting { votes, .. }) if votes.len() == r as usize
);

Expand Down
12 changes: 6 additions & 6 deletions pallets/vtoken-voting/src/tests/kusama_common_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ fn ensure_balance_after_unlock() {
assert_ok!(VtokenVoting::unlock(RuntimeOrigin::signed(ALICE), vtoken, poll_index));
assert_eq!(usable_balance(vtoken, &ALICE), 0);
assert_eq!(Tokens::accounts(&ALICE, vtoken).frozen, 10);
assert_eq!(VotingFor::<Runtime>::get(vtoken, &ALICE).locked_balance(), 10);
assert_eq!(VotingForV2::<Runtime>::get(vtoken, &ALICE).locked_balance(), 10);
});
}
}
Expand Down Expand Up @@ -299,7 +299,7 @@ fn ensure_comprehensive_balance_after_unlock() {
assert_ok!(VtokenVoting::unlock(RuntimeOrigin::signed(ALICE), vtoken, poll_index));
assert_eq!(usable_balance(vtoken, &ALICE), 8);
assert_eq!(Tokens::accounts(&ALICE, vtoken).frozen, 2);
assert_eq!(VotingFor::<Runtime>::get(vtoken, &ALICE).locked_balance(), 2);
assert_eq!(VotingForV2::<Runtime>::get(vtoken, &ALICE).locked_balance(), 2);

assert_ok!(VtokenVoting::vote(
RuntimeOrigin::signed(ALICE),
Expand All @@ -311,7 +311,7 @@ fn ensure_comprehensive_balance_after_unlock() {

assert_eq!(usable_balance(vtoken, &ALICE), 0);
assert_eq!(Tokens::accounts(&ALICE, vtoken).frozen, 10);
assert_eq!(VotingFor::<Runtime>::get(vtoken, &ALICE).locked_balance(), 10);
assert_eq!(VotingForV2::<Runtime>::get(vtoken, &ALICE).locked_balance(), 10);
});
}
}
Expand Down Expand Up @@ -431,12 +431,12 @@ fn lock_amalgamation_valid_with_multiple_removed_votes() {
VtokenVoting::unlock(RuntimeOrigin::signed(ALICE), vtoken, 0),
Error::<Runtime>::NoPermissionYet
);
assert_eq!(VotingFor::<Runtime>::get(vtoken, &ALICE).locked_balance(), 10);
assert_eq!(VotingForV2::<Runtime>::get(vtoken, &ALICE).locked_balance(), 10);
assert_eq!(usable_balance(vtoken, &ALICE), 0);

RelaychainDataProvider::set_block_number(11);
assert_ok!(VtokenVoting::unlock(RuntimeOrigin::signed(ALICE), vtoken, 0));
assert_eq!(VotingFor::<Runtime>::get(vtoken, &ALICE).locked_balance(), 10);
assert_eq!(VotingForV2::<Runtime>::get(vtoken, &ALICE).locked_balance(), 10);
assert_eq!(usable_balance(vtoken, &ALICE), 0);
assert_eq!(
ClassLocksFor::<Runtime>::get(&ALICE),
Expand Down Expand Up @@ -1188,7 +1188,7 @@ fn on_idle_works() {
let mut actual_count = 0;
for poll_index in 0..50 {
let relay_block_number = poll_index as BlockNumber;
if ReferendumTimeout::<Runtime>::get(
if ReferendumTimeoutV2::<Runtime>::get(
vtoken,
relay_block_number + UndecidingTimeout::<Runtime>::get(vtoken).unwrap(),
)
Expand Down
12 changes: 6 additions & 6 deletions pallets/vtoken-voting/src/tests/polkadot_common_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ fn ensure_balance_after_unlock() {
assert_ok!(VtokenVoting::unlock(RuntimeOrigin::signed(ALICE), vtoken, poll_index));
assert_eq!(usable_balance(vtoken, &ALICE), 0);
assert_eq!(Tokens::accounts(&ALICE, vtoken).frozen, 10);
assert_eq!(VotingFor::<Runtime>::get(vtoken, &ALICE).locked_balance(), 10);
assert_eq!(VotingForV2::<Runtime>::get(vtoken, &ALICE).locked_balance(), 10);
});
}
}
Expand Down Expand Up @@ -299,7 +299,7 @@ fn ensure_comprehensive_balance_after_unlock() {
assert_ok!(VtokenVoting::unlock(RuntimeOrigin::signed(ALICE), vtoken, poll_index));
assert_eq!(usable_balance(vtoken, &ALICE), 8);
assert_eq!(Tokens::accounts(&ALICE, vtoken).frozen, 2);
assert_eq!(VotingFor::<Runtime>::get(vtoken, &ALICE).locked_balance(), 2);
assert_eq!(VotingForV2::<Runtime>::get(vtoken, &ALICE).locked_balance(), 2);

assert_ok!(VtokenVoting::vote(
RuntimeOrigin::signed(ALICE),
Expand All @@ -311,7 +311,7 @@ fn ensure_comprehensive_balance_after_unlock() {

assert_eq!(usable_balance(vtoken, &ALICE), 0);
assert_eq!(Tokens::accounts(&ALICE, vtoken).frozen, 10);
assert_eq!(VotingFor::<Runtime>::get(vtoken, &ALICE).locked_balance(), 10);
assert_eq!(VotingForV2::<Runtime>::get(vtoken, &ALICE).locked_balance(), 10);
});
}
}
Expand Down Expand Up @@ -431,12 +431,12 @@ fn lock_amalgamation_valid_with_multiple_removed_votes() {
VtokenVoting::unlock(RuntimeOrigin::signed(ALICE), vtoken, 0),
Error::<Runtime>::NoPermissionYet
);
assert_eq!(VotingFor::<Runtime>::get(vtoken, &ALICE).locked_balance(), 10);
assert_eq!(VotingForV2::<Runtime>::get(vtoken, &ALICE).locked_balance(), 10);
assert_eq!(usable_balance(vtoken, &ALICE), 0);

RelaychainDataProvider::set_block_number(11);
assert_ok!(VtokenVoting::unlock(RuntimeOrigin::signed(ALICE), vtoken, 0));
assert_eq!(VotingFor::<Runtime>::get(vtoken, &ALICE).locked_balance(), 10);
assert_eq!(VotingForV2::<Runtime>::get(vtoken, &ALICE).locked_balance(), 10);
assert_eq!(usable_balance(vtoken, &ALICE), 0);
assert_eq!(
ClassLocksFor::<Runtime>::get(&ALICE),
Expand Down Expand Up @@ -1188,7 +1188,7 @@ fn on_idle_works() {
let mut actual_count = 0;
for poll_index in 0..50 {
let relay_block_number = poll_index as BlockNumber;
if ReferendumTimeout::<Runtime>::get(
if ReferendumTimeoutV2::<Runtime>::get(
vtoken,
relay_block_number + UndecidingTimeout::<Runtime>::get(vtoken).unwrap(),
)
Expand Down
10 changes: 5 additions & 5 deletions pallets/vtoken-voting/src/tests/vbnc_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ fn ensure_balance_after_unlock() {
assert_ok!(VtokenVoting::unlock(RuntimeOrigin::signed(ALICE), vtoken, poll_index));
assert_eq!(usable_balance(vtoken, &ALICE), 0);
assert_eq!(Tokens::accounts(&ALICE, vtoken).frozen, 10);
assert_eq!(VotingFor::<Runtime>::get(vtoken, &ALICE).locked_balance(), 10);
assert_eq!(VotingForV2::<Runtime>::get(vtoken, &ALICE).locked_balance(), 10);
});
}
}
Expand Down Expand Up @@ -273,7 +273,7 @@ fn ensure_comprehensive_balance_after_unlock() {
assert_ok!(VtokenVoting::unlock(RuntimeOrigin::signed(ALICE), vtoken, poll_index));
assert_eq!(usable_balance(vtoken, &ALICE), 8);
assert_eq!(Tokens::accounts(&ALICE, vtoken).frozen, 2);
assert_eq!(VotingFor::<Runtime>::get(vtoken, &ALICE).locked_balance(), 2);
assert_eq!(VotingForV2::<Runtime>::get(vtoken, &ALICE).locked_balance(), 2);

assert_ok!(VtokenVoting::vote(
RuntimeOrigin::signed(ALICE),
Expand All @@ -284,7 +284,7 @@ fn ensure_comprehensive_balance_after_unlock() {

assert_eq!(usable_balance(vtoken, &ALICE), 0);
assert_eq!(Tokens::accounts(&ALICE, vtoken).frozen, 10);
assert_eq!(VotingFor::<Runtime>::get(vtoken, &ALICE).locked_balance(), 10);
assert_eq!(VotingForV2::<Runtime>::get(vtoken, &ALICE).locked_balance(), 10);
});
}
}
Expand Down Expand Up @@ -397,12 +397,12 @@ fn lock_amalgamation_valid_with_multiple_removed_votes() {
VtokenVoting::unlock(RuntimeOrigin::signed(ALICE), vtoken, 0),
Error::<Runtime>::NoPermissionYet
);
assert_eq!(VotingFor::<Runtime>::get(vtoken, &ALICE).locked_balance(), 10);
assert_eq!(VotingForV2::<Runtime>::get(vtoken, &ALICE).locked_balance(), 10);
assert_eq!(usable_balance(vtoken, &ALICE), 0);

System::set_block_number(11);
assert_ok!(VtokenVoting::unlock(RuntimeOrigin::signed(ALICE), vtoken, 0));
assert_eq!(VotingFor::<Runtime>::get(vtoken, &ALICE).locked_balance(), 10);
assert_eq!(VotingForV2::<Runtime>::get(vtoken, &ALICE).locked_balance(), 10);
assert_eq!(usable_balance(vtoken, &ALICE), 0);
assert_eq!(
ClassLocksFor::<Runtime>::get(&ALICE),
Expand Down

0 comments on commit fe256a5

Please sign in to comment.