From d1e78cc68a63c3803524bd4bbec953dc75a11e96 Mon Sep 17 00:00:00 2001
From: Hugo Trentesaux <hugo@trentesaux.fr>
Date: Mon, 22 May 2023 13:20:12 +0200
Subject: [PATCH] add embeded client spec and genesis in binary

(this re-buids chainspecs at each run)
---
 node/src/command.rs | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/node/src/command.rs b/node/src/command.rs
index bd16a8f0f..4d4047c20 100644
--- a/node/src/command.rs
+++ b/node/src/command.rs
@@ -150,18 +150,26 @@ impl SubstrateCli for Cli {
                         .map_err(|e| format!("failed to read {JSON_GENESIS} {e}"))?[..],
                 )
                 .map_err(|e| format!("failed to parse {e}"))?;
+                // rebuild chainspecs from these files
                 Box::new(chain_spec::gtest::live_chainspecs(
                     client_spec,
                     genesis_data,
                 )?)
             }
-            // hardcoded previously generated raw chainspecs
+            // return hardcoded live chainspecs
+            // embed client spec and genesis to avoid embeding hexadecimal runtime
+            // and having hexadecimal runtime in git history
             #[cfg(feature = "gtest")]
             "gtest" => {
-                unimplemented!();
-                // Box::new(chain_spec::gtest::ChainSpec::from_json_bytes(
-                //     &include_bytes!("../specs/gtest-raw.json")[..],
-                // )?)
+                let client_spec: gtest::ClientSpec =
+                    serde_json::from_slice(include_bytes!("../specs/gtest_client-specs.json"))
+                        .unwrap();
+                let genesis_data: gtest_genesis::GenesisJson =
+                    serde_json::from_slice(include_bytes!("../specs/gtest_genesis.json")).unwrap();
+                Box::new(chain_spec::gtest::live_chainspecs(
+                    client_spec,
+                    genesis_data,
+                )?)
             }
             // === G1 ===
             #[cfg(feature = "g1")]
-- 
GitLab