-
Notifications
You must be signed in to change notification settings - Fork 241
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
Problem: there are duplicated hard coded informations in integration tests #233
Conversation
I will fix the the bugs and lint asap. But it is ok to review first. |
Codecov Report
@@ Coverage Diff @@
## main #233 +/- ##
==========================================
+ Coverage 21.51% 25.29% +3.77%
==========================================
Files 27 34 +7
Lines 1729 2554 +825
==========================================
+ Hits 372 646 +274
- Misses 1324 1858 +534
- Partials 33 50 +17
Continue to review full report at Codecov.
|
fb82424
to
900240b
Compare
there are still linter issues |
For the lint issues, you can configure |
@yihuang I just configured it. Should be ok now. |
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 think we should support the expansion feature in pystarport
directly, so people can still use pystarport serve --config scripts/devnet.yaml
in cli directly.
ok, I'll change a little bit. By the way the PR here crypto-com/pystarport#37 |
If that one is merged, we don't need to do the expansion here right? |
@yihuang Yes, but I still need to do some modifications on this PR. |
why?
|
the |
This can be solved by overriding the |
Good idea, I can also try parameterise it. |
cfd4bbf
to
68675b5
Compare
Now change the expansion code to pystarport. But The commit uses the test version of pystarport, need to finish and merge crypto-com/pystarport#37, before continuing. |
6c2a29e
to
4d63980
Compare
1. Scritps 2. yaml 3. Python files
After crypto-com/pystarport#37, would change back to crypto-com/pystarport.
Test the expansion feature
3c285d4
to
f85ee81
Compare
nix/default.nix
Outdated
cronos-config = ../scripts/cronos-devnet.yaml; | ||
hermes-config = ../scripts/hermes.toml; | ||
geth-genesis = ../scripts/geth-genesis.json; | ||
chainmain-config = builtins.toString ../scripts/chainmain-devnet.yaml; |
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.
Why the builtins.toString
call?
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 is necessary to get the full path of the file (string), instead of copying to nix store. https://github.com/crypto-org-chain/cronos/blob/main/nix/scripts.nix#L15: if we use ../scripts/cronos-devnet.yaml
and .env
, then quote it with ${config.cronos-config}
will copy to nix store.
Not copying to nix sotre has following benefits:
- Read
.env
with relative path just under the projectscript
folder. - In nix-shell environment, if we modify the
cronos-devnet.yaml
, we can callstart-cronos
directly without exiting the nix-shell and re-enter the nix-shell.
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.
start-cronos
Before:
#!/nix/store/c9cxq1583a85bsq76q2rbnbiwwp7ygxr-bash-4.4-p23/bin/bash
# rely on environment to provide cronosd
export PATH=/nix/store/f347n055kzsyq30m41x481dpsq0zbip1-python3.8-pystarport-0.2.2/bin:$PATH
source /nix/store/ym2jzjqjmzf7azjkc8m9jd4vy0qjrx5p-dotenv
/nix/store/zhicf2wijlr36315xx1nxq5bhh6q90qs-start-cronos /nix/store/k0mfjv85j0sjbfjj6lisriwq3pkzcsqi-cronos-devnet.yaml $@
After:
#!/nix/store/c9cxq1583a85bsq76q2rbnbiwwp7ygxr-bash-4.4-p23/bin/bash
# rely on environment to provide cronosd
export PATH=/nix/store/fjm893gw3z5yd3f3vsabb5vw2my1dvd2-python3.8-pystarport-0.2.3/bin:$PATH
source /Users/damonchen/Documents/cronos/scripts/.env
/nix/store/zhicf2wijlr36315xx1nxq5bhh6q90qs-start-cronos /Users/damonchen/Documents/cronos/scripts/cronos-devnet.yaml $@
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.
Then you don't get the reproducibility with these scripts.
In development, you can always run ./scripts/start-cronos config data
explicitly.
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 see, treat it like a fixed binary. Let me think a more thoughtful idea.
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.
But seems no documents here, user would not know start-cronos
exists. The binary is not useful because it only works in nix-shell
. Even me, I don't use it at all.
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.
Of course, it is important in integration test. Just not that useful for users, assuming they do not have nix
installed.
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.
start-cronos
and start-geth
are only used to start cronos and geth devnets with the identical environment, to run cronos devnet with custom config, one can always use pystarport
directly, the scripts/start-cronos
is only a thin wrapper over that.
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.
Two TODOs here:
- Make all
ShellScriptBin
reproducible. And add documents if possible. - Improve all scripts. E.g. So that user knows they can use
dotenv
option as well.
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.
These scripts are not intended to be used by user, so just keep it simple here, only start-geth
is useful for normal user, the other scripts are thin wrappers of pystarport
.
We can even remove start-chainmain
and start-cronos
, and simply use pystarport
directly.
and remove deepdiff dependency.
It is more general and work with full path as well
374671f
to
571639a
Compare
This makes these two script-bins defined in `scripts.nix` always use the same yaml and dotenv file, for metting the "re-producibility" requirement during one/same `nix-shell` environment. These script-bins are wrappers of pystarport with fixed yaml and dotenv. If you want to create the cronos/chainmain instance with different configurations, you should avoid using the script-bins. Please run the scripts directly, or use `pystarport` step by step. Besides, if you change the yaml or dotenv, you need to exit and re-enter the nix-shell. So that the modified yaml or dotenv are copied to nix store, and their paths can be rewritten into these two script-bins.
571639a
to
3416c76
Compare
👮🏻👮🏻👮🏻 !!!! REFERENCE THE PROBLEM YOUR ARE SOLVING IN THE PR TITLE AND DESCRIBE YOUR SOLUTION HERE !!!! DO NOT FORGET !!!! 👮🏻👮🏻👮🏻
Close #10
This PR adds the following features:
.env
file which consolidates all keys/mnemonic words/address etc. Scripts, python files, and all yamls can read the.env
file to expand the keys/mnemonic words/address etcPlease merge crypto-com/pystarport#37 first.
PR Checklist:
make
)make test
)go fmt
)golangci-lint run
)go list -json -m all | nancy sleuth
)Thank you for your code, it's appreciated! :)