Skip to content

Commit

Permalink
fix(node): make session message decoding backwards-compatible
Browse files Browse the repository at this point in the history
  • Loading branch information
aesedepece committed Nov 21, 2023
1 parent 0426669 commit 157f0cd
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions node/src/actors/session/handlers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@ use witnet_data_structures::{
Block, CheckpointBeacon, Epoch, Hashable, InventoryEntry, InventoryItem, SuperBlock,
SuperBlockVote,
},
proto::ProtobufConvert,
proto::versioning::Versioned,
transaction::Transaction,
types::{
Address, Command, InventoryAnnouncement, InventoryRequest, LastBeacon,
Message as WitnetMessage, Peers, Version,
},
};
use witnet_p2p::sessions::{SessionStatus, SessionType};
use witnet_util::timestamp::get_timestamp;

use super::Session;
use crate::actors::{
chain_manager::ChainManager,
inventory_manager::InventoryManager,
Expand All @@ -39,7 +39,7 @@ use crate::actors::{
sessions_manager::SessionsManager,
};

use witnet_util::timestamp::get_timestamp;
use super::Session;

#[derive(Debug, Eq, Fail, PartialEq)]
enum HandshakeError {
Expand Down Expand Up @@ -133,7 +133,7 @@ impl StreamHandler<Result<BytesMut, Error>> for Session {
}

let bytes = res.unwrap();
let result = WitnetMessage::from_pb_bytes(&bytes);
let result = WitnetMessage::from_versioned_pb_bytes(&bytes);

match result {
Err(err) => {
Expand Down Expand Up @@ -1105,9 +1105,10 @@ fn process_superblock_vote(_session: &mut Session, superblock_vote: SuperBlockVo

#[cfg(test)]
mod tests {
use super::*;
use witnet_data_structures::chain::Hash;

use super::*;

#[test]
fn handshake_bootstrap_before_epoch_zero() {
// Check that when the last beacon has epoch 0 and the current epoch is not 0,
Expand Down

0 comments on commit 157f0cd

Please sign in to comment.