diff --git a/Cargo.lock b/Cargo.lock index 6f3c201c..6b0e2b06 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2557,6 +2557,7 @@ dependencies = [ "frame-try-runtime", "gafi-support", "game-randomness", + "log", "pallet-aura", "pallet-balances", "pallet-cache", diff --git a/gafi-node/node/Cargo.toml b/gafi-node/node/Cargo.toml index 2899864e..4d23e2b0 100644 --- a/gafi-node/node/Cargo.toml +++ b/gafi-node/node/Cargo.toml @@ -20,53 +20,53 @@ name = "gafi-node" clap = { version = "4.2.5", features = ["derive"] } futures = { version = "0.3.21", features = ["thread-pool"] } -sc-cli = { workspace = true, default-features = false } +sc-cli = { workspace = true } sp-core = { workspace = true, default-features = false } -sc-executor = { workspace = true, default-features = false } -sc-network = { workspace = true, default-features = false } -sc-service = { workspace = true, default-features = false } -sc-telemetry = { workspace = true, default-features = false } -sc-transaction-pool = { workspace = true, default-features = false } -sc-transaction-pool-api = { workspace = true, default-features = false } -sc-offchain = { workspace = true, default-features = false } -sc-statement-store = { workspace = true, default-features = false } -sc-consensus-aura = { workspace = true, default-features = false } +sc-executor = { workspace = true } +sc-network = { workspace = true } +sc-service = { workspace = true } +sc-telemetry = { workspace = true } +sc-transaction-pool = { workspace = true } +sc-transaction-pool-api = { workspace = true } +sc-offchain = { workspace = true } +sc-statement-store = { workspace = true } +sc-consensus-aura = { workspace = true } sp-consensus-aura = { workspace = true, default-features = false } -sc-consensus = { workspace = true, default-features = false } -sc-consensus-grandpa = { workspace = true, default-features = false } +sc-consensus = { workspace = true } +sc-consensus-grandpa = { workspace = true } sp-consensus-grandpa = { workspace = true, default-features = false } -sc-client-api = { workspace = true, default-features = false } +sc-client-api = { workspace = true } sp-runtime = { workspace = true, default-features = false } sp-io = { workspace = true, default-features = false } sp-timestamp = { workspace = true, default-features = false } sp-inherents = { workspace = true, default-features = false } -sp-keyring = { workspace = true, default-features = false } +sp-keyring = { workspace = true } frame-system = { workspace = true, default-features = false } pallet-transaction-payment = { workspace = true, default-features = false } # These dependencies are used for the node template's RPCs jsonrpsee = { version = "0.16.2", features = ["server"] } sp-api = { workspace = true, default-features = false } -sc-rpc-api = { workspace = true, default-features = false } -sp-blockchain = { workspace = true, default-features = false } +sc-rpc-api = { workspace = true } +sp-blockchain = { workspace = true } sp-block-builder = { workspace = true, default-features = false } -sc-basic-authorship = { workspace = true, default-features = false } -substrate-frame-rpc-system = { workspace = true, default-features = false } -pallet-transaction-payment-rpc = { workspace = true, default-features = false } +sc-basic-authorship = { workspace = true } +substrate-frame-rpc-system = { workspace = true } +pallet-transaction-payment-rpc = { workspace = true } # These dependencies are used for runtime benchmarking frame-benchmarking = { workspace = true, default-features = false } -frame-benchmarking-cli = { workspace = true, default-features = false } +frame-benchmarking-cli = { workspace = true } # Local Dependencies gafi-runtime = { version = "4.0.0-dev", path = "../runtime" } gafi-support = { version = "4.0.0-dev", default-features = false, path = "../../support" } # CLI-specific dependencies -try-runtime-cli = { workspace = true, default-features = false, optional = true } +try-runtime-cli = { workspace = true, optional = true } [build-dependencies] -substrate-build-script-utils = { workspace = true, default-features = false } +substrate-build-script-utils = { workspace = true } [features] default = [] diff --git a/gafi-node/runtime/Cargo.toml b/gafi-node/runtime/Cargo.toml index eb2a653f..48485ff6 100644 --- a/gafi-node/runtime/Cargo.toml +++ b/gafi-node/runtime/Cargo.toml @@ -19,6 +19,7 @@ codec = { package = "parity-scale-codec", version = "3.6.1", default-features = scale-info = { version = "2.5.0", default-features = false, features = [ "derive", ] } +log = { version = "0.4.19", default-features = false } pallet-aura = { workspace = true, default-features = false } pallet-balances = { workspace = true, default-features = false } @@ -64,7 +65,7 @@ game-randomness = { version = "4.0.0-dev", default-features = false, path = "../ pallet-game = { version = "4.0.0-dev", default-features = false, path = "../../game/pallet-game" } [build-dependencies] -substrate-wasm-builder = { workspace = true, default-features = false, optional = true } +substrate-wasm-builder = { workspace = true, optional = true } [features] default = ["std"] @@ -99,6 +100,7 @@ std = [ "sp-transaction-pool/std", "sp-version/std", "substrate-wasm-builder", + "log/std", "pallet-insecure-randomness-collective-flip/std", "pallet-nfts/std", diff --git a/gafi-node/runtime/src/lib.rs b/gafi-node/runtime/src/lib.rs index 52547b31..b84525db 100644 --- a/gafi-node/runtime/src/lib.rs +++ b/gafi-node/runtime/src/lib.rs @@ -185,7 +185,7 @@ where ); let raw_payload = SignedPayload::new(call, extra) .map_err(|e| { - // log::warn!("Unable to create signed payload: {:?}", e); + log::warn!("Unable to create signed payload: {:?}", e); }) .ok()?; let signature = raw_payload.using_encoded(|payload| C::sign(payload, public))?; diff --git a/game/pallet-game/src/benchmarking.rs b/game/pallet-game/src/benchmarking.rs index 77263af2..17ef362a 100644 --- a/game/pallet-game/src/benchmarking.rs +++ b/game/pallet-game/src/benchmarking.rs @@ -456,6 +456,8 @@ benchmarks_instance_pallet! { item: ::Helper::item(0), amount: 10, unit_price: >::Currency::minimum_balance(), + start_block: None, + end_block: None, }.into() ); } @@ -502,6 +504,8 @@ benchmarks_instance_pallet! { who, bundle, price: >::Currency::minimum_balance(), + start_block: None, + end_block: None, }.into() ); } @@ -545,6 +549,8 @@ benchmarks_instance_pallet! { who, wishlist: bundle, price: >::Currency::minimum_balance(), + start_block: None, + end_block: None, }.into() ); } @@ -617,6 +623,8 @@ benchmarks_instance_pallet! { source: bundle, required: required.clone(), maybe_price: Some(>::Currency::minimum_balance()), + start_block: None, + end_block: None, }.into() ); } @@ -765,6 +773,8 @@ benchmarks_instance_pallet! { item: package.item, amount: package.amount, unit_price: >::Currency::minimum_balance(), + start_block: None, + end_block: None, }.into() ); } diff --git a/game/pallet-game/src/lib.rs b/game/pallet-game/src/lib.rs index bafc2434..e45805ec 100644 --- a/game/pallet-game/src/lib.rs +++ b/game/pallet-game/src/lib.rs @@ -39,7 +39,7 @@ mod types; mod benchmarking; mod weights; -use crate::weights::WeightInfo; +// use crate::weights::WeightInfo; pub use weights::*; use frame_support::{ diff --git a/game/pallet-game/src/mock.rs b/game/pallet-game/src/mock.rs index 06d3739d..c3f667c3 100644 --- a/game/pallet-game/src/mock.rs +++ b/game/pallet-game/src/mock.rs @@ -1,40 +1,33 @@ use crate::{self as pallet_game}; use frame_support::{ - dispatch::Vec, parameter_types, - traits::{AsEnsureOriginWithArg, ConstU16, ConstU64, OnFinalize, OnInitialize}, + traits::{AsEnsureOriginWithArg, ConstU64, OnFinalize, OnInitialize}, PalletId, }; use frame_system as system; +use pallet_balances::AccountData; use pallet_nfts::PalletFeatures; -use sp_core::{ - sr25519::{self, Signature}, - ConstU128, ConstU32, H256, -}; +use sp_core::{sr25519::Signature, ConstU128, ConstU32, H256}; use sp_runtime::{ - testing::{Header, TestXt}, + testing::TestXt, traits::{BlakeTwo256, Extrinsic as ExtrinsicT, IdentifyAccount, IdentityLookup, Verify}, }; -use system::{mocking}; +use system::mocking; pub type Extrinsic = TestXt; -type UncheckedExtrinsic = mocking::MockUncheckedExtrinsic; type Block = mocking::MockBlock; type AccountId = <::Signer as IdentifyAccount>::AccountId; type AccountPublic = ::Signer; +use sp_runtime::BuildStorage; // Configure a mock runtime to test the pallet. frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system, PalletGame: pallet_game, Balances: pallet_balances, Nfts: pallet_nfts, - } ); @@ -45,43 +38,44 @@ impl system::Config for Test { type DbWeight = (); type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; - type Index = u64; - type BlockNumber = u64; + type Nonce = u64; type Hash = H256; type Hashing = BlakeTwo256; - type AccountId = AccountId; + type AccountId = sp_core::sr25519::Public; type Lookup = IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); type PalletInfo = PalletInfo; - type AccountData = pallet_balances::AccountData; + type AccountData = AccountData; type OnNewAccount = (); type OnKilledAccount = (); type SystemWeightInfo = (); - type SS58Prefix = ConstU16<42>; + type SS58Prefix = (); type OnSetCode = (); - type MaxConsumers = frame_support::traits::ConstU32<16>; + type MaxConsumers = ConstU32<16>; } pub const EXISTENTIAL_DEPOSIT: u128 = 1000; +parameter_types! { + pub ExistentialDeposit: u128 = EXISTENTIAL_DEPOSIT; +} + impl pallet_balances::Config for Test { - type MaxLocks = ConstU32<50>; + type MaxLocks = (); type MaxReserves = (); type ReserveIdentifier = [u8; 8]; - /// The type for recording an account's balance. type Balance = u128; - /// The ubiquitous event type. - type RuntimeEvent = RuntimeEvent; type DustRemoval = (); - type ExistentialDeposit = ConstU128; + type RuntimeEvent = RuntimeEvent; + type ExistentialDeposit = ExistentialDeposit; type AccountStore = System; - type WeightInfo = pallet_balances::weights::SubstrateWeight; + type WeightInfo = (); type FreezeIdentifier = (); type MaxFreezes = (); - type HoldIdentifier = (); + type RuntimeHoldReason = (); type MaxHolds = (); } @@ -229,5 +223,5 @@ pub fn run_to_block(n: u64) { // Build genesis storage according to the mock runtime. pub fn new_test_ext() -> sp_io::TestExternalities { - system::GenesisConfig::default().build_storage::().unwrap().into() + frame_system::GenesisConfig::::default().build_storage().unwrap().into() } diff --git a/game/pallet-game/src/tests.rs b/game/pallet-game/src/tests.rs index aee7b89b..8a8c03e3 100644 --- a/game/pallet-game/src/tests.rs +++ b/game/pallet-game/src/tests.rs @@ -281,7 +281,7 @@ fn create_game_should_works() { fn create_game_collection_should_works() { new_test_ext().execute_with(|| { run_to_block(1); - let (owner, admin) = do_create_game(); + let (_, admin) = do_create_game(); assert_ok!(PalletGame::create_game_collection( RuntimeOrigin::signed(admin.clone()), @@ -305,7 +305,7 @@ fn create_game_collection_should_fails() { // no permission { run_to_block(1); - let (owner, admin) = do_create_game(); + let (owner, _) = do_create_game(); let acc = new_account(3, 3 * unit(GAKI)); // random acc should has no permission @@ -413,7 +413,7 @@ fn set_accept_adding_should_works() { fn add_game_collection_should_works() { new_test_ext().execute_with(|| { run_to_block(1); - let (owner, admin) = do_create_game(); + let (_, admin) = do_create_game(); let who = new_account(1, 1000 * unit(GAKI)); @@ -1001,7 +1001,7 @@ pub fn buy_bundle_should_fails() { run_to_block(1); let price = 100 * unit(GAKI); - let seller = do_all_set_bundle(TEST_BUNDLE.clone().to_vec(), price); + let _ = do_all_set_bundle(TEST_BUNDLE.clone().to_vec(), price); let buyer = new_account(1, 1 * unit(GAKI)); @@ -1801,7 +1801,7 @@ fn create_dynamic_pool_should_works() { fn request_mint_should_works() { new_test_ext().execute_with(|| { run_to_block(1); - let (owner, _) = do_all_create_stable_pool(default_mint_config()); + let (_, _) = do_all_create_stable_pool(default_mint_config()); let player = new_account(2, 1000_000 * unit(GAKI)); let amount = 10; diff --git a/game/randomness/src/mock.rs b/game/randomness/src/mock.rs index a32f3516..8d41256f 100644 --- a/game/randomness/src/mock.rs +++ b/game/randomness/src/mock.rs @@ -1,31 +1,22 @@ use crate as game_randomness; use crate::*; -use frame_support::{ - dispatch::Vec, - parameter_types, - traits::{ConstU16, ConstU64}, - PalletId, -}; +use frame_support::{parameter_types, traits::ConstU64, PalletId}; use frame_system as system; use sp_core::{sr25519::Signature, H256}; use sp_runtime::{ - testing::{Header, TestXt}, + testing::TestXt, traits::{BlakeTwo256, Extrinsic as ExtrinsicT, IdentifyAccount, IdentityLookup, Verify}, + BuildStorage, }; use system::mocking; - -pub type Extrinsic = TestXt; -type UncheckedExtrinsic = mocking::MockUncheckedExtrinsic; -type Block = mocking::MockBlock; +type Extrinsic = TestXt; type AccountId = <::Signer as IdentifyAccount>::AccountId; +type Block = mocking::MockBlock; // Configure a mock runtime to test the pallet. frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system, GameRandomness: game_randomness, @@ -40,13 +31,12 @@ impl system::Config for Test { type DbWeight = (); type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; - type Index = u64; - type BlockNumber = u64; + type Nonce = u64; type Hash = H256; type Hashing = BlakeTwo256; - type AccountId = AccountId; + type AccountId = sp_core::sr25519::Public; type Lookup = IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); @@ -55,9 +45,9 @@ impl system::Config for Test { type OnNewAccount = (); type OnKilledAccount = (); type SystemWeightInfo = (); - type SS58Prefix = ConstU16<42>; + type SS58Prefix = (); type OnSetCode = (); - type MaxConsumers = frame_support::traits::ConstU32<16>; + type MaxConsumers = ConstU32<16>; } impl pallet_insecure_randomness_collective_flip::Config for Test {} @@ -84,9 +74,9 @@ impl frame_system::offchain::SigningTypes for Test { type Signature = Signature; } -impl frame_system::offchain::SendTransactionTypes for Test +impl frame_system::offchain::SendTransactionTypes for Test where - RuntimeCall: From, + RuntimeCall: From, { type OverarchingCall = RuntimeCall; type Extrinsic = Extrinsic; @@ -106,17 +96,7 @@ where } } -pub fn run_to_block(n: u64) { - while System::block_number() < n { - if System::block_number() > 1 { - System::on_finalize(System::block_number()); - } - System::set_block_number(System::block_number() + 1); - System::on_initialize(System::block_number()); - } -} - // Build genesis storage according to the mock runtime. pub fn new_test_ext() -> sp_io::TestExternalities { - system::GenesisConfig::default().build_storage::().unwrap().into() + frame_system::GenesisConfig::::default().build_storage().unwrap().into() } diff --git a/game/randomness/src/tests.rs b/game/randomness/src/tests.rs index a5a770fc..3ed9bbd0 100644 --- a/game/randomness/src/tests.rs +++ b/game/randomness/src/tests.rs @@ -1,9 +1,8 @@ -use crate::{mock::*, Error, Event}; -use frame_support::{assert_noop, assert_ok}; +use crate::mock::*; #[test] fn it_works_for_default_value() { new_test_ext().execute_with(|| { assert_eq!(true, true); }); -} \ No newline at end of file +} diff --git a/pallets/pallet-cache/src/lib.rs b/pallets/pallet-cache/src/lib.rs index 2a2cdbc1..02076045 100644 --- a/pallets/pallet-cache/src/lib.rs +++ b/pallets/pallet-cache/src/lib.rs @@ -128,7 +128,7 @@ pub mod pallet { } #[pallet::event] - #[pallet::generate_deposit(pub(super) fn deposit_event)] + // #[pallet::generate_deposit(pub(super) fn deposit_event)] pub enum Event, I: 'static = ()> { } diff --git a/pallets/pallet-cache/src/mock.rs b/pallets/pallet-cache/src/mock.rs index 6ce41ab7..b4511b9b 100644 --- a/pallets/pallet-cache/src/mock.rs +++ b/pallets/pallet-cache/src/mock.rs @@ -1,54 +1,45 @@ use crate::{self as pallet_cache}; -use frame_support::{parameter_types, traits::{GenesisBuild, tokens::Balance}}; +use frame_support::parameter_types; use frame_system as system; use frame_support::traits::{OnFinalize, OnInitialize}; pub use gafi_support::pool::{TicketInfo, TicketType}; +use pallet_balances::AccountData; pub use pallet_balances::Call as BalancesCall; -use sp_core::{H256, ConstU128, ConstU32}; +use sp_core::{ConstU128, ConstU16, ConstU64, H256}; use sp_runtime::{ - testing::Header, traits::{BlakeTwo256, IdentityLookup}, AccountId32, }; use sp_std::{vec, vec::Vec}; - -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; - +use sp_runtime::BuildStorage; pub const TIME_SERVICE: u128 = 60 * 60_000u128; // 1 hour // Configure a mock runtime to test the pallet. frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { - System: frame_system::{Pallet, Call, Config, Storage, Event}, - Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, - Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent}, - PalletCache: pallet_cache::{Pallet, Storage, Event}, + System: frame_system, + Balances: pallet_balances, + Timestamp: pallet_timestamp, + PalletCache: pallet_cache, } ); -pub const EXISTENTIAL_DEPOSIT: u128 = 1000; - impl pallet_balances::Config for Test { - type MaxLocks = ConstU32<50>; + type MaxLocks = (); type MaxReserves = (); type ReserveIdentifier = [u8; 8]; - /// The type for recording an account's balance. type Balance = u128; - /// The ubiquitous event type. - type RuntimeEvent = RuntimeEvent; type DustRemoval = (); - type ExistentialDeposit = ConstU128; + type RuntimeEvent = RuntimeEvent; + type ExistentialDeposit = ConstU128<1>; type AccountStore = System; - type WeightInfo = pallet_balances::weights::SubstrateWeight; + type WeightInfo = (); type FreezeIdentifier = (); type MaxFreezes = (); - type HoldIdentifier = (); + type RuntimeHoldReason = (); type MaxHolds = (); } @@ -90,29 +81,28 @@ impl system::Config for Test { type DbWeight = (); type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; - type Index = u64; - type BlockNumber = u64; + type Nonce = u64; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = AccountId32; - type AccountData = pallet_balances::AccountData; type Lookup = IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; - type BlockHashCount = BlockHashCount; + type BlockHashCount = ConstU64<250>; type Version = (); type PalletInfo = PalletInfo; + type AccountData = AccountData; type OnNewAccount = (); type OnKilledAccount = (); type SystemWeightInfo = (); - type SS58Prefix = SS58Prefix; + type SS58Prefix = ConstU16<42>; type OnSetCode = (); type MaxConsumers = frame_support::traits::ConstU32<16>; } // Build genesis storage according to the mock runtime. pub fn _new_test_ext() -> sp_io::TestExternalities { - system::GenesisConfig::default().build_storage::().unwrap().into() + frame_system::GenesisConfig::::default().build_storage().unwrap().into() } pub fn run_to_block(n: u64) { @@ -142,7 +132,8 @@ impl Default for ExtBuilder { impl ExtBuilder { fn build(self) -> sp_io::TestExternalities { - let mut storage = frame_system::GenesisConfig::default().build_storage::().unwrap(); + let mut storage = + frame_system::GenesisConfig::::default().build_storage().unwrap().into(); let _ = pallet_balances::GenesisConfig:: { balances: self.balances, diff --git a/pallets/pallet-faucet/src/mock.rs b/pallets/pallet-faucet/src/mock.rs index 3d6445f5..f7c9f257 100644 --- a/pallets/pallet-faucet/src/mock.rs +++ b/pallets/pallet-faucet/src/mock.rs @@ -2,56 +2,46 @@ use crate as pallet_faucet; use frame_support::parameter_types; use frame_system as system; -use frame_support::{ - dispatch::Vec, -}; -use sp_core::{H256, ConstU32, ConstU128, ConstU64}; +use frame_support::dispatch::Vec; +use pallet_balances::AccountData; +pub use pallet_balances::Call as BalancesCall; +use sp_core::{ConstU128, ConstU64, H256, ConstU16}; use sp_runtime::{ - testing::Header, traits::{BlakeTwo256, IdentityLookup}, AccountId32, }; -pub use pallet_balances::Call as BalancesCall; - -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; +use sp_runtime::BuildStorage; type Block = frame_system::mocking::MockBlock; // Configure a mock runtime to test the pallet. frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { - System: frame_system::{Pallet, Call, Config, Storage, Event}, - Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, - Faucet: pallet_faucet::{Pallet, Call, Storage, Event}, - PalletCache: pallet_cache::{Pallet, Storage, Event}, - Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent}, + System: frame_system, + Balances: pallet_balances, + Faucet: pallet_faucet, + PalletCache: pallet_cache, + Timestamp: pallet_timestamp, } ); -pub const EXISTENTIAL_DEPOSIT: u64 = 1000; - impl pallet_balances::Config for Test { - type MaxLocks = ConstU32<50>; + type MaxLocks = (); type MaxReserves = (); type ReserveIdentifier = [u8; 8]; - /// The type for recording an account's balance. - type Balance = u64; - /// The ubiquitous event type. - type RuntimeEvent = RuntimeEvent; + type Balance = u128; type DustRemoval = (); - type ExistentialDeposit = ConstU64; + type RuntimeEvent = RuntimeEvent; + type ExistentialDeposit = ConstU128<1>; type AccountStore = System; - type WeightInfo = pallet_balances::weights::SubstrateWeight; + type WeightInfo = (); type FreezeIdentifier = (); type MaxFreezes = (); - type HoldIdentifier = (); + type RuntimeHoldReason = (); type MaxHolds = (); } -pub const FAUCET_BALANCE: u64 = 1_000_000; +pub const FAUCET_BALANCE: u128 = 1_000_000; pub const MILLISECS_PER_BLOCK: u64 = 6000; pub const SLOT_DURATION: u64 = 6 * MILLISECS_PER_BLOCK; // 6 seconds pub const TIME_SERVICE: u128 = 60 * 60_000u128; // 1 hour @@ -79,7 +69,7 @@ impl pallet_cache::Config for Test { } parameter_types! { - pub FaucetAmount: u64 = FAUCET_BALANCE; + pub FaucetAmount: u128 = FAUCET_BALANCE; } impl pallet_faucet::Config for Test { @@ -102,34 +92,33 @@ impl system::Config for Test { type DbWeight = (); type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; - type Index = u64; - type BlockNumber = u64; + type Nonce = u64; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = AccountId32; type Lookup = IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; - type BlockHashCount = BlockHashCount; + type BlockHashCount = ConstU64<250>; type Version = (); type PalletInfo = PalletInfo; - type AccountData = pallet_balances::AccountData; + type AccountData = AccountData; type OnNewAccount = (); type OnKilledAccount = (); type SystemWeightInfo = (); - type SS58Prefix = SS58Prefix; + type SS58Prefix = ConstU16<42>; type OnSetCode = (); type MaxConsumers = frame_support::traits::ConstU32<16>; } // Build genesis storage according to the mock runtime. pub fn _new_test_ext() -> sp_io::TestExternalities { - system::GenesisConfig::default().build_storage::().unwrap().into() + frame_system::GenesisConfig::::default().build_storage().unwrap().into() } pub const GENESIS_ACCOUNT: AccountId32 = AccountId32::new([0u8; 32]); -pub const TEST_ACCOUNTS: [(AccountId32, u64); 10] = [ +pub const TEST_ACCOUNTS: [(AccountId32, u128); 10] = [ (GENESIS_ACCOUNT, 1000000000000000000), (AccountId32::new([1u8; 32]), 1000000000000000000), (AccountId32::new([2u8; 32]), 1000000000000000000), @@ -143,7 +132,7 @@ pub const TEST_ACCOUNTS: [(AccountId32, u64); 10] = [ ]; pub struct ExtBuilder { - balances: Vec<(AccountId32, u64)>, + balances: Vec<(AccountId32, u128)>, genesis_accounts: Vec, } @@ -165,13 +154,18 @@ impl Default for ExtBuilder { impl ExtBuilder { fn build(self) -> sp_io::TestExternalities { - let mut storage = frame_system::GenesisConfig::default().build_storage::().unwrap(); + let mut storage = + frame_system::GenesisConfig::::default().build_storage().unwrap().into(); - let _ = pallet_balances::GenesisConfig:: { balances: self.balances } - .assimilate_storage(&mut storage); + let _ = pallet_balances::GenesisConfig:: { + balances: self.balances, + } + .assimilate_storage(&mut storage); - let _ = pallet_faucet::GenesisConfig:: { genesis_accounts: self.genesis_accounts } - .assimilate_storage(&mut storage); + let _ = pallet_faucet::GenesisConfig:: { + genesis_accounts: self.genesis_accounts, + } + .assimilate_storage(&mut storage); let ext = sp_io::TestExternalities::from(storage); ext diff --git a/pallets/pallet-faucet/src/tests.rs b/pallets/pallet-faucet/src/tests.rs index 232e5780..0563bd70 100644 --- a/pallets/pallet-faucet/src/tests.rs +++ b/pallets/pallet-faucet/src/tests.rs @@ -18,7 +18,7 @@ fn faucet_works() { fn faucet_works_with_low_balance() { ExtBuilder::default().build_and_execute(|| { let sender = AccountId32::new([11; 32]); - let legit_balance = FAUCET_BALANCE / 10 - 1u64; + let legit_balance = FAUCET_BALANCE / 10 - 1u128; let _ = pallet_balances::Pallet::::deposit_creating(&sender, legit_balance); assert_eq!(Balances::free_balance(&sender), legit_balance); assert_ok!(Faucet::faucet(RuntimeOrigin::signed(sender.clone())));