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

test(block_production): Add tests to block_production_task method #478

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

GMKrieger
Copy link

Pull Request type

Please add the labels corresponding to the type of changes your PR introduces:

  • Testing

What is the current behavior?

Resolves: #NA

The block production tests currently only test block sealing when starting a new service.

What is the new behavior?

This PR aims to add tests on the block_production_task method and related methods to thoroughly test the code.

Does this introduce a breaking change?

No.

Other information

The testing format is based on #468. All feedback is welcome!

@GMKrieger GMKrieger added the testing Related to tests and test infrastructure label Jan 24, 2025
@GMKrieger GMKrieger self-assigned this Jan 24, 2025
@GMKrieger GMKrieger force-pushed the test/block-production-tests branch 3 times, most recently from 6b9d8ec to da627d1 Compare January 30, 2025 20:48
@GMKrieger GMKrieger marked this pull request as ready for review January 30, 2025 20:48
crates/madara/client/block_production/src/lib.rs Outdated Show resolved Hide resolved
Comment on lines 884 to 926
#[rstest::fixture]
fn pending_block_state_diff() -> StateDiff {
StateDiff {
storage_diffs: vec![
ContractStorageDiffItem {
address: Felt::ONE,
storage_entries: vec![
StorageEntry { key: Felt::ZERO, value: Felt::ZERO },
StorageEntry { key: Felt::ONE, value: Felt::ONE },
StorageEntry { key: Felt::TWO, value: Felt::TWO },
],
},
ContractStorageDiffItem {
address: Felt::TWO,
storage_entries: vec![
StorageEntry { key: Felt::ZERO, value: Felt::ZERO },
StorageEntry { key: Felt::ONE, value: Felt::ONE },
StorageEntry { key: Felt::TWO, value: Felt::TWO },
],
},
ContractStorageDiffItem {
address: Felt::THREE,
storage_entries: vec![
StorageEntry { key: Felt::ZERO, value: Felt::ZERO },
StorageEntry { key: Felt::ONE, value: Felt::ONE },
StorageEntry { key: Felt::TWO, value: Felt::TWO },
],
},
],
deprecated_declared_classes: vec![Felt::ZERO],
declared_classes: vec![
DeclaredClassItem { class_hash: Felt::ONE, compiled_class_hash: Felt::ONE },
DeclaredClassItem { class_hash: Felt::TWO, compiled_class_hash: Felt::TWO },
],
deployed_contracts: vec![DeployedContractItem { address: Felt::THREE, class_hash: Felt::THREE }],
replaced_classes: vec![ReplacedClassItem { contract_address: Felt::TWO, class_hash: Felt::TWO }],
nonces: vec![
NonceUpdate { contract_address: Felt::ONE, nonce: Felt::ONE },
NonceUpdate { contract_address: Felt::TWO, nonce: Felt::TWO },
NonceUpdate { contract_address: Felt::THREE, nonce: Felt::THREE },
],
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm not sure its a good idea to have a fixture for the pending block state diff as this is very subject to change depending on the test we are running. Imo this is too specific and we should probably be defining this on a per-test basis. Wdyt?

Copy link
Author

Choose a reason for hiding this comment

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

I created this on a point of testing that many more tests used this pending block setup and the file was getting ridiculously long. In hindsight, it shouldn't have been a fixture anyway because of what you said, but maybe it could be a method that creates a simple pending block from the fixtures if need be and more tests are created.

crates/madara/client/block_production/src/lib.rs Outdated Show resolved Hide resolved
crates/madara/client/block_production/src/lib.rs Outdated Show resolved Hide resolved
@GMKrieger GMKrieger force-pushed the test/block-production-tests branch from da627d1 to 96948a1 Compare February 3, 2025 15:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
testing Related to tests and test infrastructure
Projects
Status: In review
Development

Successfully merging this pull request may close these issues.

2 participants