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

BLOCKCHAIN-463 - Judiciary Phase 1 #388

Merged
merged 3 commits into from
Aug 9, 2024
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Restrict Court to LLM Staked -> Staked transfers only
  • Loading branch information
kacperzuk-neti committed Jul 23, 2024
commit 93c0ea20a1ac3f144229709930e2fb3c4b4ce16e
2 changes: 1 addition & 1 deletion substrate/frame/llm/src/benchmarking.rs
Original file line number Diff line number Diff line change
@@ -120,7 +120,7 @@ benchmarks! {
let origin = RawOrigin::Signed(user.clone());
LLM::<T>::politics_lock(origin.clone().into(), amount.clone()).unwrap();
assert_eq!(LLMPolitics::<T>::get(&user), amount.clone());
}: _(origin, LLMAccount::Locked(user.clone()), LLMAccount::Liquid(user2.clone()), amount.clone())
}: _(origin, LLMAccount::Locked(user.clone()), LLMAccount::Locked(user2.clone()), amount.clone())
verify {
assert_eq!(LLMPolitics::<T>::get(&user), 0u8.into());
}
2 changes: 1 addition & 1 deletion substrate/frame/llm/src/lib.rs
Original file line number Diff line number Diff line change
@@ -421,7 +421,7 @@ pub mod pallet {
},
};
let transfer_to = match to {
LLMAccount::Liquid(account) => account,
LLMAccount::Liquid(_) => return Err(Error::<T>::InvalidAccount.into()),
LLMAccount::Locked(account) => {
LLMPolitics::<T>::mutate(account.clone(), |b| *b += amount);
Self::deposit_event(Event::<T>::LLMPoliticsLocked(account, amount));
23 changes: 5 additions & 18 deletions substrate/frame/llm/src/tests.rs
Original file line number Diff line number Diff line change
@@ -704,29 +704,16 @@ fn cant_force_transfer_from_liquid() {
}

#[test]
fn force_updates_balances_correctly_to_liquid() {
fn cant_force_transfer_to_liquid() {
new_test_ext().execute_with(|| {
assert_ok!(LLM::politics_lock(RuntimeOrigin::signed(1), 3));

let court = RuntimeOrigin::signed(1);
let id = LLM::llm_id();
let politipool = LLM::get_llm_politipool_account();
let from = LLMAccount::Locked(1);
let to = LLMAccount::Liquid(2);
let amount = 2;

assert_ok!(LLM::politics_lock(RuntimeOrigin::signed(1), 3));
assert_ok!(LLM::politics_lock(RuntimeOrigin::signed(2), 2));
let politipool_before = Assets::balance(id, politipool);
let from_before = Assets::balance(id, 1);
let to_before = Assets::balance(id, 2);

assert_ok!(LLM::force_transfer(court, from, to, amount));

assert_eq!(Assets::balance(id, politipool), politipool_before - amount);
assert_eq!(Assets::balance(id, 1), from_before);
assert_eq!(Assets::balance(id, 2), to_before + amount);
let amount = 1;

assert_eq!(LLMPolitics::<Test>::get(1), 3 - amount);
assert_eq!(LLMPolitics::<Test>::get(2), 2);
assert_noop!(LLM::force_transfer(court, from, to, amount), Error::<Test>::InvalidAccount);
});
}

Loading