Skip to content

Commit

Permalink
fix warnings & dummy test
Browse files Browse the repository at this point in the history
  • Loading branch information
Szegoo committed May 29, 2024
1 parent 1cf36bf commit 673ab51
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 15 deletions.
19 changes: 11 additions & 8 deletions pallets/orders/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,27 +13,25 @@
// You should have received a copy of the GNU General Public License
// along with RegionX. If not, see <https://www.gnu.org/licenses/>.

use frame_support::{
pallet_prelude::*,
parameter_types,
traits::{nonfungible::Mutate, Everything},
};
use frame_support::{pallet_prelude::*, parameter_types, traits::Everything};
use parachain_primitives::ParaId;
use sp_core::{ConstU64, H256};
use sp_runtime::{
traits::{BlakeTwo256, BlockNumberProvider, IdentityLookup},
AccountId32, BuildStorage, DispatchResult,
traits::{BlakeTwo256, IdentityLookup},
AccountId32, BuildStorage,
};
use xcm::opaque::lts::NetworkId;

use std::sync::Arc;
use xcm_builder::{
AccountId32Aliases, ChildParachainConvertsVia, DescribeAllTerminal, HashedDescription,
};

type AccountId = AccountId32;
type Block = frame_system::mocking::MockBlock<Test>;

pub const ALICE: AccountId = AccountId::new([0u8; 32]);
pub const BOB: AccountId = AccountId::new([1u8; 32]);

// Configure a mock runtime to test the pallet.
frame_support::construct_runtime!(
pub enum Test
Expand Down Expand Up @@ -120,6 +118,11 @@ impl crate::Config for Test {
// Build genesis storage according to the mock runtime.
pub fn new_test_ext() -> sp_io::TestExternalities {
let mut t = frame_system::GenesisConfig::<Test>::default().build_storage().unwrap();
pallet_balances::GenesisConfig::<Test> {
balances: vec![(ALICE, 10_000_000), (BOB, 10_000_000)],
}
.assimilate_storage(&mut t)
.unwrap();
let mut ext = sp_io::TestExternalities::new(t);
ext.execute_with(|| System::set_block_number(1));
ext
Expand Down
32 changes: 32 additions & 0 deletions pallets/orders/src/tests.rs
Original file line number Diff line number Diff line change
@@ -1 +1,33 @@
// This file is part of RegionX.
//
// RegionX is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// RegionX is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with RegionX. If not, see <https://www.gnu.org/licenses/>.

use crate::{mock::*, Requirements};
use frame_support::assert_ok;

#[test]
fn create_order_works() {
new_test_ext().execute_with(|| {
// TODO
assert_ok!(Orders::create_order(
RuntimeOrigin::signed(ALICE),
2000.into(),
Requirements {
begin: 0,
end: 8,
core_occupancy: 28800 // Half of a core.
}
));
});
}
8 changes: 4 additions & 4 deletions pallets/orders/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ pub type OrderId = u32;
#[derive(Encode, Decode, Debug, Clone, PartialEq, Eq, TypeInfo, MaxEncodedLen)]
pub struct Requirements {
/// The timeslice at which the Region begins.
begin: Timeslice,
pub begin: Timeslice,
/// The timeslice at which the Region ends.
end: Timeslice,
/// The minimum proportion of the core that the region should occupy.
core_occupancy: PartsOf57600,
pub end: Timeslice,
/// The minimum fraction of the core that the region should occupy.
pub core_occupancy: PartsOf57600,
}

/// The information we store about a Coretime order.
Expand Down
4 changes: 1 addition & 3 deletions primitives/parachain/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,8 @@
//!
//! Code copied from polkadot-sdk: https://github.com/paritytech/polkadot-sdk/blob/master/polkadot/runtime/parachains/src/origin.rs

use codec::{CompactAs, Decode, Encode, MaxEncodedLen};
pub use cumulus_primitives_core::ParaId;
use scale_info::TypeInfo;
use sp_runtime::{traits::BadOrigin, RuntimeDebug};
use sp_runtime::traits::BadOrigin;
use sp_std::result;

pub use pallet::*;
Expand Down

0 comments on commit 673ab51

Please sign in to comment.