mirror of
https://github.com/comit-network/xmr-btc-swap.git
synced 2024-12-24 23:19:34 -05:00
Test monero amount serialisation
This commit is contained in:
parent
28ffe063b7
commit
fea6b29da9
@ -82,6 +82,7 @@ mod tests {
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::str::FromStr;
|
||||
use xmr_btc::serde::monero_private_key;
|
||||
use xmr_btc::{CrossCurveScalar, Curve25519Scalar};
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, PartialEq)]
|
||||
pub struct TestState {
|
||||
|
@ -77,6 +77,9 @@ mod tests {
|
||||
#[derive(Debug, Serialize, Deserialize, PartialEq)]
|
||||
pub struct MoneroPrivateKey(#[serde(with = "monero_private_key")] crate::monero::PrivateKey);
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, PartialEq)]
|
||||
pub struct MoneroAmount(#[serde(with = "monero_amount")] crate::monero::Amount);
|
||||
|
||||
#[test]
|
||||
fn serde_monero_private_key() {
|
||||
let key = MoneroPrivateKey(monero::PrivateKey::from_scalar(Scalar::random(&mut OsRng)));
|
||||
@ -84,4 +87,12 @@ mod tests {
|
||||
let decoded: MoneroPrivateKey = serde_cbor::from_slice(&encoded).unwrap();
|
||||
assert_eq!(key, decoded);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn serde_monero_amount() {
|
||||
let amount = MoneroAmount(crate::monero::Amount::from_piconero(1000));
|
||||
let encoded = serde_cbor::to_vec(&amount).unwrap();
|
||||
let decoded: MoneroAmount = serde_cbor::from_slice(&encoded).unwrap();
|
||||
assert_eq!(amount, decoded);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user