Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions crates/pop-chains/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,9 @@ tokio_test::block_on(async {
let release = true; // Whether the binary should be built using the release profile.
let status = {}; // Mechanism to observe status updates
let verbose = false; // Whether verbose output is required
let missing = zombienet.binaries();
for binary in missing {
binary.source(release, &status, verbose).await;
let missing = zombienet.archives();
for archive in missing {
archive.source(release, &status, verbose).await;
}
})
```
Expand Down
219 changes: 219 additions & 0 deletions crates/pop-chains/artifacts/paseo-local.json

Large diffs are not rendered by default.

21 changes: 13 additions & 8 deletions crates/pop-chains/src/bench/binary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ use pop_common::{
git::GitHub,
polkadot_sdk::sort_by_latest_stable_version,
sourcing::{
ArchiveFileSpec, Binary,
ArchiveFileSpec, ArchiveType,
GitHub::*,
Source,
Source, SourcedArchive,
filters::prefix,
traits::{
Source as SourceT,
Expand Down Expand Up @@ -36,7 +36,7 @@ impl SourceT for BenchmarkingCli {
fn source(&self) -> Result<Source, Error> {
// Source from GitHub release asset
let repo = GitHub::parse(self.repository())?;
let binary = self.binary();
let binary = self.binary()?;
Ok(Source::GitHub(ReleaseArchive {
owner: repo.org,
repository: repo.name,
Expand All @@ -60,15 +60,20 @@ impl SourceT for BenchmarkingCli {
pub async fn omni_bencher_generator(
cache: PathBuf,
version: Option<&str>,
) -> Result<Binary, Error> {
) -> Result<SourcedArchive, Error> {
let cli = BenchmarkingCli::OmniBencher;
let name = cli.binary().to_string();
let name = cli.binary()?.to_string();
let source = cli
.source()?
.resolve(&name, version, cache.as_path(), |f| prefix(f, &name))
.await
.into();
let binary = Binary::Source { name, source, cache: cache.to_path_buf() };
let binary = SourcedArchive::Source {
name,
source,
cache: cache.to_path_buf(),
archive_type: ArchiveType::Binary,
};
Ok(binary)
}

Expand All @@ -83,7 +88,7 @@ mod tests {
let temp_dir_path = temp_dir.path().to_path_buf();
let version = "polkadot-stable2412-4";
let binary = omni_bencher_generator(temp_dir_path.clone(), Some(version)).await?;
assert!(matches!(binary, Binary::Source { name: _, source, cache }
assert!(matches!(binary, SourcedArchive::Source { name: _, source, cache, archive_type }
if source == Source::GitHub(ReleaseArchive {
owner: "r0gue-io".to_string(),
repository: "polkadot".to_string(),
Expand All @@ -96,7 +101,7 @@ mod tests {
contents: ["frame-omni-bencher"].map(|b| ArchiveFileSpec::new(b.into(), Some(b.into()), true)).to_vec(),
latest: binary.latest().map(|l| l.to_string()),
}).into() &&
cache == temp_dir_path.as_path()
cache == temp_dir_path.as_path() && archive_type == ArchiveType::Binary
));
Ok(())
}
Expand Down
10 changes: 5 additions & 5 deletions crates/pop-chains/src/build/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -894,12 +894,12 @@ edition = "2021"
Some(&vec!["https://github.com/r0gue-io/pop-node#node-v0.3.0".to_string()]),
)
.await?;
let mut binary_name: String = "".to_string();
for binary in zombienet.binaries().filter(|b| !b.exists() && b.name() == "pop-node") {
binary_name = format!("{}-{}", binary.name(), binary.version().unwrap());
binary.source(true, &(), true).await?;
let mut archive_name: String = "".to_string();
for archive in zombienet.archives().filter(|b| !b.exists() && b.name() == "pop-node") {
archive_name = format!("{}-{}", archive.name(), archive.version().unwrap());
archive.source(true, &(), true).await?;
}
Ok(binary_name)
Ok(archive_name)
}

// Replace the binary fetched with the mocked binary
Expand Down
5 changes: 5 additions & 0 deletions crates/pop-chains/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,8 @@ const PASSET_HUB_SPEC_JSON: &str = include_str!("../artifacts/passet-hub-spec.js
fn get_passet_hub_spec_content() -> &'static str {
PASSET_HUB_SPEC_JSON
}

const PASEO_SPEC_JSON: &str = include_str!("../artifacts/paseo-local.json");
fn get_paseo_spec_content() -> &'static str {
PASEO_SPEC_JSON
}
22 changes: 14 additions & 8 deletions crates/pop-chains/src/omni_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ use pop_common::{
git::GitHub,
polkadot_sdk::sort_by_latest_semantic_version,
sourcing::{
ArchiveFileSpec, Binary,
ArchiveFileSpec, ArchiveType,
GitHub::*,
Source,
Source, SourcedArchive,
filters::prefix,
traits::{
Source as SourceT,
Expand Down Expand Up @@ -37,7 +37,7 @@ impl SourceT for PolkadotOmniNodeCli {
fn source(&self) -> Result<Source, Error> {
// Source from GitHub release asset
let repo = GitHub::parse(self.repository())?;
let binary = self.binary();
let binary = self.binary()?;
Ok(Source::GitHub(ReleaseArchive {
owner: repo.org,
repository: repo.name,
Expand All @@ -61,15 +61,20 @@ impl SourceT for PolkadotOmniNodeCli {
pub async fn polkadot_omni_node_generator(
cache: PathBuf,
version: Option<&str>,
) -> Result<Binary, Error> {
) -> Result<SourcedArchive, Error> {
let cli = PolkadotOmniNodeCli::PolkadotOmniNode;
let name = cli.binary().to_string();
let name = cli.binary()?.to_string();
let source = cli
.source()?
.resolve(&name, version, cache.as_path(), |f| prefix(f, &name))
.await
.into();
let binary = Binary::Source { name, source, cache: cache.to_path_buf() };
let binary = SourcedArchive::Source {
name,
source,
cache: cache.to_path_buf(),
archive_type: ArchiveType::Binary,
};
Ok(binary)
}

Expand Down Expand Up @@ -132,9 +137,10 @@ mod tests {
let binary = polkadot_omni_node_generator(cache.path().to_path_buf(), None).await?;

match binary {
Binary::Source { name, source, cache: cache_path } => {
SourcedArchive::Source { name, source, cache: cache_path, archive_type } => {
assert_eq!(name, "polkadot-omni-node");
assert_eq!(cache_path, cache.path());
assert_eq!(archive_type, ArchiveType::Binary);
// Source should be a ResolvedRelease
match *source {
Source::GitHub(github) =>
Expand All @@ -144,7 +150,7 @@ mod tests {
_ => panic!("Expected GitHub variant"),
}
},
_ => panic!("Expected Binary::Source variant"),
_ => panic!("Expected SourcedArchive::Source variant"),
}

Ok(())
Expand Down
24 changes: 16 additions & 8 deletions crates/pop-chains/src/try_runtime/binary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ use pop_common::{
git::GitHub,
polkadot_sdk::sort_by_latest_semantic_version,
sourcing::{
ArchiveFileSpec, Binary,
ArchiveFileSpec, ArchiveType,
GitHub::*,
Source,
Source, SourcedArchive,
filters::prefix,
traits::{
Source as SourceT,
Expand Down Expand Up @@ -35,7 +35,7 @@ impl SourceT for TryRuntimeCli {
fn source(&self) -> Result<Source, Error> {
// Source from GitHub release asset
let repo = GitHub::parse(self.repository())?;
let binary = self.binary();
let binary = self.binary()?;
Ok(Source::GitHub(ReleaseArchive {
owner: repo.org,
repository: repo.name,
Expand All @@ -56,15 +56,23 @@ impl SourceT for TryRuntimeCli {
/// # Arguments
/// * `cache` - The path to the directory where the binary should be cached.
/// * `version` - An optional version string. If `None`, the latest available version is used.
pub async fn try_runtime_generator(cache: PathBuf, version: Option<&str>) -> Result<Binary, Error> {
pub async fn try_runtime_generator(
cache: PathBuf,
version: Option<&str>,
) -> Result<SourcedArchive, Error> {
let cli = TryRuntimeCli::TryRuntime;
let name = cli.binary().to_string();
let name = cli.binary()?.to_string();
let source = cli
.source()?
.resolve(&name, version, cache.as_path(), |f| prefix(f, &name))
.await
.into();
let binary = Binary::Source { name, source, cache: cache.to_path_buf() };
let binary = SourcedArchive::Source {
name,
source,
cache: cache.to_path_buf(),
archive_type: ArchiveType::Binary,
};
Ok(binary)
}

Expand All @@ -79,7 +87,7 @@ mod tests {
let path = temp_dir.path().to_path_buf();
let version = "v0.8.0";
let binary = try_runtime_generator(path.clone(), None).await?;
assert!(matches!(binary, Binary::Source { name: _, source, cache }
assert!(matches!(binary, SourcedArchive::Source { name: _, source, cache, archive_type}
if source == Source::GitHub(ReleaseArchive {
owner: "r0gue-io".to_string(),
repository: "try-runtime-cli".to_string(),
Expand All @@ -92,7 +100,7 @@ mod tests {
contents: ["try-runtime-cli"].map(|b| ArchiveFileSpec::new(b.into(), Some(b.into()), true)).to_vec(),
latest: binary.latest().map(|l| l.to_string()),
}).into() &&
cache == path
cache == path && archive_type == ArchiveType::Binary
));
Ok(())
}
Expand Down
Loading
Loading