-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #22 from multiversx/chain-simulator-custom-configs…
…-remade Chain simulator custom configs
- Loading branch information
Showing
16 changed files
with
364 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# OverridableConfigTomlValues represents an array of items to be overloaded inside other configuration files, which can be helpful | ||
# so that certain config values need to remain the same during upgrades. | ||
# (for example, an Elasticsearch user wants external.toml->ElasticSearchConnector.Enabled to remain true all the time during upgrades, while the default | ||
# configuration of the node has the false value) | ||
# The Path indicates what value to change, while Value represents the new value in string format. The node operator must make sure | ||
# to follow the same type of the original value (ex: uint32: "37", float32: "37.0", bool: "true") | ||
# File represents the file name that holds the configuration. Currently, the supported files are: | ||
# api.toml, config.toml, economics.toml, enableEpochs.toml, enableRounds.toml, external.toml, fullArchiveP2P.toml, p2p.toml, ratings.toml, systemSmartContractsConfig.toml | ||
# ------------------------------- | ||
# Un-comment and update the following section in order to enable config values overloading | ||
# ------------------------------- | ||
# OverridableConfigTomlValues = [ | ||
# { File = "config.toml", Path = "StoragePruning.NumEpochsToKeep", Value = "4" }, | ||
# { File = "config.toml", Path = "MiniBlocksStorage.Cache.Name", Value = "MiniBlocksStorage" }, | ||
# { File = "external.toml", Path = "ElasticSearchConnector.Enabled", Value = "true" } | ||
#] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package config | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/multiversx/mx-chain-go/config" | ||
"github.com/pelletier/go-toml" | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestLoadNodeOverrideConfigs(t *testing.T) { | ||
t.Parallel() | ||
|
||
testString := ` | ||
# Test comment | ||
OverridableConfigTomlValues = [ | ||
{ File = "config.toml", Path = "A", Value = "B" }, | ||
{ File = "external.toml", Path = "C", Value = "D" } | ||
] | ||
` | ||
|
||
expectedConfig := OverrideConfigs{ | ||
OverridableConfigTomlValues: []config.OverridableConfig{ | ||
{ | ||
File: "config.toml", | ||
Path: "A", | ||
Value: "B", | ||
}, | ||
{ | ||
File: "external.toml", | ||
Path: "C", | ||
Value: "D", | ||
}, | ||
}, | ||
} | ||
|
||
cfg := OverrideConfigs{} | ||
|
||
err := toml.Unmarshal([]byte(testString), &cfg) | ||
assert.Nil(t, err) | ||
assert.Equal(t, expectedConfig, cfg) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import sys | ||
|
||
from multiversx_sdk_network_providers import ProxyNetworkProvider | ||
|
||
SIMULATOR_URL = "http://localhost:8085" | ||
GENERATE_BLOCKS_UNTIL_EPOCH_REACHED_URL = f"{SIMULATOR_URL}/simulator/generate-blocks-until-epoch-reached" | ||
NETWORK_STATUS_URL = f"{SIMULATOR_URL}/network/status/4294967295" | ||
|
||
|
||
def main(): | ||
# create a network provider | ||
provider = ProxyNetworkProvider(SIMULATOR_URL) | ||
|
||
targetEpoch = 10 | ||
# generate blocks until we reach the target epoch | ||
provider.do_post(f"{GENERATE_BLOCKS_UNTIL_EPOCH_REACHED_URL}/{targetEpoch}", {}) | ||
|
||
network_status = provider.get_network_status() # will default to metachain | ||
|
||
if network_status.epoch_number < targetEpoch: | ||
sys.exit(f"epoch {targetEpoch} not reached") | ||
|
||
print(f"successfully created blocks and epoch {targetEpoch} was reached") | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.