-
Notifications
You must be signed in to change notification settings - Fork 479
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 a test to check the download of the latest version #648
base: master
Are you sure you want to change the base?
Conversation
Thanks for the PR! I'll take a closer look at it later but for now just wanted to say that Also, the coverage bot says the coverage decreased, which means you need to add some more tests. |
The coverage decrease seems to be because I separated the But I can add tests for it. However, maybe it would be better to mock the HTTP requests in those methods and pass the endpoint URL as parameter. What do you think? About the CI, the problem is that I'm getting the latest version based on the
Maybe I misunderstood the goal of the task. Should I not use the latest version in the |
Yeah, definitely. I actually think that in the JS tests we would be better off with mocks both for positive and negative case. I'd consider an actual download an integration test and for that we might just go all the way - i.e. have a CI job that executes the script and does the check in Bash rather than trying to do it in JS. But, well, I'm not against having that part in JS - it's not like other tests here are pure unit tests :) It's a bit of a mess so whatever works is fine. BTW, would mocking require adding some dependencies? We overall prefer to avoid too many deps - we have enough already and we should actually trim that even more.
Are you sure you're really getting the latest release version? |
Great. I will do that then. Mocking the JS tests and adding the integration test in the CI.
No, not necessarily. We can use the native HTTPS module of Node.js. So no new dependencies are needed :-)
I'm getting the current version from the package.json. See this line. And the released version is fetched from the "releases" entry in the list.json in this line. |
function getVersionList () { | ||
console.log('Retrieving available version list...'); | ||
|
||
return new Promise<string>((resolve, reject) => { |
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.
Any reason to directly use promises rather than async
/await
here?
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.
Yes. As far as I know the https.get
module from nodejs is not "awaitable" so I needed to wrap it in a promise and explicitly resolve the response.
return new Promise<string>((resolve, reject) => { | ||
const mem = new MemoryStream(null, { readable: false }); | ||
https.get('https://binaries.soliditylang.org/bin/list.json', function (response) { | ||
if (response.statusCode !== 200) { |
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.
It's something that has already been here before but we should change this so that anything between 200 and 299 is a success. I think we also have the same check in other places in the code
But I'd do it in a separate PR since it's a functional change, not just a refactor and is also unrelated to tests.
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.
response.ok
?
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.
I don't think the https
nodejs module has such ok
property. I know that the response object of the fecth API has it, but it is not what we are using here. However, we could mimic its behavior.
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.
Ah, you're right, I was actually looking at the fetch API when I made the comment.
Oh, you're right. Looks like the external test for solc-js that we have in the main repo actually bumps version in In any case, this just shows that this must be tested from the outside. I.e. we should not be assuming inside these JS tests that version in |
️✅ There are no secrets present in this pull request anymore.If these secrets were true positive and are still valid, we highly recommend you to revoke them. 🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request. |
I added the unit tests for I opened another PR #659 for the CI bash integration test. |
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.
I am actually learning JS/TS more than anything with this review, but here's my 2 cents :)
Co-authored-by: matheusaaguiar <[email protected]>
c24005f
to
ad40b4c
Compare
Co-authored-by: matheusaaguiar <[email protected]>
Co-authored-by: matheusaaguiar <[email protected]>
Co-authored-by: matheusaaguiar <[email protected]>
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.
This PR attempt to solve the issue #632. It adds a test to verify if the current version is equal to the downloaded one, and it also modifies the downloader script to enable its use in the tests.