Skip to content

Commit a0e0c49

Browse files
authored
Merge 48e01dd into 73ca073
2 parents 73ca073 + 48e01dd commit a0e0c49

File tree

13 files changed

+2463
-1042
lines changed

13 files changed

+2463
-1042
lines changed

.github/workflows/ci.yaml

Lines changed: 251 additions & 251 deletions
Large diffs are not rendered by default.

.github/workflows/tests.yaml

Lines changed: 58 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -139,64 +139,64 @@ jobs:
139139
fi
140140
cargo test --workspace --all-features --doc
141141
142-
build_and_test_windows:
143-
timeout-minutes: 30
144-
name: "Tests"
145-
runs-on: ${{ matrix.runner }}
146-
strategy:
147-
fail-fast: false
148-
matrix:
149-
name: [windows-latest]
150-
rust: [ '${{ inputs.rust-version}}' ]
151-
features: [all, none, default]
152-
target:
153-
- x86_64-pc-windows-msvc
154-
include:
155-
- name: windows-latest
156-
os: windows
157-
runner: [self-hosted, windows, x64]
158-
env:
159-
# Using self-hosted runners so use local cache for sccache and
160-
# not SCCACHE_GHA_ENABLED.
161-
RUSTC_WRAPPER: "sccache"
162-
steps:
163-
- name: Checkout
164-
uses: actions/checkout@v4
165-
with:
166-
ref: ${{ inputs.git-ref }}
167-
168-
- name: Install ${{ matrix.rust }}
169-
run: |
170-
rustup toolchain install ${{ matrix.rust }}
171-
rustup toolchain default ${{ matrix.rust }}
172-
rustup target add ${{ matrix.target }}
173-
rustup set default-host ${{ matrix.target }}
174-
175-
- name: Install cargo-nextest
176-
shell: powershell
177-
run: |
178-
$tmp = New-TemporaryFile | Rename-Item -NewName { $_ -replace 'tmp$', 'zip' } -PassThru
179-
Invoke-WebRequest -OutFile $tmp https://get.nexte.st/latest/windows
180-
$outputDir = if ($Env:CARGO_HOME) { Join-Path $Env:CARGO_HOME "bin" } else { "~/.cargo/bin" }
181-
$tmp | Expand-Archive -DestinationPath $outputDir -Force
182-
$tmp | Remove-Item
183-
184-
- name: Select features
185-
run: |
186-
switch ("${{ matrix.features }}") {
187-
"all" {
188-
echo "FEATURES=--all-features" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf8 -Append
189-
}
190-
"none" {
191-
echo "FEATURES=--no-default-features" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf8 -Append
192-
}
193-
"default" {
194-
echo "FEATURES=" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf8 -Append
195-
}
196-
default {
197-
Exit 1
198-
}
199-
}
142+
# build_and_test_windows:
143+
# timeout-minutes: 30
144+
# name: "Tests"
145+
# runs-on: ${{ matrix.runner }}
146+
# strategy:
147+
# fail-fast: false
148+
# matrix:
149+
# name: [windows-latest]
150+
# rust: [ '${{ inputs.rust-version}}' ]
151+
# features: [all, none, default]
152+
# target:
153+
# - x86_64-pc-windows-msvc
154+
# include:
155+
# - name: windows-latest
156+
# os: windows
157+
# runner: [self-hosted, windows, x64]
158+
# env:
159+
# # Using self-hosted runners so use local cache for sccache and
160+
# # not SCCACHE_GHA_ENABLED.
161+
# RUSTC_WRAPPER: "sccache"
162+
# steps:
163+
# - name: Checkout
164+
# uses: actions/checkout@v4
165+
# with:
166+
# ref: ${{ inputs.git-ref }}
167+
168+
# - name: Install ${{ matrix.rust }}
169+
# run: |
170+
# rustup toolchain install ${{ matrix.rust }}
171+
# rustup toolchain default ${{ matrix.rust }}
172+
# rustup target add ${{ matrix.target }}
173+
# rustup set default-host ${{ matrix.target }}
174+
175+
# - name: Install cargo-nextest
176+
# shell: powershell
177+
# run: |
178+
# $tmp = New-TemporaryFile | Rename-Item -NewName { $_ -replace 'tmp$', 'zip' } -PassThru
179+
# Invoke-WebRequest -OutFile $tmp https://get.nexte.st/latest/windows
180+
# $outputDir = if ($Env:CARGO_HOME) { Join-Path $Env:CARGO_HOME "bin" } else { "~/.cargo/bin" }
181+
# $tmp | Expand-Archive -DestinationPath $outputDir -Force
182+
# $tmp | Remove-Item
183+
184+
# - name: Select features
185+
# run: |
186+
# switch ("${{ matrix.features }}") {
187+
# "all" {
188+
# echo "FEATURES=--all-features" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf8 -Append
189+
# }
190+
# "none" {
191+
# echo "FEATURES=--no-default-features" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf8 -Append
192+
# }
193+
# "default" {
194+
# echo "FEATURES=" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf8 -Append
195+
# }
196+
# default {
197+
# Exit 1
198+
# }
199+
# }
200200

