Skip to content

Commit b4b1944

Browse files
4677: Re-generate chainspec.toml for EE test support r=jacek-casper a=jacek-casper chainspec.toml.in is now packaged with the test support crate (instead of a symlink to to chainspec.toml) and a small build script was added to generate a local chainspec automatically during a cargo build. Closes casper-network/casper-sidecar#285. Co-authored-by: Jacek Malec <[email protected]>
2 parents 84c8668 + f90a6a5 commit b4b1944

File tree

6 files changed

+48
-2
lines changed

6 files changed

+48
-2
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,8 @@ resources/production/*.wasm
133133
resources/node-storage/*
134134
resources/local/chainspec.toml
135135

136+
execution_engine_testing/test_support/resources/chainspec.toml
137+
136138
# CLion
137139
.idea/
138140
cmake-build-debug/

Cargo.lock

Lines changed: 13 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

execution_engine_testing/test_support/Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ toml = "0.5.6"
3232
casper-types = { version = "5.0.0", path = "../../types", features = ["std"] }
3333
version-sync = "0.9.3"
3434

35+
[build-dependencies]
36+
toml_edit = "=0.21.0"
37+
humantime = "2"
38+
3539
[features]
3640
use-as-wasm = []
3741

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
use humantime::format_rfc3339;
2+
use std::{
3+
env, fs,
4+
path::Path,
5+
time::{Duration, SystemTime},
6+
};
7+
use toml_edit::{value, Document};
8+
9+
fn main() {
10+
let manifest_dir = env::var("CARGO_MANIFEST_DIR").unwrap();
11+
let input_chainspec = Path::new(&manifest_dir)
12+
.join("resources")
13+
.join("chainspec.toml.in");
14+
let output_chainspec = Path::new(&manifest_dir)
15+
.join("resources")
16+
.join("chainspec.toml");
17+
18+
println!("cargo:rerun-if-changed={}", input_chainspec.display());
19+
20+
let toml = fs::read_to_string(input_chainspec).expect("could not read chainspec.toml.in");
21+
let mut doc = toml
22+
.parse::<Document>()
23+
.expect("invalid document in chainspec.toml.in");
24+
let activation_point = SystemTime::now() + Duration::from_secs(40);
25+
doc["protocol"]["activation_point"] = value(format_rfc3339(activation_point).to_string());
26+
27+
fs::write(output_chainspec, doc.to_string()).expect("could not write chainspec.toml");
28+
}

execution_engine_testing/test_support/resources/chainspec.toml

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../resources/local/chainspec.toml.in

0 commit comments

Comments
 (0)