Skip to content

Commit

Permalink
Merge branch 'main' into dht-hash
Browse files Browse the repository at this point in the history
  • Loading branch information
ThetaSinner committed Dec 10, 2024
2 parents 614ab5b + b8f6553 commit e0e7394
Show file tree
Hide file tree
Showing 9 changed files with 334 additions and 249 deletions.
32 changes: 24 additions & 8 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,44 @@ on:
- main

jobs:
test:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
fail-fast: false

runs-on: ${{ matrix.os }}
static:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- uses: taiki-e/install-action@v2
with:
tool: [email protected]

- uses: Swatinem/rust-cache@v2

- name: Toml format
run: make static-toml

- name: Format
run: make fmt

- name: Lint
run: make clippy

- name: Doc
if: matrix.os == 'ubuntu-latest'
run: make doc

test:
needs: static
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
fail-fast: false

runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v4

- uses: Swatinem/rust-cache@v2

- name: Build
run: make build

Expand All @@ -40,6 +55,7 @@ jobs:
name: "All Jobs Pass"
runs-on: "ubuntu-latest"
needs:
- static
- test
steps:
- name: check status
Expand Down
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@

all: fmt clippy doc test

static-toml:
taplo format --check

fmt:
cargo fmt --all -- --check

Expand Down
9 changes: 5 additions & 4 deletions crates/api/src/agent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,8 @@ pub struct AgentInfo {
pub url: Option<Url>,

/// The arc over which this agent claims authority.
pub storage_arc: BasicArc,
#[serde(default = "StorageArc::default")]
pub storage_arc: StorageArc,
}

/// Signed agent information.
Expand Down Expand Up @@ -304,7 +305,7 @@ mod test {
let now = Timestamp::from_micros(1731690797907204);
let later = Timestamp::from_micros(now.as_micros() + 72_000_000_000);
let url = Some(Url::from_str("ws://test.com:80/test-url").unwrap());
let storage_arc = Some((42, u32::MAX / 13));
let storage_arc = StorageArc::Arc(42, u32::MAX / 13);

let enc = AgentInfoSigned::sign(
&TestCrypto,
Expand All @@ -315,7 +316,7 @@ mod test {
expires_at: later,
is_tombstone: false,
url: url.clone(),
storage_arc,
storage_arc: storage_arc.clone(),
},
)
.await
Expand Down Expand Up @@ -347,7 +348,7 @@ mod test {
async fn fills_in_default_fields() {
let dec = AgentInfoSigned::decode(&TestCrypto, br#"{"agentInfo":"{\"agent\":\"dGVzdC1hZ2VudA\",\"space\":\"dGVzdC1zcGFjZQ\",\"createdAt\":\"1731690797907204\",\"expiresAt\":\"1731762797907204\",\"isTombstone\":false}","signature":"ZmFrZS1zaWduYXR1cmU"}"#).unwrap();
assert!(dec.url.is_none());
assert!(dec.storage_arc.is_none());
assert_eq!(StorageArc::Empty, dec.storage_arc);
}

#[tokio::test(flavor = "multi_thread")]
Expand Down
Loading

0 comments on commit e0e7394

Please sign in to comment.