201201
- name: Install sccache
202202
uses: mozilla-actions/sccache-action@v0.0.9

Cargo.lock

Lines changed: 22 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ testresult = "0.4.1"
5858
tracing-subscriber = { version = "0.3.19", features = ["fmt"] }
5959
tracing-test = "0.2.5"
6060
walkdir = "2.5.0"
61+
atomic_refcell = "0.1.13"
6162
iroh = { version = "0.90", features = ["discovery-local-network"]}
6263

6364
[features]

src/api/remote.rs

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1064,8 +1064,15 @@ mod tests {
10641064
use testresult::TestResult;
10651065

10661066
use crate::{
1067+
api::blobs::Blobs,
10671068
protocol::{ChunkRangesSeq, GetRequest},
1068-
store::fs::{tests::INTERESTING_SIZES, FsStore},
1069+
store::{
1070+
fs::{
1071+
tests::{create_n0_bao, test_data, INTERESTING_SIZES},
1072+
FsStore,
1073+
},
1074+
mem::MemStore,
1075+
},
10691076
tests::{add_test_hash_seq, add_test_hash_seq_incomplete},
10701077
util::ChunkRangesExt,
10711078
};
@@ -1117,6 +1124,38 @@ mod tests {
11171124
Ok(())
11181125
}
11191126

1127+
async fn test_observe_partial(blobs: &Blobs) -> TestResult<()> {
1128+
let sizes = INTERESTING_SIZES;
1129+
for size in sizes {
1130+
let data = test_data(size);
1131+
let ranges = ChunkRanges::chunk(0);
1132+
let (hash, bao) = create_n0_bao(&data, &ranges)?;
1133+
blobs.import_bao_bytes(hash, ranges.clone(), bao).await?;
1134+
let bitfield = blobs.observe(hash).await?;
1135+
if size > 1024 {
1136+
assert_eq!(bitfield.ranges, ranges);
1137+
} else {
1138+
assert_eq!(bitfield.ranges, ChunkRanges::all());
1139+
}
1140+
}
1141+
Ok(())
1142+
}
1143+
1144+
#[tokio::test]
1145+
async fn test_observe_partial_mem() -> TestResult<()> {
1146+
let store = MemStore::new();
1147+
test_observe_partial(store.blobs()).await?;
1148+
Ok(())
1149+
}
1150+
1151+
#[tokio::test]
1152+
async fn test_observe_partial_fs() -> TestResult<()> {
1153+
let td = tempfile::tempdir()?;
1154+
let store = FsStore::load(td.path()).await?;
1155+
test_observe_partial(store.blobs()).await?;
1156+
Ok(())
1157+
}
1158+
11201159
#[tokio::test]
11211160
async fn test_local_info_hash_seq() -> TestResult<()> {
11221161
let sizes = INTERESTING_SIZES;

src/hash.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ impl From<&[u8; 32]> for Hash {
111111

112112
impl PartialOrd for Hash {
113113
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
114-
Some(self.0.as_bytes().cmp(other.0.as_bytes()))
114+
Some(self.cmp(other))
115115
}
116116
}
117117

src/metrics.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use iroh_metrics::{Counter, MetricsGroup};
44

55
/// Enum of metrics for the module
66
#[allow(missing_docs)]
7+
#[allow(dead_code)]
78
#[derive(Debug, Default, MetricsGroup)]
89
#[metrics(name = "iroh-blobs")]
910
pub struct Metrics {

0 commit comments

Comments
 (0)