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

Add runTx API tests #352

Merged
merged 1 commit into from
Sep 25, 2018
Merged

Add runTx API tests #352

merged 1 commit into from
Sep 25, 2018

Conversation

s1na
Copy link
Contributor

@s1na s1na commented Sep 22, 2018

This PR is part of the series for adding API test coverage. It:

  • Adds tests for runTx.js
  • Modifies lib/runTx.js to add two validation checks. Furthermore it moves the check for populateCache flag to the beginning of function.
  • A test Related to populateCache fails. I'm not sure if the test case makes sense. I assumed runTx should run even when populateCache is false, the difference being that no cache is utilized. However, runTx fails because it tries to use cache nevertheless.
  • Moves createGenesis utility to utils.js file.

@holgerd77
Copy link
Member

Thanks, this already looks quite good. Would assume the same behavior as you for the no-cache case, think we have to look closer into that one.

@s1na
Copy link
Contributor Author

s1na commented Sep 24, 2018

I had a quick look, and it seems runTx is using stateManager.cache methods such as get and put in 8 occasions to look up and update accounts in the trie.

I'd probably use stateManager methods instead of directly using stateManager.cache, and move the populateCache option to stateManager, which would use cache or not underneath depending on the value of populateCache.

It seems this might be the direction that was intended, as stateManager does have methods getAccount and putAccount which call the cache methods. However, they don't support the flag to disable cache. Is this maybe work in progress?

@holgerd77
Copy link
Member

Can you comment out the current failing test with some commentary notes that this should pass (in a similar way) and then open a new issue where you describe what you wrote in the comment above?

Then we have this cleanly separated and can move on merging this PR.

Also, @mattdean-digicatapult should maybe have a comment on this, since he is the current state manager expert and is currently in the process of reworking this.

@mattdean-digicatapult
Copy link
Contributor

@s1na, there is work in progress on this. I've got a do-not-merge PR (#309) that is gradually being broken up and merged which will clean-up all these direct cache writes. There's still an open question as to how we handle the populateCache flag, but my preference is probably to remove it's usage from the rest of VM as it exposes the use of a cache as part of the stateManager interface.

@s1na
Copy link
Contributor Author

s1na commented Sep 24, 2018

Hey @mattdean-digicatapult :) great. I don't know the arguments for keeping populateCache, but what you say makes sense.

cb = opts
return cb(new Error('invalid input, opts must be provided'))
}

Copy link
Member

Choose a reason for hiding this comment

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

Ok.

if (!tx) {
return cb(new Error('invalid input, tx is required'))
}

Copy link
Member

Choose a reason for hiding this comment

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

Ok.

if (opts.populateCache === false) {
return cb()
}

Copy link
Member

Choose a reason for hiding this comment

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

Ok.

)

t.end()
})
Copy link
Member

Choose a reason for hiding this comment

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

Nice cases. In addition to all the failure cases, can you add one which actually passes?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh sorry, I was thinking the success case is thoroughly covered by the blockchain tests. You're right, there should be a success case.

Just added a simple one.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, I think it is better to have this explicitly defined rather than have this implicitly tested somewhere else. Thanks for adding!

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.

@holgerd77 holgerd77 merged commit 8a9e76e into ethereumjs:master Sep 25, 2018
@s1na s1na deleted the test/api-runTx branch September 25, 2018 12:29
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.

4 participants