mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 05:17:58 +00:00
Bump to latest scale-encode/decode/value and fix test running (#1103)
* Bump to latest scale-encode,decode,value and fix test running * remove patch deps * update CI to spit out 'substrate-node' binary now * fmt * Fix test: compact type ID no longer present so can't re-encode Value in same way * remove patch * Fix cargo.lock * Fix other compact test
This commit is contained in:
@@ -6,21 +6,16 @@ pub(crate) use crate::{node_runtime, utils::TestNodeProcess};
|
||||
|
||||
use subxt::SubstrateConfig;
|
||||
|
||||
/// substrate node should be installed on the $PATH
|
||||
const SUBSTRATE_NODE_PATH: &str = "substrate";
|
||||
/// `substrate-node` should be installed on the $PATH. We fall back
|
||||
/// to also checking for an older `substrate` binary.
|
||||
const SUBSTRATE_NODE_PATHS: &str = "substrate-node,substrate";
|
||||
|
||||
pub async fn test_context_with(authority: String) -> TestContext {
|
||||
let path = std::env::var("SUBSTRATE_NODE_PATH").unwrap_or_else(|_| {
|
||||
if which::which(SUBSTRATE_NODE_PATH).is_err() {
|
||||
panic!(
|
||||
"A substrate binary should be installed on your path for integration tests. \
|
||||
See https://github.com/paritytech/subxt/tree/master#integration-testing"
|
||||
)
|
||||
}
|
||||
SUBSTRATE_NODE_PATH.to_string()
|
||||
});
|
||||
let paths =
|
||||
std::env::var("SUBSTRATE_NODE_PATH").unwrap_or_else(|_| SUBSTRATE_NODE_PATHS.to_string());
|
||||
let paths: Vec<_> = paths.split(',').map(|p| p.trim()).collect();
|
||||
|
||||
let mut proc = TestContext::build(path.as_str());
|
||||
let mut proc = TestContext::build(&paths);
|
||||
proc.with_authority(authority);
|
||||
proc.spawn::<SubstrateConfig>().await.unwrap()
|
||||
}
|
||||
|
||||
@@ -26,11 +26,11 @@ where
|
||||
R: Config,
|
||||
{
|
||||
/// Construct a builder for spawning a test node process.
|
||||
pub fn build<S>(program: S) -> TestNodeProcessBuilder
|
||||
pub fn build<P>(paths: &[P]) -> TestNodeProcessBuilder
|
||||
where
|
||||
S: AsRef<OsStr> + Clone,
|
||||
P: AsRef<OsStr> + Clone,
|
||||
{
|
||||
TestNodeProcessBuilder::new(program)
|
||||
TestNodeProcessBuilder::new(paths)
|
||||
}
|
||||
|
||||
/// Returns the subxt client connected to the running node.
|
||||
@@ -48,17 +48,24 @@ where
|
||||
|
||||
/// Construct a test node process.
|
||||
pub struct TestNodeProcessBuilder {
|
||||
node_path: OsString,
|
||||
node_paths: Vec<OsString>,
|
||||
authority: Option<String>,
|
||||
}
|
||||
|
||||
impl TestNodeProcessBuilder {
|
||||
pub fn new<P>(node_path: P) -> TestNodeProcessBuilder
|
||||
pub fn new<P>(node_paths: &[P]) -> TestNodeProcessBuilder
|
||||
where
|
||||
P: AsRef<OsStr>,
|
||||
{
|
||||
// Check that paths are valid and build up vec.
|
||||
let mut paths = Vec::new();
|
||||
for path in node_paths {
|
||||
let path = path.as_ref();
|
||||
paths.push(path.to_os_string())
|
||||
}
|
||||
|
||||
Self {
|
||||
node_path: node_path.as_ref().into(),
|
||||
node_paths: paths,
|
||||
authority: None,
|
||||
}
|
||||
}
|
||||
@@ -76,7 +83,7 @@ impl TestNodeProcessBuilder {
|
||||
{
|
||||
let mut node_builder = SubstrateNode::builder();
|
||||
|
||||
node_builder.binary_paths(&[self.node_path]);
|
||||
node_builder.binary_paths(&self.node_paths);
|
||||
|
||||
if let Some(authority) = &self.authority {
|
||||
node_builder.arg(authority.to_lowercase());
|
||||
|
||||
Reference in New Issue
Block a user