Add contracts config for test_config
@@ -44,13 +44,6 @@ pub struct EIP1271Config {
pub contract_address: Address,
}
-impl EIP1271Config {
- pub fn load() -> Self {
- let object = merge_configs("eip1271.json");
- serde_json::from_value(object).expect("Cannot deserialize EIP1271 test config")
- }
-}
-
/// Common Ethereum parameters.
#[derive(Debug, Deserialize)]
pub struct EthConfig {
@@ -58,13 +51,6 @@ pub struct EthConfig {
pub web3_url: String,
}
-impl EthConfig {
- pub fn load() -> Self {
- let object = load_json(&config_path("constant/eth.json"));
- serde_json::from_value(object).expect("Cannot deserialize Ethereum test config")
- }
-}
-
/// Common Api addresses.
#[derive(Debug, Deserialize)]
pub struct ApiConfig {
@@ -72,18 +58,42 @@ pub struct ApiConfig {
pub rest_api_url: String,
}
-impl ApiConfig {
+/// Config for Contracts.
+#[derive(Debug, Deserialize)]
+pub struct ContractsConfig {
+ /// Address of the rest api.
+ pub test_mnemonic: String,
+}
+
+impl EIP1271Config {
+ pub fn load() -> Self {
+ let object = merge_configs("eip1271.json");
+ serde_json::from_value(object).expect("Cannot deserialize EIP1271 test config")
+ }
+}
+
+macro_rules! impl_config {
+ ($name_config:ident, $file:tt) => {
+ impl $name_config {
pub fn load() -> Self {
- let object = load_json(&config_path("constant/api.json"));
- serde_json::from_value(object).expect("Cannot deserialize Api test config")
+ let object = load_json(&config_path(&format!("{}.json", $file)));
+ serde_json::from_value(object)
+ .expect(&format!("Cannot deserialize config from '{}'", $file))
+ }
}
+ };
}
+impl_config!(ApiConfig, "constant/api");
+impl_config!(EthConfig, "constant/eth");
+impl_config!(ContractsConfig, "constant/contracts");
+
#[derive(Debug)]
pub struct TestConfig {
pub eip1271: EIP1271Config,
pub eth: EthConfig,
pub api: ApiConfig,
+ pub contracts: ContractsConfig,
}
impl TestConfig {
@@ -92,6 +102,7 @@ impl TestConfig {
eip1271: EIP1271Config::load(),
eth: EthConfig::load(),
api: ApiConfig::load(),
+ contracts: ContractsConfig::load(),
}
}
}
