Skip to content
This repository has been archived by the owner on Jun 25, 2021. It is now read-only.

Commit

Permalink
Merge pull request #2203 from madadam/more-tests
Browse files Browse the repository at this point in the history
More tests
  • Loading branch information
madadam committed Oct 12, 2020
2 parents c721976 + 2891f53 commit 425be3b
Show file tree
Hide file tree
Showing 9 changed files with 603 additions and 1,092 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ async-recursion = "0.3.1"
bincode = "1.2.1"
bls = { package = "threshold_crypto", version = "~0.4.0" }
bls_dkg = "~0.2.0"
bls_signature_aggregator = { git = "https://github.com/madadam/bls_signature_aggregator.git", branch = "repetition" }
bls_signature_aggregator = "~0.1.4"
bytes = "~0.5.4"
crossbeam-channel = { version = "~0.4.2", optional = true }
ctrlc = { version = "3", optional = true, features = ["termination"] }
Expand Down
27 changes: 18 additions & 9 deletions src/messages/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ use std::fmt::{self, Debug, Formatter};
use xor_name::Prefix;

/// Message sent over the network.
#[derive(Clone, Eq, PartialEq, Serialize, Deserialize)]
#[derive(Clone, Eq, Serialize, Deserialize)]
pub(crate) struct Message {
/// Source authority.
/// Messages do not need to sign this field as it is all verifiable (i.e. if the sig validates
Expand Down Expand Up @@ -148,22 +148,19 @@ impl Message {
/// Creates a signed message from a section.
/// Note: `signature` isn't verified and is assumed valid.
pub(crate) fn section_src(
src: Prefix,
plain: PlainMessage,
signature: bls::Signature,
dst: DstLocation,
variant: Variant,
proof_chain: SectionProofChain,
dst_key: bls::PublicKey,
) -> Result<Self, CreateError> {
Self::new_signed(
SrcAuthority::Section {
prefix: src,
prefix: plain.src,
signature,
},
dst,
variant,
plain.dst,
plain.variant,
Some(proof_chain),
Some(dst_key),
Some(plain.dst_key),
)
}

Expand Down Expand Up @@ -278,6 +275,18 @@ impl Message {
}
}

// Ignore `serialized` and `hash` fields because they are only computed from the other fields and
// in some cases might be even absent.
impl PartialEq for Message {
fn eq(&self, other: &Self) -> bool {
self.src == other.src
&& self.dst == other.dst
&& self.variant == other.variant
&& self.proof_chain == other.proof_chain
&& self.dst_key == other.dst_key
}
}

impl Debug for Message {
fn fmt(&self, formatter: &mut Formatter) -> fmt::Result {
formatter
Expand Down
4 changes: 0 additions & 4 deletions src/node/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ use self::{
executor::Executor,
stage::{Approved, Bootstrapping, Comm, NodeInfo, Stage},
};
#[cfg(all(test, feature = "mock"))]
use crate::section::SectionKeyShare;
use crate::{
crypto::{Keypair, PublicKey},
error::{Error, Result},
Expand All @@ -36,8 +34,6 @@ use crate::{
};
use bytes::Bytes;
use itertools::Itertools;
#[cfg(feature = "mock")]
use std::collections::BTreeSet;
use std::{net::SocketAddr, sync::Arc};
use tokio::sync::mpsc;
use xor_name::{Prefix, XorName};
Expand Down
11 changes: 2 additions & 9 deletions src/node/stage/approved.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1269,14 +1269,7 @@ impl Approved {
proof_chain: SectionProofChain,
proof: Proof,
) -> Result<Command> {
let message = Message::section_src(
message.src,
proof.signature,
message.dst,
message.variant,
proof_chain,
message.dst_key,
)?;
let message = Message::section_src(message, proof.signature, proof_chain)?;

Ok(Command::HandleMessage {
message,
Expand Down Expand Up @@ -1392,7 +1385,7 @@ impl Approved {

if new_is_elder {
info!(
"Section updated: prefix: ({:b}), key: {:?}, elders: {:?}",
"Section updated: prefix: ({:b}), key: {:?}, elders: {}",
self.shared_state.our_prefix(),
self.shared_state.our_history.last_key(),
self.shared_state.our_info().elders.values().format(", ")
Expand Down
277 changes: 0 additions & 277 deletions src/node/tests/adult.rs

This file was deleted.

0 comments on commit 425be3b

Please sign in to comment.