diff --git a/Readme.md b/Readme.md index 7a2f74b..d67fe77 100644 --- a/Readme.md +++ b/Readme.md @@ -15,3 +15,27 @@ you will find the result in `./target/release` If you want to build the `Hati` server, you don't need to build this library separately. Just build the server and it will automatically include this lib +# Developing + +we recommend to use the nix environment, so that you will have +exactly the same environment as the developers. + +just enter the repository directory and run + +``` +nix develop +``` + +and everything should be done for you. + +## Git + +Please configure a pre-commit hook like the one in `var/git-pre-commit` + +``` +cp var/git-pre-commit .git/hooks/pre-commit +``` + +This will run `cargo test --offline` right before your commit, +to make sure that everything compiles and that the test pass + diff --git a/src/connection/handshake/tests.rs b/src/connection/handshake/tests.rs index 9530407..c5f84dd 100644 --- a/src/connection/handshake/tests.rs +++ b/src/connection/handshake/tests.rs @@ -8,11 +8,7 @@ use crate::{ fn test_handshake_dirsync_req() { let rand = enc::Random::new(); let secret = enc::Secret::new_rand(&rand); - let cipher_send = enc::sym::CipherSend::new( - enc::sym::CipherKind::XChaCha20Poly1305, - secret, - &rand, - ); + let cipher = enc::sym::CipherKind::XChaCha20Poly1305; let (_, exchange_key) = match enc::asym::KeyExchangeKind::X25519DiffieHellman.new_keypair(&rand) @@ -49,11 +45,7 @@ fn test_handshake_dirsync_req() { let mut bytes = Vec::::with_capacity(h_req.len()); bytes.resize(h_req.len(), 0); - h_req.serialize( - cipher_send.kind().nonce_len(), - cipher_send.kind().tag_len(), - &mut bytes, - ); + h_req.serialize(cipher.nonce_len(), cipher.tag_len(), &mut bytes); let mut deserialized = match Handshake::deserialize(&bytes) { Ok(deserialized) => deserialized, @@ -65,10 +57,9 @@ fn test_handshake_dirsync_req() { if let HandshakeData::DirSync(dirsync::DirSync::Req(r_a)) = &mut deserialized.data { - let enc_start = - r_a.encrypted_offset() + cipher_send.kind().nonce_len().0; + let enc_start = r_a.encrypted_offset() + cipher.nonce_len().0; if let Err(e) = r_a.data.deserialize_as_cleartext( - &bytes[enc_start..(bytes.len() - cipher_send.kind().tag_len().0)], + &bytes[enc_start..(bytes.len() - cipher.tag_len().0)], ) { assert!(false, "DirSync Req Inner serialize: {}", e.to_string()); } diff --git a/var/git-pre-commit b/var/git-pre-commit new file mode 100755 index 0000000..81ac843 --- /dev/null +++ b/var/git-pre-commit @@ -0,0 +1,4 @@ +#!/usr/bin/env bash + +RUSTFLAGS=-Awarnings exec cargo test --offline --profile dev +