Skip to content

Commit

Permalink
Make tests compatible with the "request id" related change
Browse files Browse the repository at this point in the history
  • Loading branch information
Rafał Chabowski committed May 27, 2024
1 parent 21a46c4 commit 927e06f
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 7 deletions.
20 changes: 13 additions & 7 deletions rpc_sidecar/src/node_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ use std::{
use tokio_util::codec::Framed;

use casper_binary_port::{
BalanceResponse, BinaryMessage, BinaryMessageCodec, BinaryRequest, BinaryRequestHeader,
BinaryResponse, BinaryResponseAndRequest, ConsensusValidatorChanges, DictionaryItemIdentifier,
BalanceResponse, BinaryMessage, BinaryMessageCodec, BinaryRequest, BinaryResponse,
BinaryResponseAndRequest, ConsensusValidatorChanges, DictionaryItemIdentifier,
DictionaryQueryResult, ErrorCode, GetRequest, GetTrieFullResult, GlobalStateQueryResult,
GlobalStateRequest, InformationRequest, KeyPrefix, NodeStatus, PayloadEntity, PurseIdentifier,
RecordId, SpeculativeExecutionResult, TransactionWithExecutionInfo,
Expand Down Expand Up @@ -912,6 +912,7 @@ mod tests {
};

use super::*;
use casper_binary_port::BinaryRequestHeader;
use casper_types::testing::TestRng;
use casper_types::{CLValue, SemVer};
use futures::FutureExt;
Expand All @@ -928,6 +929,7 @@ mod tests {
BinaryResponseAndRequest::new(
BinaryResponse::from_value(AvailableBlockRange::RANGE_0_0, bad_version),
&request,
0,
),
0,
&notify,
Expand All @@ -951,6 +953,7 @@ mod tests {
BinaryResponseAndRequest::new(
BinaryResponse::from_value(AvailableBlockRange::RANGE_0_0, version),
&request,
0,
),
0,
&notify,
Expand All @@ -960,7 +963,8 @@ mod tests {
result,
Ok(BinaryResponseAndRequest::new(
BinaryResponse::from_value(AvailableBlockRange::RANGE_0_0, version),
&request
&request,
0
))
);
assert_eq!(notify.notified().now_or_never(), None)
Expand All @@ -980,6 +984,7 @@ mod tests {
BinaryResponseAndRequest::new(
BinaryResponse::from_value(AvailableBlockRange::RANGE_0_0, version),
&request,
0,
),
0,
&notify,
Expand All @@ -989,7 +994,8 @@ mod tests {
result,
Ok(BinaryResponseAndRequest::new(
BinaryResponse::from_value(AvailableBlockRange::RANGE_0_0, version),
&request
&request,
0
))
);
assert_eq!(notify.notified().now_or_never(), None)
Expand Down Expand Up @@ -1149,7 +1155,7 @@ mod tests {

let req = get_dummy_request_payload(Some(actual_id));
let resp = BinaryResponse::new_empty(ProtocolVersion::V2_0_0);
let resp_and_req = BinaryResponseAndRequest::new(resp, &req);
let resp_and_req = BinaryResponseAndRequest::new(resp, &req, actual_id);

let result = validate_response(resp_and_req, expected_id, &notify);
assert!(matches!(
Expand All @@ -1162,7 +1168,7 @@ mod tests {

let req = get_dummy_request_payload(Some(actual_id));
let resp = BinaryResponse::new_empty(ProtocolVersion::V2_0_0);
let resp_and_req = BinaryResponseAndRequest::new(resp, &req);
let resp_and_req = BinaryResponseAndRequest::new(resp, &req, actual_id);

let result = validate_response(resp_and_req, expected_id, &notify);
assert!(matches!(
Expand All @@ -1180,7 +1186,7 @@ mod tests {

let req = get_dummy_request_payload(Some(actual_id));
let resp = BinaryResponse::new_empty(ProtocolVersion::V2_0_0);
let resp_and_req = BinaryResponseAndRequest::new(resp, &req);
let resp_and_req = BinaryResponseAndRequest::new(resp, &req, actual_id);

let result = validate_response(resp_and_req, expected_id, &notify);
dbg!(&result);
Expand Down
3 changes: 3 additions & 0 deletions rpc_sidecar/src/rpcs/account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ mod tests {
Ok(BinaryResponseAndRequest::new(
BinaryResponse::new_empty(SUPPORTED_PROTOCOL_VERSION),
&[],
0,
))
}
_ => unimplemented!(),
Expand Down Expand Up @@ -213,6 +214,7 @@ mod tests {
Ok(BinaryResponseAndRequest::new(
BinaryResponse::new_empty(SUPPORTED_PROTOCOL_VERSION),
&[],
0,
))
}
_ => unimplemented!(),
Expand Down Expand Up @@ -257,6 +259,7 @@ mod tests {
SUPPORTED_PROTOCOL_VERSION,
),
&[],
0,
))
}
_ => unimplemented!(),
Expand Down
4 changes: 4 additions & 0 deletions rpc_sidecar/src/rpcs/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -704,6 +704,7 @@ mod tests {
Ok(BinaryResponseAndRequest::new(
BinaryResponse::from_value(self.block.clone(), SUPPORTED_PROTOCOL_VERSION),
&[],
0,
))
}
BinaryRequest::Get(GetRequest::Information { info_type_tag, .. })
Expand All @@ -716,6 +717,7 @@ mod tests {
SUPPORTED_PROTOCOL_VERSION,
),
&[],
0,
))
}
BinaryRequest::Get(GetRequest::Record {
Expand Down Expand Up @@ -758,6 +760,7 @@ mod tests {
SUPPORTED_PROTOCOL_VERSION,
),
&[],
0,
))
}
BinaryRequest::Get(GetRequest::State(req))
Expand All @@ -778,6 +781,7 @@ mod tests {
SUPPORTED_PROTOCOL_VERSION,
),
&[],
0,
))
}
req => unimplemented!("unexpected request: {:?}", req),
Expand Down
1 change: 1 addition & 0 deletions rpc_sidecar/src/rpcs/info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -757,6 +757,7 @@ mod tests {
Ok(BinaryResponseAndRequest::new(
BinaryResponse::from_value(transaction, SUPPORTED_PROTOCOL_VERSION),
&[],
0,
))
}
req => unimplemented!("unexpected request: {:?}", req),
Expand Down
2 changes: 2 additions & 0 deletions rpc_sidecar/src/rpcs/speculative_exec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ mod tests {
SUPPORTED_PROTOCOL_VERSION,
),
&[],
0,
))
}
BinaryRequest::TrySpeculativeExec { .. } => Ok(BinaryResponseAndRequest::new(
Expand All @@ -254,6 +255,7 @@ mod tests {
SUPPORTED_PROTOCOL_VERSION,
),
&[],
0,
)),
req => unimplemented!("unexpected request: {:?}", req),
}
Expand Down
Loading

0 comments on commit 927e06f

Please sign in to comment.