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

VM: New test for runTX return values #1213

Merged
merged 3 commits into from
Apr 22, 2021

Conversation

emersonmacro
Copy link
Contributor

Added a new test for default return values in runTx.spec.ts (testing the non-optional fields in RunTxResult).

I'm still getting my head wrapped around the code and testing practices for this project, so feedback is most definitely welcome.

@codecov
Copy link

codecov bot commented Apr 21, 2021

Codecov Report

Merging #1213 (907691a) into master (7f3a533) will decrease coverage by 0.14%.
The diff coverage is n/a.

Impacted file tree graph

Flag Coverage Δ
block 79.77% <ø> (-0.40%) ⬇️
blockchain 84.16% <ø> (-0.07%) ⬇️
client 83.80% <ø> (-0.25%) ⬇️
common 86.87% <ø> (-0.53%) ⬇️
devp2p 84.27% <ø> (ø)
ethash 82.08% <ø> (ø)
tx 82.26% <ø> (-0.22%) ⬇️
vm 81.34% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

@holgerd77
Copy link
Member

Have updated this branch.

@holgerd77
Copy link
Member

@emersonmacro thanks for the PR, this looks actually pretty good already, great! 😄

Will leave this open for now for some discussion around the runTx() result format.

res.receipt.gasUsed,
res.gasUsed.toArrayLike(Buffer),
`runTx result -> receipt.gasUsed -> result.gasUsed as Buffer (${txType.name})`
)
Copy link
Member

Choose a reason for hiding this comment

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

This is actually not so beautiful that we here return the gasUsed as a Buffer and on the upper level as a BN value. 🙄 Should we add this to the list of breaking changes for v6 #1024 for an update (to BN I guess) or is there some reasoning here I overlook? //cc @ryanio

Copy link
Contributor

Choose a reason for hiding this comment

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

ah yes I think we should update it to return a BN.

in general here I'd say that instead of using t.deepEqual we should use BN's eq method, so for example t.ok(res.gasUsed.eq(new BN(res.receipt.gasUsed)))

I also like to do this with Buffers as well: t.ok(buffer1.equals(buffer2))

Copy link
Member

Choose a reason for hiding this comment

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

Is this encompassing more checks or stricter or what's the reasoning for this?

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.

LGTM, thanks!

@holgerd77 holgerd77 merged commit e8f46ff into ethereumjs:master Apr 22, 2021
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.

3 participants