Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ci #7

Merged
merged 3 commits into from
Nov 6, 2023
Merged

Ci #7

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
26 changes: 26 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
on: [push]

name: CI

jobs:
build_and_test:
name: Test Rust
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
- name: Cache target
uses: actions/cache@v2
env:
cache-name: cache-default-target-and-lockfile
with:
path: |
target
Cargo.lock
~/.rustup
key: ${{ env.cache-name }}-${{ hashFiles('**/Cargo.toml') }}
- run: cargo build --all-features
- run: cargo test --all-features -- --skip session
- run: cargo clippy -- -Dwarnings
12 changes: 5 additions & 7 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ async fn main() -> Result<(), Box<dyn Error>> {
if let Some(addr) = &address {
let remote: Multiaddr = addr.parse()?;
println!("Joining session at {addr}...");
while let Err(_) = swarm.dial(remote.clone()) {
while swarm.dial(remote.clone()).is_err() {
println!("Waiting for session to start at {addr}...");
sleep(Duration::from_millis(200)).await;
}
Expand Down Expand Up @@ -291,11 +291,11 @@ async fn main() -> Result<(), Box<dyn Error>> {
.map_err(|e| format!("Not a valid signature: {e}"))?;

verifying_key
.verify(&chunk, &signature)
.verify(chunk, &signature)
.map_err(|e| format!("Verification of msg sender failed: {e}"))?;

let chunk = private_key
.decrypt(Pkcs1v15Encrypt, &chunk)
.decrypt(Pkcs1v15Encrypt, chunk)
.map_err(|e| format!("failed to decrypt: {e}"))?;

let key_len = i64::from_be_bytes(chunk[..8].try_into().unwrap()) as usize;
Expand Down Expand Up @@ -359,10 +359,8 @@ async fn main() -> Result<(), Box<dyn Error>> {
continue;
};
if let Msg::Share { from, to, share } = msg.clone() {
if to == pub_key.clone() {
if participants.contains_key(&from) {
if to == pub_key.clone() && participants.contains_key(&from) {
received_shares.insert(from, share);
}
}
}
Event::Msg(msg)
Expand Down Expand Up @@ -418,7 +416,7 @@ async fn main() -> Result<(), Box<dyn Error>> {
println!("A new session has been started, others can join using the following command:");
println!(
"{} --address={addr} --name=<your_alias> --input=<file.json>",
std::env::args().nth(0).unwrap_or_else(|| "<bin>".into())
std::env::args().next().unwrap_or_else(|| "<bin>".into())
);
println!(
"\nPress ENTER to start the benchmark once all participants have joined."
Expand Down