-
Notifications
You must be signed in to change notification settings - Fork 773
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/tests: ensure verifyPostConditions works #1900
Conversation
Codecov Report
Flags with carried forward coverage won't be shown. Click here to find out more. |
Updated this one, sample messages:
There are some gotcha's in the diffs, will comment. |
@@ -144,14 +144,14 @@ export async function verifyPostConditions(state: any, testData: any, t: tape.Te | |||
const promise = verifyAccountPostConditions(state, address, account, testData, t) | |||
queue.push(promise) | |||
} else { | |||
t.fail('invalid account in the trie: ' + <string>key) | |||
t.comment('invalid account in the trie: ' + <string>key) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Converted all tape commands to comment
. The reason is that if you have failing tests, then this adds to the number of tests counter. Let's say we accidentally do not run some tests, then --verify-amount-alltests
flag could still pass while this is actually not the case.
Also note that if any of these comments get triggered, then the state root of the block is wrong, so the test fails anyways.
}) | ||
if (val !== hashedStorage[key]) { | ||
t.comment( | ||
`Expected storage key 0x${data.key.toString('hex')} at address ${address} to have value ${ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have to add address here since it is not clear when these promises are fulfilled.
@@ -188,38 +195,40 @@ export function verifyAccountPostConditions( | |||
] = acctData.storage[key] | |||
} | |||
|
|||
if (storageKeys.length > 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed this if statement: if there is no storage in the postState but we somehow still store something, then we should detect that anyways.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice, lgtm!
862fbb8
to
f3a28d2
Compare
Updated this via rebase (via Web UI). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
If a blockchain test fails and we have the
--debug
flag on, we expect that we doverifyPostConditions
:ethereumjs-monorepo/packages/vm/tests/tester/runners/BlockchainTestsRunner.ts
Line 171 in 0b7cc1b
However, this actually does not work. If the block is invalid and produces a different
stateRoot
than whatever we expect, thenrunBlockchain
actually throws and theverifyPostConditions
is never ran.This PR also updates the formatter such that it is easier to read what goes wrong. On a VM which I intentially made producing wrong output:
(Was done by adding this to
runBlock.ts
:)If the tests contain the postConditions we can now very quickly figure out what goes wrong if a test files 😄