Have the RPC return the unsupported version when Unsupported

This commit is contained in:
Luke Parker 2022-11-14 23:56:28 -05:00
parent 6acbfdcc45
commit 83060a914a
No known key found for this signature in database
GPG key ID: F9F1386DB1E119B6
3 changed files with 5 additions and 5 deletions
coins/monero

View file

@ -56,7 +56,7 @@ mod tests;
#[derive(Clone, Copy, PartialEq, Eq, Debug, Zeroize)] #[derive(Clone, Copy, PartialEq, Eq, Debug, Zeroize)]
#[allow(non_camel_case_types)] #[allow(non_camel_case_types)]
pub enum Protocol { pub enum Protocol {
Unsupported, Unsupported(usize),
v14, v14,
v16, v16,
Custom { ring_len: usize, bp_plus: bool }, Custom { ring_len: usize, bp_plus: bool },
@ -66,7 +66,7 @@ impl Protocol {
/// Amount of ring members under this protocol version. /// Amount of ring members under this protocol version.
pub fn ring_len(&self) -> usize { pub fn ring_len(&self) -> usize {
match self { match self {
Protocol::Unsupported => panic!("Unsupported protocol version"), Protocol::Unsupported(_) => panic!("Unsupported protocol version"),
Protocol::v14 => 11, Protocol::v14 => 11,
Protocol::v16 => 16, Protocol::v16 => 16,
Protocol::Custom { ring_len, .. } => *ring_len, Protocol::Custom { ring_len, .. } => *ring_len,
@ -77,7 +77,7 @@ impl Protocol {
/// This method will likely be reworked when versions not using Bulletproofs at all are added. /// This method will likely be reworked when versions not using Bulletproofs at all are added.
pub fn bp_plus(&self) -> bool { pub fn bp_plus(&self) -> bool {
match self { match self {
Protocol::Unsupported => panic!("Unsupported protocol version"), Protocol::Unsupported(_) => panic!("Unsupported protocol version"),
Protocol::v14 => false, Protocol::v14 => false,
Protocol::v16 => true, Protocol::v16 => true,
Protocol::Custom { bp_plus, .. } => *bp_plus, Protocol::Custom { bp_plus, .. } => *bp_plus,

View file

@ -212,7 +212,7 @@ impl Rpc {
{ {
13 | 14 => Protocol::v14, 13 | 14 => Protocol::v14,
15 | 16 => Protocol::v16, 15 | 16 => Protocol::v16,
_ => Protocol::Unsupported, version => Protocol::Unsupported(version),
}, },
) )
} }

View file

@ -28,7 +28,7 @@ pub async fn rpc() -> Rpc {
// Mine 20 blocks to ensure decoy availability // Mine 20 blocks to ensure decoy availability
mine_block(&rpc, &addr).await.unwrap(); mine_block(&rpc, &addr).await.unwrap();
mine_block(&rpc, &addr).await.unwrap(); mine_block(&rpc, &addr).await.unwrap();
assert!(!matches!(rpc.get_protocol().await.unwrap(), Protocol::Unsupported)); assert!(!matches!(rpc.get_protocol().await.unwrap(), Protocol::Unsupported(_)));
rpc rpc
} }