-
Notifications
You must be signed in to change notification settings - Fork 7
chore: add e2e testcase for contract size #98
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -56,6 +56,37 @@ pub fn create_test_chain_spec_with_mint_admin(mint_admin: Address) -> Arc<ChainS | |
| create_test_chain_spec_with_extras(None, Some(mint_admin)) | ||
| } | ||
|
|
||
| /// Creates a reusable chain specification with a custom contract size limit. | ||
| pub fn create_test_chain_spec_with_contract_size_limit( | ||
| contract_size_limit: usize, | ||
| activation_height: Option<u64>, | ||
| ) -> Arc<ChainSpec> { | ||
| let mut genesis: Genesis = | ||
| serde_json::from_str(include_str!("../assets/genesis.json")).expect("valid genesis"); | ||
|
|
||
| let mut extras = serde_json::Map::new(); | ||
| extras.insert("contractSizeLimit".to_string(), json!(contract_size_limit)); | ||
| if let Some(height) = activation_height { | ||
| extras.insert( | ||
| "contractSizeLimitActivationHeight".to_string(), | ||
| json!(height), | ||
| ); | ||
| } | ||
|
|
||
| genesis | ||
| .config | ||
| .extra_fields | ||
| .insert("evolve".to_string(), serde_json::Value::Object(extras)); | ||
|
|
||
| Arc::new( | ||
| ChainSpecBuilder::default() | ||
| .chain(reth_chainspec::Chain::from_id(TEST_CHAIN_ID)) | ||
| .genesis(genesis) | ||
| .cancun_activated() | ||
| .build(), | ||
| ) | ||
| } | ||
|
Comment on lines
+59
to
+88
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The logic for creating a To reduce duplication, you could refactor |
||
|
|
||
| fn create_test_chain_spec_with_extras( | ||
| base_fee_sink: Option<Address>, | ||
| mint_admin: Option<Address>, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's significant code duplication between
contract_size_limit_rejects_oversized_codeandcontract_size_limit_allows_oversized_code_when_configured. The setup for state, caller account, andevm_envis nearly identical.To improve readability and maintainability, consider extracting this common setup into a helper function. This function could take the
ContractSizeLimitSettingsas a parameter and return the configured EVM instance and other necessary test data.