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

dev: Add builder pattern for the machine object in tests #558

Merged
merged 6 commits into from
Nov 24, 2023

Conversation

edisontim
Copy link
Contributor

Pull Request type

Please check the type of change your PR introduces:

  • Bugfix
  • Feature
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes, no API changes)
  • Build-related changes
  • Documentation content changes
  • Other (please describe):

What is the current behavior?

Resolves: #546

What is the new behavior?

Add builder pattern for Machine object in tests

Does this introduce a breaking change?

  • Yes
  • No

@Eikix
Copy link
Member

Eikix commented Nov 20, 2023

Hi Tim! Thanks for your first PR,
I'd personally rather see an API closer to:

let machine = MachineBuilder::new().with_bytecode(bytecode).with_calldata(calldata).with_caller(caller).with_read_only().build();

Or something similar

that way, we can reduce overall LoC and have more nimble tests.

Moreover, if a test only needs a to set the bytecode, but all the rest can be our pre-defined presets, we can do:

let machine = MachineBuilder::new().with_preset().with_bytecode(bytecode).build();

Lmk if you think that's ok @enitrat @edisontim

@enitrat
Copy link
Collaborator

enitrat commented Nov 20, 2023

agreed - the way it has been implemented just abstracts it but doesn't make it simpler!

@edisontim
Copy link
Contributor Author

Ok I'll remove the Director object from there then :)

@edisontim
Copy link
Contributor Author

Makes sense to me to also get rid of setup_execution_context_with_bytecode and all the others, and for test_execution_context_read_code and other tests like that to create a machine to run the tests. What do you think?

@Eikix
Copy link
Member

Eikix commented Nov 21, 2023

Makes sense to me to also get rid of setup_execution_context_with_bytecode and all the others, and for test_execution_context_read_code and other tests like that to create a machine to run the tests. What do you think?

I think you're right

@edisontim
Copy link
Contributor Author

@enitrat @enitrat Is this what you had in mind?

Copy link
Collaborator

@enitrat enitrat left a comment

Choose a reason for hiding this comment

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

yep looks good now!

@enitrat
Copy link
Collaborator

enitrat commented Nov 23, 2023

all good, please rebase!

@edisontim
Copy link
Contributor Author

Done :) !

Copy link
Collaborator

@enitrat enitrat left a comment

Choose a reason for hiding this comment

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

@Eikix LGTM

@Eikix Eikix added this pull request to the merge queue Nov 24, 2023
Merged via the queue into kkrt-labs:main with commit 40b70d3 Nov 24, 2023
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

dev: use a builder pattern to construct the machine object in tests
3 participants