Ensure metadata is in sync with running node during tests (#333)

* add test-runtime crate to dynamically obtain metadata/node_runtime for tests

* cargo fmt

* Download substrate prior to cargo calls (hopefully)

* add README explaining test-runtime

* Fix CI, fmt and clippy

* more clippy

* tweak test-node readme

* fmt the clippied

* A little tidy up in build.rs

* use ureq and raw string

* Don't export unnecessary metadata

* async_std/RpcClient/bytes instead of ureq/Value/hex

* newline

* document try_from_url error unwrap
This commit is contained in:
James Wilson
2021-11-29 09:39:40 +00:00
committed by GitHub
parent 7e26f9559c
commit 4b9ee133ac
11 changed files with 200 additions and 20 deletions
+1 -1
View File
@@ -15,9 +15,9 @@
// along with subxt. If not, see <http://www.gnu.org/licenses/>.
use crate::{
runtime::node_runtime::system,
test_node_process,
test_node_process_with,
utils::node_runtime::system,
};
use sp_core::storage::{
+1 -2
View File
@@ -15,7 +15,6 @@
// along with subxt. If not, see <http://www.gnu.org/licenses/>.
mod codegen;
mod runtime;
mod utils;
#[cfg(test)]
@@ -23,5 +22,5 @@ mod client;
#[cfg(test)]
mod frame;
pub use runtime::node_runtime;
pub use test_runtime::node_runtime;
pub use utils::*;
Binary file not shown.
-26
View File
@@ -1,26 +0,0 @@
// Copyright 2019-2021 Parity Technologies (UK) Ltd.
// This file is part of subxt.
//
// subxt is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// subxt is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with subxt. If not, see <http://www.gnu.org/licenses/>.
#![allow(clippy::too_many_arguments)]
#[subxt::subxt(
runtime_metadata_path = "tests/integration/node_runtime.scale",
generated_type_derives = "Debug, Eq, PartialEq"
)]
pub mod node_runtime {
#[subxt(substitute_type = "sp_arithmetic::per_things::Perbill")]
use sp_runtime::Perbill;
}
+2 -6
View File
@@ -64,13 +64,9 @@ where
/// Attempt to kill the running substrate process.
pub fn kill(&mut self) -> Result<(), String> {
log::info!("Killing contracts node process {}", self.proc.id());
log::info!("Killing node process {}", self.proc.id());
if let Err(err) = self.proc.kill() {
let err = format!(
"Error killing contracts node process {}: {}",
self.proc.id(),
err
);
let err = format!("Error killing node process {}: {}", self.proc.id(), err);
log::error!("{}", err);
return Err(err)
}