Skip to content

Commit

Permalink
fix: added pallet account in test files
Browse files Browse the repository at this point in the history
  • Loading branch information
abdulhakim2902 committed Oct 15, 2022
1 parent cc27792 commit b852e93
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 8 deletions.
11 changes: 11 additions & 0 deletions pallets/genetic-testing/tests/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ mod tests {
use frame_system::RawOrigin;
use genetic_testing::{DnaSampleStatus, DnaTestResultSubmission, Error};
use labs::LabInfo;
use orders::PalletAccount;
use services::ServiceInfo;

use primitives_area_code::{CityCode, CountryCode, RegionCode};
Expand All @@ -24,6 +25,8 @@ mod tests {
#[test]
fn reject_dna_sample_works() {
<ExternalityBuilder>::default().existential_deposit(1).build().execute_with(|| {
PalletAccount::<Test>::put(5);

assert_ok!(Balances::set_balance(RawOrigin::Root.into(), 2, 100, 0));
assert_ok!(Labs::register_lab(
Origin::signed(1),
Expand Down Expand Up @@ -195,6 +198,8 @@ mod tests {
#[test]
fn process_dna_sample_works() {
<ExternalityBuilder>::default().existential_deposit(1).build().execute_with(|| {
PalletAccount::<Test>::put(5);

assert_ok!(Balances::set_balance(RawOrigin::Root.into(), 2, 100, 0));
assert_ok!(Labs::register_lab(
Origin::signed(1),
Expand Down Expand Up @@ -322,6 +327,8 @@ mod tests {
#[test]
fn cannot_process_dna_sample_works_unauthorized() {
<ExternalityBuilder>::default().existential_deposit(1).build().execute_with(|| {
PalletAccount::<Test>::put(5);

assert_ok!(Balances::set_balance(RawOrigin::Root.into(), 2, 100, 0));
assert_ok!(Labs::register_lab(
Origin::signed(1),
Expand Down Expand Up @@ -432,6 +439,8 @@ mod tests {
#[test]
fn cannot_process_dna_sample_works_not_submitted() {
<ExternalityBuilder>::default().existential_deposit(1).build().execute_with(|| {
PalletAccount::<Test>::put(5);

assert_ok!(Balances::set_balance(RawOrigin::Root.into(), 2, 100, 0));
assert_ok!(Labs::register_lab(
Origin::signed(1),
Expand Down Expand Up @@ -505,6 +514,8 @@ mod tests {
#[test]
fn submit_test_result_works() {
<ExternalityBuilder>::default().existential_deposit(1).build().execute_with(|| {
PalletAccount::<Test>::put(5);

assert_ok!(Balances::set_balance(RawOrigin::Root.into(), 2, 100, 0));
assert_ok!(Labs::register_lab(
Origin::signed(1),
Expand Down
3 changes: 3 additions & 0 deletions pallets/labs/tests/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ mod tests {
use crate::mock::*;

use labs::{Error, Event as EventC, Lab, LabInfo, LabVerifierKey, PalletAccount};
use orders::PalletAccount as OrderPalletAccount;

use frame_support::{
assert_noop, assert_ok,
Expand Down Expand Up @@ -1261,6 +1262,7 @@ mod tests {

PalletAccount::<Test>::put(4);
LabVerifierKey::<Test>::put(2);
OrderPalletAccount::<Test>::put(5);

assert_ok!(Labs::update_minimum_stake_amount(
Origin::signed(2),
Expand Down Expand Up @@ -1351,6 +1353,7 @@ mod tests {

PalletAccount::<Test>::put(4);
LabVerifierKey::<Test>::put(2);
OrderPalletAccount::<Test>::put(5);

assert_ok!(Labs::update_minimum_stake_amount(
Origin::signed(2),
Expand Down
46 changes: 39 additions & 7 deletions pallets/orders/src/tests.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::{mock::*, Error, EscrowKey, Order, OrderStatus};
use crate::{mock::*, Error, EscrowKey, Order, OrderStatus, PalletAccount};
use frame_support::{
assert_noop, assert_ok,
sp_runtime::traits::{Hash, Keccak256},
Expand Down Expand Up @@ -222,6 +222,9 @@ fn set_order_paid_with_dbio_works() {
let lab = account_key("lab");
let admin = account_key("admin");
let customer = account_key("customer");
let pallet_id = account_key("pallet_id");

PalletAccount::<Test>::put(pallet_id);

assert_ok!(Labs::register_lab(
Origin::signed(lab),
Expand Down Expand Up @@ -310,7 +313,7 @@ fn set_order_paid_with_dbio_works() {
);

assert_eq!(Balances::free_balance(customer), 190);
assert_eq!(Balances::free_balance(Orders::staking_account_id(_order_id)), 10);
assert_eq!(Balances::free_balance(pallet_id), 11);
})
}

Expand All @@ -320,6 +323,9 @@ fn set_order_paid_with_app_chain_token_works() {
let lab = account_key("lab");
let admin = account_key("admin");
let customer = account_key("customer");
let pallet_id = account_key("pallet_id");

PalletAccount::<Test>::put(pallet_id);

assert_ok!(Labs::register_lab(
Origin::signed(lab),
Expand Down Expand Up @@ -409,7 +415,7 @@ fn set_order_paid_with_app_chain_token_works() {
);

assert_eq!(Assets::balance(asset_id, customer), 190);
assert_eq!(Assets::balance(asset_id, Orders::staking_account_id(_order_id)), 10);
assert_eq!(Assets::balance(asset_id, pallet_id), 11);
})
}

Expand All @@ -418,6 +424,9 @@ fn cancel_order_works_when_order_status_paid() {
<ExternalityBuilder>::default().existential_deposit(1).build().execute_with(|| {
let lab = account_key("lab");
let customer = account_key("customer");
let pallet_id = account_key("pallet_id");

PalletAccount::<Test>::put(pallet_id);

assert_ok!(Labs::register_lab(
Origin::signed(lab),
Expand Down Expand Up @@ -481,7 +490,7 @@ fn cancel_order_works_when_order_status_paid() {
assert_ok!(Orders::set_order_paid(Origin::signed(customer), _order_id));

assert_eq!(Balances::free_balance(customer), 190);
assert_eq!(Balances::free_balance(Orders::staking_account_id(_order_id)), 10);
assert_eq!(Balances::free_balance(pallet_id), 11);

assert_ok!(Orders::cancel_order(Origin::signed(customer), _order_id));

Expand Down Expand Up @@ -516,7 +525,7 @@ fn cancel_order_works_when_order_status_paid() {
);

assert_eq!(Balances::free_balance(customer), 200);
assert_eq!(Balances::free_balance(Orders::staking_account_id(_order_id)), 0);
assert_eq!(Balances::free_balance(pallet_id), 1);
})
}

Expand All @@ -526,6 +535,9 @@ fn fulfill_order_works() {
let lab = account_key("lab");
let admin = account_key("admin");
let customer = account_key("customer");
let pallet_id = account_key("pallet_id");

PalletAccount::<Test>::put(pallet_id);

assert_ok!(Labs::register_lab(
Origin::signed(lab),
Expand Down Expand Up @@ -633,7 +645,7 @@ fn fulfill_order_works() {

assert_eq!(Balances::free_balance(customer), 190);
assert_eq!(Balances::free_balance(lab), 310);
assert_eq!(Balances::free_balance(Orders::staking_account_id(_order_id)), 0);
assert_eq!(Balances::free_balance(pallet_id), 1);
})
}

Expand All @@ -643,7 +655,9 @@ fn set_order_refunded_works() {
let lab = account_key("lab");
let admin = account_key("admin");
let customer = account_key("customer");
let pallet_id = account_key("pallet_id");

PalletAccount::<Test>::put(pallet_id);
EscrowKey::<Test>::put(admin);

assert_ok!(Labs::register_lab(
Expand Down Expand Up @@ -750,7 +764,7 @@ fn set_order_refunded_works() {

assert_eq!(Balances::free_balance(customer), 195);
assert_eq!(Balances::free_balance(lab), 305);
assert_eq!(Balances::free_balance(Orders::staking_account_id(_order_id)), 0);
assert_eq!(Balances::free_balance(pallet_id), 1);
})
}

Expand Down Expand Up @@ -924,6 +938,9 @@ fn cant_cancel_order_when_order_ongoing() {
<ExternalityBuilder>::default().existential_deposit(1).build().execute_with(|| {
let lab = account_key("lab");
let customer = account_key("customer");
let pallet_id = account_key("pallet_id");

PalletAccount::<Test>::put(pallet_id);

assert_ok!(Labs::register_lab(
Origin::signed(lab),
Expand Down Expand Up @@ -1244,6 +1261,9 @@ fn cant_set_order_paid_when_already_finished() {
<ExternalityBuilder>::default().existential_deposit(1).build().execute_with(|| {
let lab = account_key("lab");
let customer = account_key("customer");
let pallet_id = account_key("pallet_id");

PalletAccount::<Test>::put(pallet_id);

assert_ok!(Labs::register_lab(
Origin::signed(lab),
Expand Down Expand Up @@ -1333,6 +1353,9 @@ fn cant_fulfill_order_when_unauthorized() {
let admin = account_key("admin");
let customer = account_key("customer");
let other_lab = account_key("other_lab");
let pallet_id = account_key("pallet_id");

PalletAccount::<Test>::put(pallet_id);

assert_ok!(Labs::register_lab(
Origin::signed(lab),
Expand Down Expand Up @@ -1493,6 +1516,9 @@ fn cant_fulfill_order_when_already_fulfilled() {
let lab = account_key("lab");
let admin = account_key("admin");
let customer = account_key("customer");
let pallet_id = account_key("pallet_id");

PalletAccount::<Test>::put(pallet_id);

assert_ok!(Labs::register_lab(
Origin::signed(lab),
Expand Down Expand Up @@ -1662,6 +1688,9 @@ fn cant_set_order_refunded_when_already_refunded() {
let lab = account_key("lab");
let admin = account_key("admin");
let customer = account_key("customer");
let pallet_id = account_key("pallet_id");

PalletAccount::<Test>::put(pallet_id);

assert_ok!(Labs::register_lab(
Origin::signed(lab),
Expand Down Expand Up @@ -1759,6 +1788,9 @@ fn call_event_should_work() {
let lab = account_key("lab");
let admin = account_key("admin");
let customer = account_key("customer");
let pallet_id = account_key("pallet_id");

PalletAccount::<Test>::put(pallet_id);

assert_ok!(Labs::register_lab(
Origin::signed(lab),
Expand Down
23 changes: 22 additions & 1 deletion pallets/service-request/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use frame_support::{
};
use genetic_testing::{DnaSampleStatus, DnaTestResultSubmission};
use labs::{LabInfo, LabVerifierKey};
use orders::EscrowKey;
use orders::{EscrowKey, PalletAccount};
use pallet_timestamp::Now;
use primitives_area_code::{CityCode, CountryCode, RegionCode};
use primitives_duration::ExpectedDuration;
Expand Down Expand Up @@ -376,6 +376,9 @@ fn finalize_request_works() {
let admin = account_key("admin");
let customer = account_key("customer");
let lab = account_key("lab");
let pallet_id = account_key("pallet_id");

PalletAccount::<Test>::put(pallet_id);

// Customer create request
assert_ok!(ServiceRequest::create_request(
Expand Down Expand Up @@ -746,6 +749,9 @@ fn cant_claim_request_when_already_processed_or_finalized() {
let admin = account_key("admin");
let customer = account_key("customer");
let lab = account_key("lab");
let pallet_id = account_key("pallet_id");

PalletAccount::<Test>::put(pallet_id);

// Customer create request
assert_ok!(ServiceRequest::create_request(
Expand Down Expand Up @@ -1314,6 +1320,9 @@ fn cant_process_request_when_order_fullfilled() {
let admin = account_key("admin");
let customer = account_key("customer");
let lab = account_key("lab");
let pallet_id = account_key("pallet_id");

PalletAccount::<Test>::put(pallet_id);

// Customer create request
assert_ok!(ServiceRequest::create_request(
Expand Down Expand Up @@ -1771,6 +1780,9 @@ fn cant_process_request_when_request_is_on_processed_or_finalized() {
let customer = account_key("customer");
let admin = account_key("admin");
let lab = account_key("lab");
let pallet_id = account_key("pallet_id");

PalletAccount::<Test>::put(pallet_id);

// Customer create request
assert_ok!(ServiceRequest::create_request(
Expand Down Expand Up @@ -2018,6 +2030,9 @@ fn cant_finalize_requst_when_request_is_not_on_processed() {
let customer = account_key("customer");
let admin = account_key("admin");
let lab = account_key("lab");
let pallet_id = account_key("pallet_id");

PalletAccount::<Test>::put(pallet_id);

// Customer create request
assert_ok!(ServiceRequest::create_request(
Expand Down Expand Up @@ -2142,6 +2157,9 @@ fn cant_finalize_request_when_order_not_fullfilled() {
let admin = account_key("admin");
let customer = account_key("customer");
let lab = account_key("lab");
let pallet_id = account_key("pallet_id");

PalletAccount::<Test>::put(pallet_id);

// Customer create request
assert_ok!(ServiceRequest::create_request(
Expand Down Expand Up @@ -2262,6 +2280,9 @@ fn call_event_should_work() {
let customer = account_key("customer");
let admin = account_key("admin");
let lab = account_key("lab");
let pallet_id = account_key("pallet_id");

PalletAccount::<Test>::put(pallet_id);

System::set_block_number(1);

Expand Down

0 comments on commit b852e93

Please sign in to comment.