Skip to content

Commit

Permalink
Merge #4835
Browse files Browse the repository at this point in the history
4835: Implement Entity and Package information requests r=EdHastingsCasperAssociation a=jacek-casper

Adds 2 new requests with handling for pre-migration and post-migration states for legacy data and corresponding tests.

Co-authored-by: Jacek Malec <[email protected]>
Co-authored-by: edhastings <[email protected]>
  • Loading branch information
3 people authored Sep 5, 2024
2 parents 520e58e + 96622aa commit 83cda94
Show file tree
Hide file tree
Showing 13 changed files with 1,873 additions and 536 deletions.
6 changes: 3 additions & 3 deletions binary_port/src/binary_response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use casper_types::{
use crate::{
binary_response_header::BinaryResponseHeader,
error_code::ErrorCode,
payload_type::{PayloadEntity, PayloadType},
response_type::{PayloadEntity, ResponseType},
};

#[cfg(test)]
Expand Down Expand Up @@ -40,7 +40,7 @@ impl BinaryResponse {

/// Creates new binary response from raw bytes.
pub fn from_raw_bytes(
payload_type: PayloadType,
payload_type: ResponseType,
payload: Vec<u8>,
protocol_version: ProtocolVersion,
) -> Self {
Expand All @@ -59,7 +59,7 @@ impl BinaryResponse {
BinaryResponse::new_error(ErrorCode::InternalError, protocol_version),
|payload| BinaryResponse {
payload,
header: BinaryResponseHeader::new(Some(V::PAYLOAD_TYPE), protocol_version),
header: BinaryResponseHeader::new(Some(V::RESPONSE_TYPE), protocol_version),
},
)
}
Expand Down
8 changes: 4 additions & 4 deletions binary_port/src/binary_response_and_request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use casper_types::{

use crate::{
binary_response::BinaryResponse, original_request_context::OriginalRequestContext,
payload_type::PayloadEntity, PayloadType,
response_type::PayloadEntity, ResponseType,
};

use crate::record_id::RecordId;
Expand Down Expand Up @@ -37,14 +37,14 @@ impl BinaryResponseAndRequest {
}
}

/// Returns a new binary response with specified data and no original request.
/// Returns a new binary response with specified data and no original request.
pub fn new_test_response<A: PayloadEntity + ToBytes>(
record_id: RecordId,
data: &A,
protocol_version: ProtocolVersion,
) -> BinaryResponseAndRequest {
let response = BinaryResponse::from_raw_bytes(
PayloadType::from_record_id(record_id, false),
ResponseType::from_record_id(record_id, false),
data.to_bytes().unwrap(),
protocol_version,
);
Expand All @@ -58,7 +58,7 @@ impl BinaryResponseAndRequest {
protocol_version: ProtocolVersion,
) -> BinaryResponseAndRequest {
let response = BinaryResponse::from_raw_bytes(
PayloadType::from_record_id(record_id, true),
ResponseType::from_record_id(record_id, true),
bincode::serialize(data).unwrap(),
protocol_version,
);
Expand Down
7 changes: 5 additions & 2 deletions binary_port/src/binary_response_header.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::{error_code::ErrorCode, payload_type::PayloadType};
use crate::{error_code::ErrorCode, response_type::ResponseType};
use casper_types::{
bytesrepr::{self, FromBytes, ToBytes},
ProtocolVersion,
Expand All @@ -19,7 +19,10 @@ pub struct BinaryResponseHeader {

impl BinaryResponseHeader {
/// Creates new binary response header representing success.
pub fn new(returned_data_type: Option<PayloadType>, protocol_version: ProtocolVersion) -> Self {
pub fn new(
returned_data_type: Option<ResponseType>,
protocol_version: ProtocolVersion,
) -> Self {
Self {
protocol_version,
error: ErrorCode::NoError as u16,
Expand Down
Loading

0 comments on commit 83cda94

Please sign in to comment.