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

internal/ethapi: add testcases for blobTx #27818

Merged
merged 20 commits into from
Aug 22, 2023

Conversation

jsvisa
Copy link
Contributor

@jsvisa jsvisa commented Jul 31, 2023

No description provided.

@jsvisa jsvisa marked this pull request as draft July 31, 2023 07:59
@jsvisa jsvisa marked this pull request as ready for review August 1, 2023 06:33
Signed-off-by: jsvisa <delweng@gmail.com>
Signed-off-by: jsvisa <delweng@gmail.com>
Signed-off-by: jsvisa <delweng@gmail.com>
Signed-off-by: jsvisa <delweng@gmail.com>
Signed-off-by: jsvisa <delweng@gmail.com>
Signed-off-by: jsvisa <delweng@gmail.com>
Signed-off-by: jsvisa <delweng@gmail.com>
Signed-off-by: jsvisa <delweng@gmail.com>
Signed-off-by: jsvisa <delweng@gmail.com>
Signed-off-by: jsvisa <delweng@gmail.com>
Signed-off-by: jsvisa <delweng@gmail.com>
Signed-off-by: jsvisa <delweng@gmail.com>
@jsvisa jsvisa changed the title internal/ethapi: getTransactionReceipt return blobGasUsed,blobGasPrice internal/ethapi: add testcases for blobTx Aug 19, 2023
@jsvisa
Copy link
Contributor Author

jsvisa commented Aug 19, 2023

@fjl ptal, thanks

@fjl
Copy link
Contributor

fjl commented Aug 19, 2023

It's good that you're adding tests, but I'm not so happy to have all of these test vectors inline as strings. If we ever change the API again, a lot of hand-editing will need to happen. So I would like to ask you, if you have time, to restructure these tests using testdata files. It can be done as follows:

  • In the test case struct, add a new string field with a name. This name can be used as the "test name", but also as the filename of a JSON file in testdata.
  • During test execution, if a special environment variable is set (e.g. GENERATE_TEST), the output that you are comparing against should be written to the testdata file. Use json.MarshalIndent to write a readable version.
  • If the environment variable is not set, the test should load the file and compare the text just like now.

@jsvisa
Copy link
Contributor Author

jsvisa commented Aug 19, 2023

It's good that you're adding tests, but I'm not so happy to have all of these test vectors inline as strings. If we ever change the API again, a lot of hand-editing will need to happen. So I would like to ask you, if you have time, to restructure these tests using testdata files. It can be done as follows:

  • In the test case struct, add a new string field with a name. This name can be used as the "test name", but also as the filename of a JSON file in testdata.

  • During test execution, if a special environment variable is set (e.g. GENERATE_TEST), the output that you are comparing against should be written to the testdata file. Use json.MarshalIndent to write a readable version.

  • If the environment variable is not set, the test should load the file and compare the text just like now.

Sounds good to me, I'll adjust them this weekend

Signed-off-by: jsvisa <delweng@gmail.com>
Signed-off-by: jsvisa <delweng@gmail.com>
Signed-off-by: jsvisa <delweng@gmail.com>
Signed-off-by: jsvisa <delweng@gmail.com>
Signed-off-by: jsvisa <delweng@gmail.com>
Signed-off-by: jsvisa <delweng@gmail.com>
@jsvisa
Copy link
Contributor Author

jsvisa commented Aug 20, 2023

@fjl, please take another look, thanks.

use the env variable WRITE_TEST_FILES from

if os.Getenv("WRITE_TEST_FILES") != "" {

jsvisa and others added 2 commits August 21, 2023 21:24
Co-authored-by: Martin Holst Swende <martin@swende.se>
Signed-off-by: jsvisa <delweng@gmail.com>
@fjl fjl merged commit 9f4a528 into ethereum:master Aug 22, 2023
1 check passed
@fjl fjl added this to the 1.13.0 milestone Aug 22, 2023
devopsbo3 pushed a commit to HorizenOfficial/go-ethereum that referenced this pull request Nov 10, 2023
Co-authored-by: Martin Holst Swende <martin@swende.se>
devopsbo3 added a commit to HorizenOfficial/go-ethereum that referenced this pull request Nov 10, 2023
devopsbo3 added a commit to HorizenOfficial/go-ethereum that referenced this pull request Nov 10, 2023
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.

3 participants