mirror of
https://git.ghostchain.io/proxmio/ghost-node.git
synced 2025-12-27 03:09:56 +00:00
rustfmt the ghost-claims pallet
Signed-off-by: Uncle Stinky <uncle.stinky@ghostchain.io>
This commit is contained in:
@@ -1,21 +1,19 @@
|
||||
#![cfg(test)]
|
||||
|
||||
use mock::{
|
||||
new_test_ext, ghost_claims,
|
||||
Test, System, Balances, Club, Vesting, Claims, RuntimeOrigin, RuntimeEvent,
|
||||
eth_keys::{
|
||||
alice_account_id, total_claims, first_eth_public_known,
|
||||
first_eth_public_key, first_account_id, first_signature,
|
||||
second_eth_public_known, second_eth_public_key, second_account_id,
|
||||
second_signature, third_eth_public_known, third_eth_public_key,
|
||||
third_account_id, third_signature, fourth_eth_public_known,
|
||||
fourth_eth_public_key, fourth_account_id, fourth_signature,
|
||||
wrong_signature, bob_account_id,
|
||||
}
|
||||
};
|
||||
use hex_literal::hex;
|
||||
use frame_support::{assert_err, assert_ok};
|
||||
use super::*;
|
||||
use frame_support::{assert_err, assert_ok};
|
||||
use hex_literal::hex;
|
||||
use mock::{
|
||||
eth_keys::{
|
||||
alice_account_id, bob_account_id, first_account_id, first_eth_public_key,
|
||||
first_eth_public_known, first_signature, fourth_account_id, fourth_eth_public_key,
|
||||
fourth_eth_public_known, fourth_signature, second_account_id, second_eth_public_key,
|
||||
second_eth_public_known, second_signature, third_account_id, third_eth_public_key,
|
||||
third_eth_public_known, third_signature, total_claims, wrong_signature,
|
||||
},
|
||||
ghost_claims, new_test_ext, Balances, Claims, Club, RuntimeEvent, RuntimeOrigin, System, Test,
|
||||
Vesting,
|
||||
};
|
||||
|
||||
#[test]
|
||||
fn serde_works() {
|
||||
@@ -41,12 +39,12 @@ fn basic_setup_works() {
|
||||
assert_eq!(Balances::usable_balance(&first_account_id()), 10);
|
||||
assert_eq!(Balances::usable_balance(&second_account_id()), 100);
|
||||
assert_eq!(Balances::usable_balance(&third_account_id()), 1000);
|
||||
|
||||
|
||||
assert_eq!(Club::rank_of(&alice_account_id()), None);
|
||||
assert_eq!(Club::rank_of(&first_account_id()), None);
|
||||
assert_eq!(Club::rank_of(&second_account_id()), Some(1));
|
||||
assert_eq!(Club::rank_of(&third_account_id()), Some(3));
|
||||
|
||||
|
||||
assert_eq!(Vesting::vesting_balance(&alice_account_id()), None);
|
||||
assert_eq!(ghost_claims::Total::<Test, ()>::get(), total_claims());
|
||||
});
|
||||
@@ -56,9 +54,10 @@ fn basic_setup_works() {
|
||||
fn small_claiming_works() {
|
||||
new_test_ext().execute_with(|| {
|
||||
assert_ok!(Claims::claim(
|
||||
RuntimeOrigin::signed(alice_account_id()),
|
||||
first_eth_public_key(),
|
||||
first_signature()));
|
||||
RuntimeOrigin::signed(alice_account_id()),
|
||||
first_eth_public_key(),
|
||||
first_signature()
|
||||
));
|
||||
|
||||
assert_eq!(Balances::usable_balance(&alice_account_id()), 10);
|
||||
assert_eq!(Balances::usable_balance(&first_account_id()), 0);
|
||||
@@ -77,9 +76,9 @@ fn small_claiming_works() {
|
||||
fn medium_claiming_works() {
|
||||
new_test_ext().execute_with(|| {
|
||||
assert_ok!(Claims::claim(
|
||||
RuntimeOrigin::signed(alice_account_id()),
|
||||
second_eth_public_key(),
|
||||
second_signature(),
|
||||
RuntimeOrigin::signed(alice_account_id()),
|
||||
second_eth_public_key(),
|
||||
second_signature(),
|
||||
));
|
||||
|
||||
assert_eq!(Balances::usable_balance(&alice_account_id()), 100);
|
||||
@@ -99,9 +98,9 @@ fn medium_claiming_works() {
|
||||
fn big_claiming_works() {
|
||||
new_test_ext().execute_with(|| {
|
||||
assert_ok!(Claims::claim(
|
||||
RuntimeOrigin::signed(alice_account_id()),
|
||||
third_eth_public_key(),
|
||||
third_signature(),
|
||||
RuntimeOrigin::signed(alice_account_id()),
|
||||
third_eth_public_key(),
|
||||
third_signature(),
|
||||
));
|
||||
|
||||
assert_eq!(Balances::usable_balance(&alice_account_id()), 200);
|
||||
@@ -113,11 +112,15 @@ fn big_claiming_works() {
|
||||
assert_eq!(Club::rank_of(&third_account_id()), None);
|
||||
|
||||
assert_eq!(Vesting::vesting_balance(&alice_account_id()), Some(800));
|
||||
assert_eq!(ghost_claims::Total::<Test, ()>::get(), total_claims() - 1000);
|
||||
assert_eq!(
|
||||
ghost_claims::Total::<Test, ()>::get(),
|
||||
total_claims() - 1000
|
||||
);
|
||||
assert_ok!(Balances::transfer_allow_death(
|
||||
RuntimeOrigin::signed(alice_account_id()),
|
||||
bob_account_id(),
|
||||
200));
|
||||
RuntimeOrigin::signed(alice_account_id()),
|
||||
bob_account_id(),
|
||||
200
|
||||
));
|
||||
})
|
||||
}
|
||||
|
||||
@@ -125,19 +128,19 @@ fn big_claiming_works() {
|
||||
fn multiple_accounts_claiming_works() {
|
||||
new_test_ext().execute_with(|| {
|
||||
assert_ok!(Claims::claim(
|
||||
RuntimeOrigin::signed(alice_account_id()),
|
||||
first_eth_public_key(),
|
||||
first_signature(),
|
||||
RuntimeOrigin::signed(alice_account_id()),
|
||||
first_eth_public_key(),
|
||||
first_signature(),
|
||||
));
|
||||
assert_ok!(Claims::claim(
|
||||
RuntimeOrigin::signed(alice_account_id()),
|
||||
second_eth_public_key(),
|
||||
second_signature(),
|
||||
RuntimeOrigin::signed(alice_account_id()),
|
||||
second_eth_public_key(),
|
||||
second_signature(),
|
||||
));
|
||||
assert_ok!(Claims::claim(
|
||||
RuntimeOrigin::signed(alice_account_id()),
|
||||
third_eth_public_key(),
|
||||
third_signature(),
|
||||
RuntimeOrigin::signed(alice_account_id()),
|
||||
third_eth_public_key(),
|
||||
third_signature(),
|
||||
));
|
||||
|
||||
assert_eq!(Balances::usable_balance(&alice_account_id()), 310);
|
||||
@@ -157,19 +160,19 @@ fn multiple_accounts_claiming_works() {
|
||||
fn multiple_accounts_reverese_claiming_works() {
|
||||
new_test_ext().execute_with(|| {
|
||||
assert_ok!(Claims::claim(
|
||||
RuntimeOrigin::signed(alice_account_id()),
|
||||
third_eth_public_key(),
|
||||
third_signature(),
|
||||
RuntimeOrigin::signed(alice_account_id()),
|
||||
third_eth_public_key(),
|
||||
third_signature(),
|
||||
));
|
||||
assert_ok!(Claims::claim(
|
||||
RuntimeOrigin::signed(alice_account_id()),
|
||||
second_eth_public_key(),
|
||||
second_signature(),
|
||||
RuntimeOrigin::signed(alice_account_id()),
|
||||
second_eth_public_key(),
|
||||
second_signature(),
|
||||
));
|
||||
assert_ok!(Claims::claim(
|
||||
RuntimeOrigin::signed(alice_account_id()),
|
||||
first_eth_public_key(),
|
||||
first_signature(),
|
||||
RuntimeOrigin::signed(alice_account_id()),
|
||||
first_eth_public_key(),
|
||||
first_signature(),
|
||||
));
|
||||
|
||||
assert_eq!(Balances::usable_balance(&alice_account_id()), 310);
|
||||
@@ -188,11 +191,14 @@ fn multiple_accounts_reverese_claiming_works() {
|
||||
#[test]
|
||||
fn cannot_claim_with_bad_signature() {
|
||||
new_test_ext().execute_with(|| {
|
||||
assert_err!(Claims::claim(
|
||||
assert_err!(
|
||||
Claims::claim(
|
||||
RuntimeOrigin::signed(alice_account_id()),
|
||||
first_eth_public_key(),
|
||||
wrong_signature()),
|
||||
crate::Error::<Test>::InvalidEthereumAddress);
|
||||
wrong_signature()
|
||||
),
|
||||
crate::Error::<Test>::InvalidEthereumAddress
|
||||
);
|
||||
|
||||
assert_eq!(Balances::usable_balance(&alice_account_id()), 0);
|
||||
assert_eq!(Balances::usable_balance(&first_account_id()), 10);
|
||||
@@ -212,11 +218,14 @@ fn cannot_claim_with_bad_signature() {
|
||||
#[test]
|
||||
fn cannot_claim_with_wrong_address() {
|
||||
new_test_ext().execute_with(|| {
|
||||
assert_err!(Claims::claim(
|
||||
assert_err!(
|
||||
Claims::claim(
|
||||
RuntimeOrigin::signed(bob_account_id()),
|
||||
first_eth_public_key(),
|
||||
first_signature()),
|
||||
crate::Error::<Test>::InvalidEthereumAddress);
|
||||
first_signature()
|
||||
),
|
||||
crate::Error::<Test>::InvalidEthereumAddress
|
||||
);
|
||||
|
||||
assert_eq!(Balances::usable_balance(&bob_account_id()), 0);
|
||||
assert_eq!(Balances::usable_balance(&alice_account_id()), 0);
|
||||
@@ -237,11 +246,14 @@ fn cannot_claim_with_wrong_address() {
|
||||
#[test]
|
||||
fn cannot_claim_nothing() {
|
||||
new_test_ext().execute_with(|| {
|
||||
assert_err!(Claims::claim(
|
||||
assert_err!(
|
||||
Claims::claim(
|
||||
RuntimeOrigin::signed(bob_account_id()),
|
||||
fourth_eth_public_key(),
|
||||
fourth_signature()),
|
||||
crate::Error::<Test>::NoBalanceToClaim);
|
||||
fourth_signature()
|
||||
),
|
||||
crate::Error::<Test>::NoBalanceToClaim
|
||||
);
|
||||
assert_eq!(Balances::usable_balance(&bob_account_id()), 0);
|
||||
assert_eq!(Balances::usable_balance(&fourth_account_id()), 0);
|
||||
assert_eq!(Vesting::vesting_balance(&bob_account_id()), None);
|
||||
@@ -259,16 +271,15 @@ fn event_emitted_during_claim() {
|
||||
System::reset_events();
|
||||
assert_eq!(System::event_count(), 0);
|
||||
assert_ok!(Claims::claim(
|
||||
RuntimeOrigin::signed(alice_account_id()),
|
||||
third_eth_public_key(),
|
||||
third_signature(),
|
||||
RuntimeOrigin::signed(alice_account_id()),
|
||||
third_eth_public_key(),
|
||||
third_signature(),
|
||||
));
|
||||
System::assert_has_event(RuntimeEvent::Claims(
|
||||
crate::Event::Claimed {
|
||||
receiver: alice_account_id(),
|
||||
donor: account,
|
||||
amount,
|
||||
rank,
|
||||
}));
|
||||
System::assert_has_event(RuntimeEvent::Claims(crate::Event::Claimed {
|
||||
receiver: alice_account_id(),
|
||||
donor: account,
|
||||
amount,
|
||||
rank,
|
||||
}));
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user