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
Don't load .env in test environment #928
Don't load .env in test environment #928
Conversation
Codecov Report
@@ Coverage Diff @@
## develop #928 +/- ##
===========================================
- Coverage 51.65% 51.63% -0.02%
===========================================
Files 432 432
Lines 7200 7202 +2
Branches 924 925 +1
===========================================
Hits 3719 3719
- Misses 3049 3050 +1
- Partials 432 433 +1
Continue to review full report at Codecov.
|
If this is a travis specific issue you should use |
@faustbrian It's not an issue with travis, since there's no If the container reads an Another solution would be to change |
If we no longer load the .env file for testnet the local testing can become quite painful. I have an .env file that I use to store all my testnet configuration that I copy between local and server so I can always have the exact same config. I will take a closer look when I am back tomorrow. |
if (process.env.ARK_ENV === 'test') { | ||
return | ||
} | ||
|
||
const envPath = expandHomeDir(`${process.env.ARK_PATH_DATA}/.env`) | ||
|
||
if (fs.existsSync(envPath)) { |
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.
Shouldn't this already prevent the loading of any file if it doesn't exist?
Codecov Report
@@ Coverage Diff @@
## develop #928 +/- ##
===========================================
- Coverage 52.71% 52.71% -0.01%
===========================================
Files 436 436
Lines 7280 7282 +2
Branches 940 941 +1
===========================================
+ Hits 3838 3839 +1
Misses 3014 3014
- Partials 428 429 +1
Continue to review full report at Codecov.
|
Proposed changes
The
~/.ark/.env
doesn't exist on Travis, so it makes sense to not even attempt to load itwhen
ARK_ENV=test
is true.This fixes an issue I ran into when running tests (core-forger) locally:
Since the container loaded my
.env
and thus setARK_P2P_PORT
to4002
, which causedprocess.env.ARK_P2P_PORT || 4000
fromcore/lib/config/testnet/plugins.js
to return the wrong port.Checklist