Skip to content

Commit

Permalink
fix fee-control and fee-proxy mocks
Browse files Browse the repository at this point in the history
  • Loading branch information
JCSanPedro committed Jan 16, 2025
1 parent 48c0995 commit af9e8f6
Show file tree
Hide file tree
Showing 7 changed files with 89 additions and 1 deletion.
4 changes: 4 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pallet/common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ scale-info = { workspace = true }
frame-support = { workspace = true }
frame-system = { workspace = true }
frame-benchmarking = { workspace = true, optional = true }
fp-self-contained = { workspace = true, default-features = true }
sp-core = { workspace = true }
sp-std = { workspace = true }
sp-runtime = { workspace = true }
Expand Down
64 changes: 63 additions & 1 deletion pallet/common/src/test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ pub mod test_prelude {
pub use sp_core::{H160, H256, U256};
pub use sp_runtime::{
testing::Header,
traits::{BlakeTwo256, IdentityLookup},
traits::{BlakeTwo256, IdentityLookup, LookupError, StaticLookup},
ArithmeticError, BoundedVec, BuildStorage,
DispatchError::BadOrigin,
Permill, TokenError,
Expand Down Expand Up @@ -747,3 +747,65 @@ macro_rules! impl_pallet_sylo_config {
}
};
}

#[macro_export]
macro_rules! impl_pallet_xrpl_config {
($test:ident) => {
pub struct FuturepassIdentityLookup;
impl StaticLookup for FuturepassIdentityLookup {
type Source = H160;
type Target = H160;
fn lookup(s: Self::Source) -> Result<Self::Target, LookupError> {
Ok(s)
}
fn unlookup(t: Self::Target) -> Self::Source {
t
}
}
impl ExtrinsicChecker for FuturepassIdentityLookup {
type Call = RuntimeCall;
type Extra = ();
type Result = bool;
fn check_extrinsic(_call: &Self::Call, _extra: &Self::Extra) -> Self::Result {
false
}
}

pub struct ValidatedCall;
impl ExtrinsicChecker for ValidatedCall {
type Call = RuntimeCall;
type Extra = ();
type Result = bool;
fn check_extrinsic(_call: &Self::Call, _extra: &Self::Extra) -> Self::Result {
true
}
}

parameter_types! {
pub const MaxMessageLength: u32 = 2048;
pub const MaxSignatureLength: u32 = 80;
}
impl pallet_xrpl::Config for Test {
type RuntimeEvent = RuntimeEvent;
type RuntimeCall = RuntimeCall;
type CallValidator = ValidatedCall;
type FuturepassLookup = FuturepassIdentityLookup;
type PalletsOrigin = OriginCaller;
type MaxMessageLength = MaxMessageLength;
type MaxSignatureLength = MaxSignatureLength;
type WeightInfo = ();
}
};
}

#[macro_export]
macro_rules! impl_pallet_utility_config {
($test:ident) => {
impl pallet_utility::Config for Test {
type RuntimeEvent = RuntimeEvent;
type RuntimeCall = RuntimeCall;
type PalletsOrigin = OriginCaller;
type WeightInfo = ();
}
};
}
5 changes: 5 additions & 0 deletions pallet/fee-control/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ pallet-dex = { workspace = true }
pallet-assets-ext = { workspace = true }
pallet-futurepass = { workspace = true }
pallet-sylo = { workspace = true }
pallet-xrpl = { workspace = true }
pallet-proxy = { workspace = true }
pallet-utility = { workspace = true }
seed-pallet-common= { workspace = true, default-features = true }

[features]
Expand All @@ -50,6 +53,8 @@ std = [
"frame-system/std",
"pallet-assets/std",
"pallet-balances/std",
"pallet-proxy/std",
"pallet-utility/std",
"sp-runtime/std",
"sp-std/std",
"seed-pallet-common/std",
Expand Down
8 changes: 8 additions & 0 deletions pallet/fee-control/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ use frame_support::{
use pallet_evm::{AddressMapping, BlockHashMapping, EnsureAddressNever, GasWeightMapping};
use precompile_utils::{Address, ErcIdConversion};
use seed_pallet_common::test_prelude::*;
use seed_pallet_common::ExtrinsicChecker;
use sp_runtime::traits::{LookupError, StaticLookup};
use sp_runtime::ConsensusEngineId;

pub const MOCK_PAYMENT_ASSET_ID: AssetId = 100;
Expand All @@ -41,6 +43,9 @@ construct_runtime!(
Futurepass: pallet_futurepass,
Sylo: pallet_sylo,
MockPallet: mock_pallet::pallet,
Xrpl: pallet_xrpl,
Utility: pallet_utility,
Proxy: pallet_proxy,
FeeControl: pallet_fee_control,
}
);
Expand All @@ -56,6 +61,9 @@ impl_pallet_timestamp_config!(Test);
impl_pallet_evm_config!(Test);
impl_pallet_futurepass_config!(Test);
impl_pallet_sylo_config!(Test);
impl_pallet_xrpl_config!(Test);
impl_pallet_proxy_config!(Test);
impl_pallet_utility_config!(Test);
impl_pallet_fee_control_config!(Test);

impl mock_pallet::pallet::Config for Test {}
Expand Down
2 changes: 2 additions & 0 deletions pallet/fee-proxy/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ std = [
"precompile-utils/std",
"pallet-assets-ext/std",
"pallet-futurepass/std",
"pallet-proxy/std",
"pallet-utility/std",
"pallet-evm/std",
"pallet-sylo/std",
"pallet-transaction-payment/std",
Expand Down
6 changes: 6 additions & 0 deletions pallet/fee-proxy/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ construct_runtime!(
Futurepass: pallet_futurepass,
FeeControl: pallet_fee_control,
Sylo: pallet_sylo,
Xrpl: pallet_xrpl,
Utility: pallet_utility,
Proxy: pallet_proxy,
}
);

Expand All @@ -55,6 +58,9 @@ impl_pallet_evm_config!(Test);
impl_pallet_futurepass_config!(Test);
impl_pallet_fee_control_config!(Test);
impl_pallet_sylo_config!(Test);
impl_pallet_xrpl_config!(Test);
impl_pallet_proxy_config!(Test);
impl_pallet_utility_config!(Test);

// Mock ErcIdConversion for testing purposes
impl<RuntimeId> ErcIdConversion<RuntimeId> for Test
Expand Down

0 comments on commit af9e8f6

Please sign in to comment.