Skip to content

Commit

Permalink
feat: add support for 0.8.25 (#118)
Browse files Browse the repository at this point in the history
solc now ships universal macos binaries, so we no longer have to build
them for https://github.com/alloy-rs/solc-builds
  • Loading branch information
mattsse authored Mar 18, 2024
1 parent 2aa8410 commit 4f15d5a
Show file tree
Hide file tree
Showing 5 changed files with 156 additions and 35 deletions.
113 changes: 113 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
[<img alt="docs.rs" src="https://img.shields.io/docsrs/svm-rs/latest?color=66c2a5&label=docs-rs&style=for-the-badge" height="20">](https://docs.rs/svm-rs/latest/svm_lib/)
[<img alt="build status" src="https://img.shields.io/github/actions/workflow/status/roynalnaruto/svm-rs/ci.yml?branch=master&style=for-the-badge" height="20">](https://github.com/roynalnaruto/svm-rs/actions?query=branch%3Amaster)

This crate provides a cross-platform support for managing Solidity compiler versions.

## Install

From [crates.io](https://crates.io):
Expand Down
1 change: 1 addition & 0 deletions crates/svm-rs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ zip = "0.6"
rand = "0.8"
tempfile = "3.10"
tokio = { version = "1.36", features = ["rt-multi-thread", "macros"] }
serial_test = "3.0"

[features]
default = ["rustls", "cli", "solc"]
Expand Down
36 changes: 13 additions & 23 deletions crates/svm-rs/src/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,15 +234,13 @@ fn ensure_checksum(
#[cfg(test)]
mod tests {
use super::*;
use crate::{
platform::Platform,
releases::{all_releases, artifact_url},
};
use rand::seq::SliceRandom;

const LATEST: Version = Version::new(0, 8, 24);
#[allow(unused)]
const LATEST: Version = Version::new(0, 8, 25);

#[tokio::test]
#[serial_test::serial]
async fn test_install() {
let versions = all_releases(platform())
.await
Expand All @@ -255,6 +253,7 @@ mod tests {
}

#[cfg(feature = "blocking")]
#[serial_test::serial]
#[test]
fn blocking_test_install() {
let versions = crate::releases::blocking_all_releases(platform::platform())
Expand All @@ -265,6 +264,7 @@ mod tests {
}

#[tokio::test]
#[serial_test::serial]
async fn test_version() {
let version = "0.8.10".parse().unwrap();
install(&version).await.unwrap();
Expand All @@ -276,6 +276,7 @@ mod tests {
}

#[cfg(feature = "blocking")]
#[serial_test::serial]
#[test]
fn blocking_test_version() {
let version = "0.8.10".parse().unwrap();
Expand Down Expand Up @@ -307,25 +308,14 @@ mod tests {
t.await.unwrap().unwrap();
}

// ensures we can download the latest native solc for apple silicon
// ensures we can download the latest universal solc for apple silicon
#[tokio::test(flavor = "multi_thread")]
async fn can_download_latest_native_apple_silicon() {
let artifacts = all_releases(Platform::MacOsAarch64).await.unwrap();

let artifact = artifacts.releases.get(&LATEST).unwrap();
let download_url = artifact_url(
Platform::MacOsAarch64,
&LATEST,
artifact.to_string().as_str(),
)
.unwrap();

let expected_checksum = artifacts.get_checksum(&LATEST).unwrap();

let resp = reqwest::get(download_url).await.unwrap();
assert!(resp.status().is_success());
let binbytes = resp.bytes().await.unwrap();
ensure_checksum(&binbytes, &LATEST, &expected_checksum).unwrap();
#[cfg(all(target_os = "macos", target_arch = "aarch64"))]
async fn can_install_latest_native_apple_silicon() {
let solc = install(&LATEST).await.unwrap();
let output = Command::new(solc).arg("--version").output().unwrap();
let version = String::from_utf8_lossy(&output.stdout);
assert!(version.contains("0.8.25"), "{}", version);
}

// ensures we can download the latest native solc for linux aarch64
Expand Down
Loading

0 comments on commit 4f15d5a

Please sign in to comment.