Skip to content
Merged
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
25 changes: 25 additions & 0 deletions ci/build-channel/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -451,4 +451,29 @@ mod tests {
("forc", "forc-crypto-0.71.0", "forc-crypto")
);
}

#[test]
fn test_forc_node_url_generation() {
let forc_node = Component::from_name("forc-node").unwrap();

// Legacy version (< 0.71.0) should use sway repo with forc-binaries tarball
let legacy = Version::new(0, 70, 1);
let repo = forc_node.repository_for_version(&legacy);
let tag = forc_node.tag_for_version(&legacy);
let prefix = forc_node.tarball_prefix_for_version(&legacy);
assert_eq!(
(repo, tag.as_str(), prefix),
("sway", "v0.70.1", "forc-binaries")
);

// Migrated version (>= 0.71.0) should use forc repo with forc-node tarball
let migrated = Version::new(0, 71, 0);
let repo = forc_node.repository_for_version(&migrated);
let tag = forc_node.tag_for_version(&migrated);
let prefix = forc_node.tarball_prefix_for_version(&migrated);
assert_eq!(
(repo, tag.as_str(), prefix),
("forc", "forc-node-0.71.0", "forc-node")
);
}
}
73 changes: 72 additions & 1 deletion component/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ impl Component {
pub fn tag_for_version(&self, version: &Version) -> String {
let repo = self.repository_for_version(version);
match (self.name.as_str(), repo) {
("forc-wallet", "forc") | ("forc-crypto", "forc") => {
("forc-wallet", "forc") | ("forc-crypto", "forc") | ("forc-node", "forc") => {
format!("{}-{}", self.name, version)
}
_ => format!("v{}", version),
Expand Down Expand Up @@ -563,6 +563,77 @@ mod tests {
);
}

#[test]
fn test_repository_for_version_forc_node_migration() {
let components = Components::collect().unwrap();
let forc_node = components
.component
.get("forc-node")
.expect("forc-node component must exist");

let legacy = Version::new(0, 70, 1);
let migrated = Version::new(0, 71, 0);

assert_eq!(
forc_node.repository_for_version(&legacy),
"sway",
"pre-0.71.0 forc-node versions should use the sway repository"
);
assert_eq!(
forc_node.repository_for_version(&migrated),
"forc",
"0.71.0+ forc-node versions should use the forc monorepo"
);
}

#[test]
fn test_tarball_prefix_for_version_forc_node_migration() {
let components = Components::collect().unwrap();
let forc_node = components
.component
.get("forc-node")
.expect("forc-node component must exist");

let legacy = Version::new(0, 70, 1);
let migrated = Version::new(0, 71, 0);

assert_eq!(
forc_node.tarball_prefix_for_version(&legacy),
"forc-binaries",
"pre-0.71.0 forc-node was bundled in forc-binaries"
);
assert_eq!(
forc_node.tarball_prefix_for_version(&migrated),
"forc-node",
"0.71.0+ forc-node has its own tarball"
);
}

#[test]
fn test_tag_for_version_forc_node_migration() {
let components = Components::collect().unwrap();
let forc_node = components
.component
.get("forc-node")
.expect("forc-node component must exist");

// Legacy versions (< 0.71.0) should use standard v-prefixed tags
let legacy = Version::new(0, 70, 1);
assert_eq!(
forc_node.tag_for_version(&legacy),
"v0.70.1",
"Legacy forc-node versions should use v-prefixed tags"
);

// New versions (>= 0.71.0) in forc repo should use forc-node-prefixed tags
let migrated = Version::new(0, 71, 0);
assert_eq!(
forc_node.tag_for_version(&migrated),
"forc-node-0.71.0",
"Migrated forc-node versions should use forc-node-prefixed tags"
);
}

#[test]
fn test_tag_for_version_standard_components() {
let components = Components::collect().unwrap();
Expand Down
8 changes: 6 additions & 2 deletions components.toml
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,15 @@ targets = ["linux_amd64", "linux_arm64", "darwin_amd64", "darwin_arm64"]

[component.forc-node]
name = "forc-node"
tarball_prefix = "forc-binaries"
tarball_prefix = "forc-node"
is_plugin = true
executables = ["forc-node"]
repository_name = "sway"
repository_name = "forc"
legacy_repository_name = "sway"
legacy_before = "0.71.0"
legacy_tarball_prefix = "forc-binaries"
targets = ["linux_amd64", "linux_arm64", "darwin_amd64", "darwin_arm64"]
publish = true

[component.forc-publish]
name = "forc-publish"
Expand Down
Loading