Skip to content

Commit 3371e8c

Browse files
author
Damon Chen
committed
Test expansion
Test the expansion feature
1 parent 68675b5 commit 3371e8c

File tree

7 files changed

+213
-3
lines changed

7 files changed

+213
-3
lines changed

integration_tests/poetry.lock

Lines changed: 31 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

integration_tests/pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ python-dateutil = "^2.8.1"
2020
web3 = "^5.20.1"
2121
eth-bloom = "^1.0.4"
2222
python-dotenv = "^0.19.2"
23-
pystarport = {git = "https://github.com/damoncro/pystarport", rev = "feature/expansion"}
23+
pystarport = {git = "https://github.com/damoncro/pystarport.git", rev = "feature/expansion"}
24+
deepdiff = "^5.6.0"
2425

2526
[tool.poetry.dev-dependencies]
2627

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
export VALIDATOR_KEY='826E479F5385C8C32CD96B0C0ACCDB8CC4FA5CACCC1BE54C1E3AA4D676A6EFF5'
2+
export COMMUNITY_KEY='5D665FBD2FB40CB8E9849263B04457BA46D5F948972D0FE4C1F19B6B0F243574'
3+
export PASSWORD='123456'
4+
export VALIDATOR2_MNEMONIC="visit craft resemble online window solution west chuckle music diesel vital settle comic tribe project blame bulb armed flower region sausage mercy arrive release"
5+
export VALIDATOR1_MNEMONIC="direct travel shrug hand twice agent sail sell jump phone velvet pilot mango charge usual multiply orient garment bleak virtual action mention panda vast"
6+
export COMMUNITY_MNEMONIC="notable error gospel wave pair ugly measure elite toddler cost various fly make eye ketchup despair slab throw tribe swarm word fruit into inmate"
7+
export SIGNER1_MNEMONIC="shed crumble dismiss loyal latin million oblige gesture shrug still oxygen custom remove ribbon disorder palace addict again blanket sad flock consider obey popular"
8+
export SIGNER2_MNEMONIC="night renew tonight dinner shaft scheme domain oppose echo summer broccoli agent face guitar surface belt veteran siren poem alcohol menu custom crunch index"
9+
export CRONOS_ADMIN="crc12luku6uxehhak02py4rcz65zu0swh7wjsrw0pp"
10+
export IBC_CRO_DENOM="ibc/6411AE2ADA1E73DB59DB151A8988F9B7D5E7E233D8414DB6817F8F1A01611F86"
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
export VALIDATOR_KEY='826E479F5385C8C32CD96B0C0ACCDB8CC4FA5CACCC1BE54C1E3AA4D676A6EFF5'
2+
export COMMUNITY_KEY='5D665FBD2FB40CB8E9849263B04457BA46D5F948972D0FE4C1F19B6B0F243574'
3+
export PASSWORD='123456'
4+
export VALIDATOR1_MNEMONIC="good"
5+
export VALIDATOR2_MNEMONIC="direct travel shrug hand twice agent sail sell jump phone velvet pilot mango charge usual multiply orient garment bleak virtual action mention panda vast"
6+
export COMMUNITY_MNEMONIC="notable error gospel wave pair ugly measure elite toddler cost various fly make eye ketchup despair slab throw tribe swarm word fruit into inmate"
7+
export SIGNER1_MNEMONIC="shed crumble dismiss loyal latin million oblige gesture shrug still oxygen custom remove ribbon disorder palace addict again blanket sad flock consider obey popular"
8+
export SIGNER2_MNEMONIC="night renew tonight dinner shaft scheme domain oppose echo summer broccoli agent face guitar surface belt veteran siren poem alcohol menu custom crunch index"
9+
export CRONOS_ADMIN="crc12luku6uxehhak02py4rcz65zu0swh7wjsrw0pp"
10+
export IBC_CRO_DENOM="ibc/6411AE2ADA1E73DB59DB151A8988F9B7D5E7E233D8414DB6817F8F1A01611F86"
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
cronos_777-1:
2+
cmd: cronosd
3+
start-flags: "--trace"
4+
app-config:
5+
minimum-gas-prices: 5000000000000basetcro
6+
json-rpc:
7+
address: "0.0.0.0:{EVMRPC_PORT}"
8+
ws-address: "0.0.0.0:{EVMRPC_PORT_WS}"
9+
validators:
10+
- coins: 1000000000000000000stake,10000000000000000000000basetcro
11+
staked: 1000000000000000000stake
12+
mnemonic: visit craft resemble online window solution west chuckle music diesel vital settle comic tribe project blame bulb armed flower region sausage mercy arrive release
13+
- coins: 1000000000000000000stake,10000000000000000000000basetcro
14+
staked: 1000000000000000000stake
15+
mnemonic: direct travel shrug hand twice agent sail sell jump phone velvet pilot mango charge usual multiply orient garment bleak virtual action mention panda vast
16+
accounts:
17+
- name: community
18+
coins: 10000000000000000000000basetcro
19+
mnemonic: "notable error gospel wave pair ugly measure elite toddler cost various fly make eye ketchup despair slab throw tribe swarm word fruit into inmate"
20+
- name: signer1
21+
coins: 20000000000000000000000basetcro
22+
mnemonic: shed crumble dismiss loyal latin million oblige gesture shrug still oxygen custom remove ribbon disorder palace addict again blanket sad flock consider obey popular
23+
- name: signer2
24+
coins: 30000000000000000000000basetcro
25+
mnemonic: night renew tonight dinner shaft scheme domain oppose echo summer broccoli agent face guitar surface belt veteran siren poem alcohol menu custom crunch index
26+
27+
genesis:
28+
consensus_params:
29+
block:
30+
max_bytes: "1048576"
31+
max_gas: "81500000"
32+
app_state:
33+
evm:
34+
params:
35+
evm_denom: basetcro
36+
cronos:
37+
params:
38+
cronos_admin: crc12luku6uxehhak02py4rcz65zu0swh7wjsrw0pp
39+
enable_auto_deployment: true
40+
ibc_cro_denom: ibc/6411AE2ADA1E73DB59DB151A8988F9B7D5E7E233D8414DB6817F8F1A01611F86
41+
gov:
42+
voting_params:
43+
voting_period: "10s"
44+
deposit_params:
45+
max_deposit_period: "10s"
46+
min_deposit:
47+
- denom: "basetcro"
48+
amount: "1"
49+
transfer:
50+
params:
51+
receive_enabled: true
52+
send_enabled: true
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
dotenv: .env
2+
cronos_777-1:
3+
cmd: cronosd
4+
start-flags: "--trace"
5+
app-config:
6+
minimum-gas-prices: 5000000000000basetcro
7+
json-rpc:
8+
address: "0.0.0.0:{EVMRPC_PORT}"
9+
ws-address: "0.0.0.0:{EVMRPC_PORT_WS}"
10+
validators:
11+
- coins: 1000000000000000000stake,10000000000000000000000basetcro
12+
staked: 1000000000000000000stake
13+
mnemonic: ${VALIDATOR1_MNEMONIC}
14+
- coins: 1000000000000000000stake,10000000000000000000000basetcro
15+
staked: 1000000000000000000stake
16+
mnemonic: ${VALIDATOR2_MNEMONIC}
17+
accounts:
18+
- name: community
19+
coins: 10000000000000000000000basetcro
20+
mnemonic: ${COMMUNITY_MNEMONIC}
21+
- name: signer1
22+
coins: 20000000000000000000000basetcro
23+
mnemonic: ${SIGNER1_MNEMONIC}
24+
- name: signer2
25+
coins: 30000000000000000000000basetcro
26+
mnemonic: ${SIGNER2_MNEMONIC}
27+
28+
genesis:
29+
consensus_params:
30+
block:
31+
max_bytes: "1048576"
32+
max_gas: "81500000"
33+
app_state:
34+
evm:
35+
params:
36+
evm_denom: basetcro
37+
cronos:
38+
params:
39+
cronos_admin: ${CRONOS_ADMIN}
40+
enable_auto_deployment: true
41+
ibc_cro_denom: ${IBC_CRO_DENOM}
42+
gov:
43+
voting_params:
44+
voting_period: "10s"
45+
deposit_params:
46+
max_deposit_period: "10s"
47+
min_deposit:
48+
- denom: "basetcro"
49+
amount: "1"
50+
transfer:
51+
params:
52+
receive_enabled: true
53+
send_enabled: true
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
import os
2+
from pathlib import Path
3+
4+
import yaml
5+
from deepdiff import DeepDiff
6+
from pystarport.expansion import expand_yaml
7+
8+
9+
def test_expansion():
10+
template_with_dotenv = Path(__file__).parent / "template_with_dotenv.yaml"
11+
template_no_dotenv = Path(__file__).parent / "template_no_dotenv.yaml"
12+
13+
# `expand_yaml` is backward compatible, not expanded, and no diff
14+
assert yaml.safe_load(open(template_no_dotenv)) == expand_yaml(
15+
template_no_dotenv, None
16+
)
17+
18+
# `expand_yaml` is expanded but no diff
19+
assert not DeepDiff(
20+
yaml.safe_load(open(template_no_dotenv)),
21+
expand_yaml(template_with_dotenv, None),
22+
ignore_order=True,
23+
)
24+
25+
# overriding dotenv with relative path is expanded and has diff)
26+
assert DeepDiff(
27+
yaml.safe_load(open(template_no_dotenv)),
28+
expand_yaml(template_with_dotenv, ".env1"),
29+
ignore_order=True,
30+
) == {
31+
"values_changed": {
32+
"root['cronos_777-1']['validators'][0]['mnemonic']": {
33+
"new_value": "good",
34+
"old_value": "visit craft resemble online window solution west chuckle "
35+
"music diesel vital settle comic tribe project blame bulb armed flower "
36+
"region sausage mercy arrive release",
37+
}
38+
}
39+
}
40+
41+
# overriding dotenv with absolute path is expanded and has diff
42+
assert DeepDiff(
43+
yaml.safe_load(open(template_no_dotenv)),
44+
expand_yaml(template_with_dotenv, os.path.abspath("test_expansion/.env1")),
45+
ignore_order=True,
46+
) == {
47+
"values_changed": {
48+
"root['cronos_777-1']['validators'][0]['mnemonic']": {
49+
"new_value": "good",
50+
"old_value": "visit craft resemble online window solution west chuckle "
51+
"music diesel vital settle comic tribe project blame bulb armed flower "
52+
"region sausage mercy arrive release",
53+
}
54+
}
55+
}

0 commit comments

Comments
 (0)