Add the git pre-commit hook
Signed-off-by: Luca Fulchir <luca.fulchir@runesauth.com>
This commit is contained in:
parent
e2874451d1
commit
a32dfe098f
24
Readme.md
24
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
|
||||
|
||||
|
|
|
@ -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::<u8>::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());
|
||||
}
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
RUSTFLAGS=-Awarnings exec cargo test --offline --profile dev
|
||||
|
Loading…
Reference in New Issue