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

runCode.js: add pc to opt args | initial API tests #406

Merged
merged 6 commits into from
Feb 12, 2019
Merged

runCode.js: add pc to opt args | initial API tests #406

merged 6 commits into from
Feb 12, 2019

Conversation

pinkiebell
Copy link
Contributor

As a user, I wan't to pass the initial program counter
to the runCode method to gain the ability to start the
execution at a specific step.

@holgerd77
Copy link
Member

I would be feeling more comfortable if we would have some API tests for this. This would in the first place need some basic setup for tests on runCode.js.

@pinkiebell
Copy link
Contributor Author

@holgerd77 👍 I'm going to add some tests next week

@holgerd77
Copy link
Member

Great!

@pinkiebell
Copy link
Contributor Author

@holgerd77 Ready for review 👍

@holgerd77 holgerd77 mentioned this pull request Feb 11, 2019
tests/tester.js Outdated
@@ -249,6 +249,7 @@ function runAll () {
require('./tester.js')
require('./genesishashes.js')
require('./constantinopleSstoreTest.js')
require('./programCounter.js')
Copy link
Member

Choose a reason for hiding this comment

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

Sorry, this is really completely our fault and I have directly created a test cleanup PR #437 on this to avoid future confusion:

The runAll() method is not used for quite some time and is also not integrated into CI, so currently your tests are not run.

Can you just add a file to the tests/api folder instead? Then the tests are run along the npm run testAPI command.

Also: the naming with programCounter.js is far too specific. Can we change this to some to-be-expanded entry point to generally test runCode functionality and can you therefore change the filename to runCode.js?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done ;)

@holgerd77 holgerd77 changed the title runCode.js: add pc to the runCode optional args runCode.js: add pc to runCode opt args | initial API tests Feb 12, 2019
@holgerd77 holgerd77 changed the title runCode.js: add pc to runCode opt args | initial API tests runCode.js: add pc to opt args | initial API tests Feb 12, 2019
Copy link
Member

@holgerd77 holgerd77 left a comment

Choose a reason for hiding this comment

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

Looks good!

@@ -108,6 +109,12 @@ module.exports = function (opts, cb) {

// iterate through the given ops until something breaks or we hit STOP
function runVm (err) {
// Check that the programCounter is in range. Does not overwrite the previous err, if any.
const pc = runState.programCounter
if (!err && pc !== 0 && (pc < 0 || pc >= runState.code.length)) {
Copy link
Member

Choose a reason for hiding this comment

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

Condition looks good.

})
})
})
})
Copy link
Member

Choose a reason for hiding this comment

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

Love this new test setup so so much 👍 😄 ✨, this makes the whole code execution so much more approachable and serves as some really valuable usage reference!

Also super transparent how to add on this, great basis for further tests, thanks a lot for the thorough work here!

@holgerd77 holgerd77 merged commit 57293c6 into ethereumjs:master Feb 12, 2019
@holgerd77
Copy link
Member

Do you need some release on this in any way?

@pinkiebell
Copy link
Contributor Author

@holgerd77 Not 'yet' 😄 . I start working on an interface in the next days to partly/fully solve #410, so I'm going to stick with my fork until that is solved 👍

@holgerd77
Copy link
Member

😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants