rpc: fix tests

This commit is contained in:
hinto.janai 2024-10-17 21:53:12 -04:00
parent 2085749824
commit d9787f95ff
No known key found for this signature in database
GPG key ID: D47CE05FA175A499
3 changed files with 16 additions and 6 deletions

View file

@ -164,7 +164,7 @@ impl AccessResponseBase {
/// use cuprate_rpc_types::{misc::*, base::*};
///
/// assert_eq!(AccessResponseBase::OK_UNTRUSTED, AccessResponseBase {
/// response_base: ResponseBase::ok_untrusted(),
/// response_base: ResponseBase::OK_UNTRUSTED,
/// credits: 0,
/// top_hash: "".into(),
/// });

View file

@ -658,7 +658,7 @@ define_request_and_response! {
connections: vec![
ConnectionInfo {
address: "3evk3kezfjg44ma6tvesy7rbxwwpgpympj45xar5fo4qajrsmkoaqdqd.onion:18083".into(),
address_type: 4,
address_type: cuprate_rpc_types::misc::AddressType::Tor,
avg_download: 0,
avg_upload: 0,
connection_id: "22ef856d0f1d44cc95e84fecfd065fe2".into(),
@ -685,7 +685,7 @@ define_request_and_response! {
},
ConnectionInfo {
address: "4iykytmumafy5kjahdqc7uzgcs34s2vwsadfjpk4znvsa5vmcxeup2qd.onion:18083".into(),
address_type: 4,
address_type: cuprate_rpc_types::misc::AddressType::Tor,
avg_download: 0,
avg_upload: 0,
connection_id: "c7734e15936f485a86d2b0534f87e499".into(),
@ -1251,7 +1251,7 @@ define_request_and_response! {
SyncInfoPeer {
info: ConnectionInfo {
address: "142.93.128.65:44986".into(),
address_type: 1,
address_type: AddressType::Ipv4,
avg_download: 1,
avg_upload: 1,
connection_id: "a5803c4c2dac49e7b201dccdef54c862".into(),
@ -1280,7 +1280,7 @@ define_request_and_response! {
SyncInfoPeer {
info: ConnectionInfo {
address: "4iykytmumafy5kjahdqc7uzgcs34s2vwsadfjpk4znvsa5vmcxeup2qd.onion:18083".into(),
address_type: 4,
address_type: AddressType::Tor,
avg_download: 0,
avg_upload: 0,
connection_id: "277f7c821bc546878c8bd29977e780f5".into(),

View file

@ -20,7 +20,7 @@ use cuprate_epee_encoding::{
)]
#[derive(Copy, Clone, Default, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "serde", serde(untagged))]
#[cfg_attr(feature = "serde", serde(untagged, try_from = "u8", into = "u8"))]
#[repr(u8)]
pub enum AddressType {
#[default]
@ -80,6 +80,16 @@ impl From<AddressType> for u8 {
}
}
impl TryFrom<u8> for AddressType {
type Error = u8;
fn try_from(value: u8) -> Result<Self, Self::Error> {
match Self::from_u8(value) {
Some(s) => Ok(s),
None => Err(value),
}
}
}
#[cfg(feature = "epee")]
impl EpeeValue for AddressType {
const MARKER: Marker = u8::MARKER;