Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mocks updated to use TestDefaultConfig #1410

Merged
merged 3 commits into from
Jan 23, 2025
Merged

Mocks updated to use TestDefaultConfig #1410

merged 3 commits into from
Jan 23, 2025

Conversation

grbIzl
Copy link
Contributor

@grbIzl grbIzl commented Jan 16, 2025

Pull Request Summary
Resolves the issue #1350

The following implementations in mocks were wrapped with derive macro to use TestDefaultConfig:

  • pallet_balances::Config
  • pallet_migrations::Config
  • frame_system::Config
  • pallet_timestamp::Config
  • pallet_assets::Config
  • pallet_contracts::Config

Check list

  • added or updated unit tests
  • updated Astar official documentation
  • added OnRuntimeUpgrade hook for precompile revert code registration
  • added benchmarks & weights for any modified runtime logics.

@grbIzl grbIzl added the tests If the PR/issue is related to tests, like xcm-simulator tests, rpc-tests etc. label Jan 16, 2025
@grbIzl grbIzl mentioned this pull request Jan 16, 2025
4 tasks
@grbIzl grbIzl marked this pull request as ready for review January 16, 2025 14:30
Copy link
Member

@Dinonard Dinonard left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a step in the right direction!

There should be more 'deletion' though.
Since we're using default params, there's no need to have all the params defined manually.

@grbIzl
Copy link
Contributor Author

grbIzl commented Jan 17, 2025

@Dinonard I cleanup obvious duplications. But I didn't touch the parameters that were redefined with anything meaningful

Dinonard
Dinonard previously approved these changes Jan 17, 2025
Copy link
Member

@Dinonard Dinonard left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@grbIzl grbIzl force-pushed the feat/updatemocks2 branch from 2f3ccef to 3a9bfe4 Compare January 20, 2025 10:32
Copy link
Contributor

@ipapandinas ipapandinas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From what I have read on the pallet-default-config-example documentation, I think that additional deletions can be made.

type Block = Block;
type DbWeight = ();
type RuntimeOrigin = RuntimeOrigin;
type Nonce = u64;
type Hash = H256;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can get rid of almost all parameters according to the frame_system::config_preludes::TestDefaultConfig; only keep only Block (defined as no_default), BlockHashCount and AccountData (overwrited).

Even Runtime* types are being injected as types generated by construct_runtime (marked as #[inject_runtime_type]).

}

parameter_types! {
pub const ExistentialDeposit: u64 = 10;
}

#[derive_impl(pallet_balances::config_preludes::TestDefaultConfig)]
impl pallet_balances::Config for Test {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure about the impact on actual tests, but perhaps using all default values might work. For example, having MaxLocks set to ConstU32<100> or 1 as the existential deposit might also work. You can find default values for pallet_balances here.

Copy link

Code Coverage

Package Line Rate Branch Rate Health
pallets/dapp-staking/rpc/runtime-api/src 0% 0%
precompiles/dapp-staking/src 89% 0%
pallets/unified-accounts/src 81% 0%
pallets/dapp-staking/src 79% 0%
chain-extensions/types/assets/src 0% 0%
pallets/vesting-mbm/src 87% 0%
precompiles/assets-erc20/src 78% 0%
pallets/astar-xcm-benchmarks/src/fungible 100% 0%
pallets/collator-selection/src 87% 0%
pallets/collective-proxy/src 94% 0%
primitives/src/xcm 62% 0%
pallets/astar-xcm-benchmarks/src 86% 0%
pallets/xc-asset-config/src 48% 0%
precompiles/substrate-ecdsa/src 67% 0%
precompiles/unified-accounts/src 100% 0%
pallets/astar-xcm-benchmarks/src/generic 100% 0%
precompiles/sr25519/src 56% 0%
chain-extensions/pallet-assets/src 54% 0%
precompiles/dispatch-lockdrop/src 83% 0%
precompiles/dapp-staking/src/test 0% 0%
pallets/dapp-staking/src/test 0% 0%
pallets/price-aggregator/src 75% 0%
chain-extensions/unified-accounts/src 0% 0%
pallets/dapp-staking/src/benchmarking 95% 0%
pallets/dynamic-evm-base-fee/src 85% 0%
primitives/src 54% 0%
precompiles/xcm/src 69% 0%
pallets/ethereum-checked/src 76% 0%
pallets/static-price-provider/src 91% 0%
pallets/inflation/src 90% 0%
chain-extensions/types/unified-accounts/src 0% 0%
Summary 76% (3486 / 4605) 0% (0 / 0)

Minimum allowed line rate is 50%

@grbIzl
Copy link
Contributor Author

grbIzl commented Jan 23, 2025

@ipapandinas I performed the additional cleanup. So the parameters that are left cannot be removed without changing code of the pallet or the test (i tried).

@grbIzl grbIzl requested a review from ipapandinas January 23, 2025 15:20
Copy link
Contributor

@ipapandinas ipapandinas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice effort! It's nice to see so many red lines removed - LGTM

Copy link
Member

@Dinonard Dinonard left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! Great work!

@grbIzl grbIzl merged commit a154d0e into master Jan 23, 2025
8 checks passed
@grbIzl grbIzl deleted the feat/updatemocks2 branch January 23, 2025 18:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tests If the PR/issue is related to tests, like xcm-simulator tests, rpc-tests etc.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants