mirror of
https://github.com/aljazceru/cdk.git
synced 2025-12-20 22:24:54 +01:00
refactor: remove mint url from config
This commit is contained in:
@@ -4,7 +4,6 @@ use bitcoin::bip32::DerivationPath;
|
|||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
use crate::mint_url::MintUrl;
|
|
||||||
use crate::nuts::{MeltQuoteState, MintQuoteState};
|
use crate::nuts::{MeltQuoteState, MintQuoteState};
|
||||||
use crate::{Amount, CurrencyUnit, Id, KeySetInfo, PublicKey};
|
use crate::{Amount, CurrencyUnit, Id, KeySetInfo, PublicKey};
|
||||||
|
|
||||||
@@ -13,8 +12,6 @@ use crate::{Amount, CurrencyUnit, Id, KeySetInfo, PublicKey};
|
|||||||
pub struct MintQuote {
|
pub struct MintQuote {
|
||||||
/// Quote id
|
/// Quote id
|
||||||
pub id: Uuid,
|
pub id: Uuid,
|
||||||
/// Mint Url
|
|
||||||
pub mint_url: MintUrl,
|
|
||||||
/// Amount of quote
|
/// Amount of quote
|
||||||
pub amount: Amount,
|
pub amount: Amount,
|
||||||
/// Unit of quote
|
/// Unit of quote
|
||||||
@@ -34,7 +31,6 @@ pub struct MintQuote {
|
|||||||
impl MintQuote {
|
impl MintQuote {
|
||||||
/// Create new [`MintQuote`]
|
/// Create new [`MintQuote`]
|
||||||
pub fn new(
|
pub fn new(
|
||||||
mint_url: MintUrl,
|
|
||||||
request: String,
|
request: String,
|
||||||
unit: CurrencyUnit,
|
unit: CurrencyUnit,
|
||||||
amount: Amount,
|
amount: Amount,
|
||||||
@@ -45,7 +41,6 @@ impl MintQuote {
|
|||||||
let id = Uuid::new_v4();
|
let id = Uuid::new_v4();
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
mint_url,
|
|
||||||
id,
|
id,
|
||||||
amount,
|
amount,
|
||||||
unit,
|
unit,
|
||||||
|
|||||||
@@ -50,7 +50,6 @@ where
|
|||||||
|
|
||||||
mint_builder = mint_builder
|
mint_builder = mint_builder
|
||||||
.with_name("fake test mint".to_string())
|
.with_name("fake test mint".to_string())
|
||||||
.with_mint_url(format!("http://{addr}:{port}"))
|
|
||||||
.with_description("fake test mint".to_string())
|
.with_description("fake test mint".to_string())
|
||||||
.with_quote_ttl(10000, 10000)
|
.with_quote_ttl(10000, 10000)
|
||||||
.with_seed(mnemonic.to_seed_normalized("").to_vec());
|
.with_seed(mnemonic.to_seed_normalized("").to_vec());
|
||||||
|
|||||||
@@ -175,7 +175,6 @@ pub async fn create_and_start_test_mint() -> anyhow::Result<Arc<Mint>> {
|
|||||||
|
|
||||||
mint_builder = mint_builder
|
mint_builder = mint_builder
|
||||||
.with_name("pure test mint".to_string())
|
.with_name("pure test mint".to_string())
|
||||||
.with_mint_url("http://aa".to_string())
|
|
||||||
.with_description("pure test mint".to_string())
|
.with_description("pure test mint".to_string())
|
||||||
.with_quote_ttl(10000, 10000)
|
.with_quote_ttl(10000, 10000)
|
||||||
.with_seed(mnemonic.to_seed_normalized("").to_vec());
|
.with_seed(mnemonic.to_seed_normalized("").to_vec());
|
||||||
@@ -198,7 +197,7 @@ pub fn create_test_wallet_for_mint(mint: Arc<Mint>) -> anyhow::Result<Arc<Wallet
|
|||||||
let connector = DirectMintConnection::new(mint);
|
let connector = DirectMintConnection::new(mint);
|
||||||
|
|
||||||
let seed = Mnemonic::generate(12)?.to_seed_normalized("");
|
let seed = Mnemonic::generate(12)?.to_seed_normalized("");
|
||||||
let mint_url = connector.mint.config.mint_url().to_string();
|
let mint_url = "http://aa".to_string();
|
||||||
let unit = CurrencyUnit::Sat;
|
let unit = CurrencyUnit::Sat;
|
||||||
let localstore = WalletMemoryDatabase::default();
|
let localstore = WalletMemoryDatabase::default();
|
||||||
let mut wallet = Wallet::new(&mint_url, unit, Arc::new(localstore), &seed, None)?;
|
let mut wallet = Wallet::new(&mint_url, unit, Arc::new(localstore), &seed, None)?;
|
||||||
|
|||||||
@@ -169,7 +169,6 @@ where
|
|||||||
|
|
||||||
mint_builder = mint_builder
|
mint_builder = mint_builder
|
||||||
.with_name("regtest mint".to_string())
|
.with_name("regtest mint".to_string())
|
||||||
.with_mint_url(format!("http://{addr}:{port}"))
|
|
||||||
.with_description("regtest mint".to_string())
|
.with_description("regtest mint".to_string())
|
||||||
.with_quote_ttl(10000, 10000)
|
.with_quote_ttl(10000, 10000)
|
||||||
.with_seed(mnemonic.to_seed_normalized("").to_vec());
|
.with_seed(mnemonic.to_seed_normalized("").to_vec());
|
||||||
|
|||||||
@@ -46,7 +46,6 @@ async fn new_mint(fee: u64) -> Mint {
|
|||||||
let quote_ttl = QuoteTTL::new(10000, 10000);
|
let quote_ttl = QuoteTTL::new(10000, 10000);
|
||||||
|
|
||||||
Mint::new(
|
Mint::new(
|
||||||
MINT_URL,
|
|
||||||
&mnemonic.to_seed_normalized(""),
|
&mnemonic.to_seed_normalized(""),
|
||||||
mint_info,
|
mint_info,
|
||||||
quote_ttl,
|
quote_ttl,
|
||||||
@@ -72,7 +71,6 @@ async fn mint_proofs(
|
|||||||
let request_lookup = uuid::Uuid::new_v4().to_string();
|
let request_lookup = uuid::Uuid::new_v4().to_string();
|
||||||
|
|
||||||
let quote = MintQuote::new(
|
let quote = MintQuote::new(
|
||||||
mint.config.mint_url(),
|
|
||||||
"".to_string(),
|
"".to_string(),
|
||||||
CurrencyUnit::Sat,
|
CurrencyUnit::Sat,
|
||||||
amount,
|
amount,
|
||||||
|
|||||||
@@ -301,7 +301,6 @@ async fn main() -> anyhow::Result<()> {
|
|||||||
|
|
||||||
mint_builder = mint_builder
|
mint_builder = mint_builder
|
||||||
.with_name(settings.mint_info.name)
|
.with_name(settings.mint_info.name)
|
||||||
.with_mint_url(settings.info.url)
|
|
||||||
.with_version(mint_version)
|
.with_version(mint_version)
|
||||||
.with_description(settings.mint_info.description)
|
.with_description(settings.mint_info.description)
|
||||||
.with_quote_ttl(10000, 10000)
|
.with_quote_ttl(10000, 10000)
|
||||||
|
|||||||
@@ -202,7 +202,6 @@ impl From<V1MintQuote> for MintQuote {
|
|||||||
fn from(quote: V1MintQuote) -> MintQuote {
|
fn from(quote: V1MintQuote) -> MintQuote {
|
||||||
MintQuote {
|
MintQuote {
|
||||||
id: quote.id,
|
id: quote.id,
|
||||||
mint_url: quote.mint_url,
|
|
||||||
amount: quote.amount,
|
amount: quote.amount,
|
||||||
unit: quote.unit,
|
unit: quote.unit,
|
||||||
request: quote.request.clone(),
|
request: quote.request.clone(),
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
ALTER TABLE mint_quote DROP COLUMN mint_url;
|
||||||
@@ -10,7 +10,6 @@ use bitcoin::bip32::DerivationPath;
|
|||||||
use cdk_common::common::LnKey;
|
use cdk_common::common::LnKey;
|
||||||
use cdk_common::database::{self, MintDatabase};
|
use cdk_common::database::{self, MintDatabase};
|
||||||
use cdk_common::mint::{self, MintKeySetInfo, MintQuote};
|
use cdk_common::mint::{self, MintKeySetInfo, MintQuote};
|
||||||
use cdk_common::mint_url::MintUrl;
|
|
||||||
use cdk_common::nut00::ProofsMethods;
|
use cdk_common::nut00::ProofsMethods;
|
||||||
use cdk_common::nut05::QuoteState;
|
use cdk_common::nut05::QuoteState;
|
||||||
use cdk_common::secret::Secret;
|
use cdk_common::secret::Secret;
|
||||||
@@ -206,12 +205,11 @@ WHERE active = 1
|
|||||||
let res = sqlx::query(
|
let res = sqlx::query(
|
||||||
r#"
|
r#"
|
||||||
INSERT OR REPLACE INTO mint_quote
|
INSERT OR REPLACE INTO mint_quote
|
||||||
(id, mint_url, amount, unit, request, state, expiry, request_lookup_id, pubkey)
|
(id, amount, unit, request, state, expiry, request_lookup_id, pubkey)
|
||||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?);
|
VALUES (?, ?, ?, ?, ?, ?, ?, ?);
|
||||||
"#,
|
"#,
|
||||||
)
|
)
|
||||||
.bind(quote.id.to_string())
|
.bind(quote.id.to_string())
|
||||||
.bind(quote.mint_url.to_string())
|
|
||||||
.bind(u64::from(quote.amount) as i64)
|
.bind(u64::from(quote.amount) as i64)
|
||||||
.bind(quote.unit.to_string())
|
.bind(quote.unit.to_string())
|
||||||
.bind(quote.request)
|
.bind(quote.request)
|
||||||
@@ -1250,7 +1248,6 @@ fn sqlite_row_to_keyset_info(row: SqliteRow) -> Result<MintKeySetInfo, Error> {
|
|||||||
|
|
||||||
fn sqlite_row_to_mint_quote(row: SqliteRow) -> Result<MintQuote, Error> {
|
fn sqlite_row_to_mint_quote(row: SqliteRow) -> Result<MintQuote, Error> {
|
||||||
let row_id: Hyphenated = row.try_get("id").map_err(Error::from)?;
|
let row_id: Hyphenated = row.try_get("id").map_err(Error::from)?;
|
||||||
let row_mint_url: String = row.try_get("mint_url").map_err(Error::from)?;
|
|
||||||
let row_amount: i64 = row.try_get("amount").map_err(Error::from)?;
|
let row_amount: i64 = row.try_get("amount").map_err(Error::from)?;
|
||||||
let row_unit: String = row.try_get("unit").map_err(Error::from)?;
|
let row_unit: String = row.try_get("unit").map_err(Error::from)?;
|
||||||
let row_request: String = row.try_get("request").map_err(Error::from)?;
|
let row_request: String = row.try_get("request").map_err(Error::from)?;
|
||||||
@@ -1274,7 +1271,6 @@ fn sqlite_row_to_mint_quote(row: SqliteRow) -> Result<MintQuote, Error> {
|
|||||||
|
|
||||||
Ok(MintQuote {
|
Ok(MintQuote {
|
||||||
id: row_id.into_uuid(),
|
id: row_id.into_uuid(),
|
||||||
mint_url: MintUrl::from_str(&row_mint_url)?,
|
|
||||||
amount: Amount::from(row_amount as u64),
|
amount: Amount::from(row_amount as u64),
|
||||||
unit: CurrencyUnit::from_str(&row_unit).map_err(Error::from)?,
|
unit: CurrencyUnit::from_str(&row_unit).map_err(Error::from)?,
|
||||||
request: row_request,
|
request: row_request,
|
||||||
|
|||||||
@@ -21,8 +21,6 @@ use crate::types::{LnKey, QuoteTTL};
|
|||||||
/// Cashu Mint
|
/// Cashu Mint
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct MintBuilder {
|
pub struct MintBuilder {
|
||||||
/// Mint Url
|
|
||||||
mint_url: Option<String>,
|
|
||||||
/// Mint Info
|
/// Mint Info
|
||||||
mint_info: MintInfo,
|
mint_info: MintInfo,
|
||||||
/// Mint Storage backend
|
/// Mint Storage backend
|
||||||
@@ -63,12 +61,6 @@ impl MintBuilder {
|
|||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Set mint url
|
|
||||||
pub fn with_mint_url(mut self, mint_url: String) -> Self {
|
|
||||||
self.mint_url = Some(mint_url);
|
|
||||||
self
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Set seed
|
/// Set seed
|
||||||
pub fn with_seed(mut self, seed: Vec<u8>) -> Self {
|
pub fn with_seed(mut self, seed: Vec<u8>) -> Self {
|
||||||
self.seed = Some(seed);
|
self.seed = Some(seed);
|
||||||
@@ -227,7 +219,6 @@ impl MintBuilder {
|
|||||||
/// Build mint
|
/// Build mint
|
||||||
pub async fn build(&self) -> anyhow::Result<Mint> {
|
pub async fn build(&self) -> anyhow::Result<Mint> {
|
||||||
Ok(Mint::new(
|
Ok(Mint::new(
|
||||||
self.mint_url.as_ref().ok_or(anyhow!("Mint url not set"))?,
|
|
||||||
self.seed.as_ref().ok_or(anyhow!("Mint seed not set"))?,
|
self.seed.as_ref().ok_or(anyhow!("Mint seed not set"))?,
|
||||||
self.mint_info.clone(),
|
self.mint_info.clone(),
|
||||||
self.quote_ttl.ok_or(anyhow!("Quote ttl not set"))?,
|
self.quote_ttl.ok_or(anyhow!("Quote ttl not set"))?,
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ use std::sync::Arc;
|
|||||||
use arc_swap::ArcSwap;
|
use arc_swap::ArcSwap;
|
||||||
|
|
||||||
use super::{Id, MintInfo, MintKeySet};
|
use super::{Id, MintInfo, MintKeySet};
|
||||||
use crate::mint_url::MintUrl;
|
|
||||||
use crate::types::QuoteTTL;
|
use crate::types::QuoteTTL;
|
||||||
|
|
||||||
/// Mint Inner configuration
|
/// Mint Inner configuration
|
||||||
@@ -16,8 +15,6 @@ pub struct Config {
|
|||||||
pub keysets: HashMap<Id, MintKeySet>,
|
pub keysets: HashMap<Id, MintKeySet>,
|
||||||
/// Mint url
|
/// Mint url
|
||||||
pub mint_info: MintInfo,
|
pub mint_info: MintInfo,
|
||||||
/// Mint config
|
|
||||||
pub mint_url: MintUrl,
|
|
||||||
/// Quotes ttl
|
/// Quotes ttl
|
||||||
pub quote_ttl: QuoteTTL,
|
pub quote_ttl: QuoteTTL,
|
||||||
}
|
}
|
||||||
@@ -36,17 +33,11 @@ pub struct SwappableConfig {
|
|||||||
|
|
||||||
impl SwappableConfig {
|
impl SwappableConfig {
|
||||||
/// Creates a new configuration instance
|
/// Creates a new configuration instance
|
||||||
pub fn new(
|
pub fn new(quote_ttl: QuoteTTL, mint_info: MintInfo, keysets: HashMap<Id, MintKeySet>) -> Self {
|
||||||
mint_url: MintUrl,
|
|
||||||
quote_ttl: QuoteTTL,
|
|
||||||
mint_info: MintInfo,
|
|
||||||
keysets: HashMap<Id, MintKeySet>,
|
|
||||||
) -> Self {
|
|
||||||
let inner = Config {
|
let inner = Config {
|
||||||
keysets,
|
keysets,
|
||||||
quote_ttl,
|
quote_ttl,
|
||||||
mint_info,
|
mint_info,
|
||||||
mint_url,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
@@ -59,24 +50,6 @@ impl SwappableConfig {
|
|||||||
self.config.load().clone()
|
self.config.load().clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Gets a copy of the mint url
|
|
||||||
pub fn mint_url(&self) -> MintUrl {
|
|
||||||
self.load().mint_url.clone()
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Replace the current mint url with a new one
|
|
||||||
pub fn set_mint_url(&self, mint_url: MintUrl) {
|
|
||||||
let current_inner = self.load();
|
|
||||||
let new_inner = Config {
|
|
||||||
mint_url,
|
|
||||||
quote_ttl: current_inner.quote_ttl,
|
|
||||||
mint_info: current_inner.mint_info.clone(),
|
|
||||||
keysets: current_inner.keysets.clone(),
|
|
||||||
};
|
|
||||||
|
|
||||||
self.config.store(Arc::new(new_inner));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Gets a copy of the quote ttl
|
/// Gets a copy of the quote ttl
|
||||||
pub fn quote_ttl(&self) -> QuoteTTL {
|
pub fn quote_ttl(&self) -> QuoteTTL {
|
||||||
self.load().quote_ttl
|
self.load().quote_ttl
|
||||||
@@ -87,7 +60,6 @@ impl SwappableConfig {
|
|||||||
let current_inner = self.load();
|
let current_inner = self.load();
|
||||||
let new_inner = Config {
|
let new_inner = Config {
|
||||||
mint_info: current_inner.mint_info.clone(),
|
mint_info: current_inner.mint_info.clone(),
|
||||||
mint_url: current_inner.mint_url.clone(),
|
|
||||||
quote_ttl,
|
quote_ttl,
|
||||||
keysets: current_inner.keysets.clone(),
|
keysets: current_inner.keysets.clone(),
|
||||||
};
|
};
|
||||||
@@ -105,7 +77,6 @@ impl SwappableConfig {
|
|||||||
let current_inner = self.load();
|
let current_inner = self.load();
|
||||||
let new_inner = Config {
|
let new_inner = Config {
|
||||||
mint_info,
|
mint_info,
|
||||||
mint_url: current_inner.mint_url.clone(),
|
|
||||||
quote_ttl: current_inner.quote_ttl,
|
quote_ttl: current_inner.quote_ttl,
|
||||||
keysets: current_inner.keysets.clone(),
|
keysets: current_inner.keysets.clone(),
|
||||||
};
|
};
|
||||||
@@ -119,7 +90,6 @@ impl SwappableConfig {
|
|||||||
let new_inner = Config {
|
let new_inner = Config {
|
||||||
mint_info: current_inner.mint_info.clone(),
|
mint_info: current_inner.mint_info.clone(),
|
||||||
quote_ttl: current_inner.quote_ttl,
|
quote_ttl: current_inner.quote_ttl,
|
||||||
mint_url: current_inner.mint_url.clone(),
|
|
||||||
keysets,
|
keysets,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1,21 +1,8 @@
|
|||||||
use tracing::instrument;
|
use tracing::instrument;
|
||||||
|
|
||||||
use super::{Mint, MintInfo};
|
use super::{Mint, MintInfo};
|
||||||
use crate::mint_url::MintUrl;
|
|
||||||
|
|
||||||
impl Mint {
|
impl Mint {
|
||||||
/// Set Mint Url
|
|
||||||
#[instrument(skip_all)]
|
|
||||||
pub fn set_mint_url(&self, mint_url: MintUrl) {
|
|
||||||
self.config.set_mint_url(mint_url);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Get Mint Url
|
|
||||||
#[instrument(skip_all)]
|
|
||||||
pub fn get_mint_url(&self) -> MintUrl {
|
|
||||||
self.config.mint_url()
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Set Mint Info
|
/// Set Mint Info
|
||||||
#[instrument(skip_all)]
|
#[instrument(skip_all)]
|
||||||
pub fn set_mint_info(&self, mint_info: MintInfo) {
|
pub fn set_mint_info(&self, mint_info: MintInfo) {
|
||||||
|
|||||||
@@ -101,7 +101,6 @@ impl Mint {
|
|||||||
})?;
|
})?;
|
||||||
|
|
||||||
let quote = MintQuote::new(
|
let quote = MintQuote::new(
|
||||||
self.config.mint_url(),
|
|
||||||
create_invoice_response.request.to_string(),
|
create_invoice_response.request.to_string(),
|
||||||
unit.clone(),
|
unit.clone(),
|
||||||
amount,
|
amount,
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
//! Cashu Mint
|
//! Cashu Mint
|
||||||
|
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::str::FromStr;
|
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use bitcoin::bip32::{ChildNumber, DerivationPath, Xpriv};
|
use bitcoin::bip32::{ChildNumber, DerivationPath, Xpriv};
|
||||||
@@ -22,7 +21,6 @@ use crate::cdk_lightning::{self, MintLightning};
|
|||||||
use crate::dhke::{sign_message, verify_message};
|
use crate::dhke::{sign_message, verify_message};
|
||||||
use crate::error::Error;
|
use crate::error::Error;
|
||||||
use crate::fees::calculate_fee;
|
use crate::fees::calculate_fee;
|
||||||
use crate::mint_url::MintUrl;
|
|
||||||
use crate::nuts::*;
|
use crate::nuts::*;
|
||||||
use crate::util::unix_time;
|
use crate::util::unix_time;
|
||||||
use crate::Amount;
|
use crate::Amount;
|
||||||
@@ -60,7 +58,6 @@ impl Mint {
|
|||||||
/// Create new [`Mint`]
|
/// Create new [`Mint`]
|
||||||
#[allow(clippy::too_many_arguments)]
|
#[allow(clippy::too_many_arguments)]
|
||||||
pub async fn new(
|
pub async fn new(
|
||||||
mint_url: &str,
|
|
||||||
seed: &[u8],
|
seed: &[u8],
|
||||||
mint_info: MintInfo,
|
mint_info: MintInfo,
|
||||||
quote_ttl: QuoteTTL,
|
quote_ttl: QuoteTTL,
|
||||||
@@ -183,12 +180,7 @@ impl Mint {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
config: SwappableConfig::new(
|
config: SwappableConfig::new(quote_ttl, mint_info, active_keysets),
|
||||||
MintUrl::from_str(mint_url)?,
|
|
||||||
quote_ttl,
|
|
||||||
mint_info,
|
|
||||||
active_keysets,
|
|
||||||
),
|
|
||||||
pubsub_manager: Arc::new(localstore.clone().into()),
|
pubsub_manager: Arc::new(localstore.clone().into()),
|
||||||
secp_ctx,
|
secp_ctx,
|
||||||
xpriv,
|
xpriv,
|
||||||
@@ -564,6 +556,7 @@ fn derivation_path_from_unit(unit: CurrencyUnit, index: u32) -> Option<Derivatio
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use std::collections::HashSet;
|
use std::collections::HashSet;
|
||||||
|
use std::str::FromStr;
|
||||||
|
|
||||||
use bitcoin::Network;
|
use bitcoin::Network;
|
||||||
use cdk_common::common::{LnKey, QuoteTTL};
|
use cdk_common::common::{LnKey, QuoteTTL};
|
||||||
@@ -571,6 +564,7 @@ mod tests {
|
|||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
|
use crate::cdk_database::mint_memory::MintMemoryDatabase;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn mint_mod_generate_keyset_from_seed() {
|
fn mint_mod_generate_keyset_from_seed() {
|
||||||
@@ -658,8 +652,6 @@ mod tests {
|
|||||||
assert_eq!(amounts_and_pubkeys, expected_amounts_and_pubkeys);
|
assert_eq!(amounts_and_pubkeys, expected_amounts_and_pubkeys);
|
||||||
}
|
}
|
||||||
|
|
||||||
use crate::cdk_database::mint_memory::MintMemoryDatabase;
|
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
struct MintConfig<'a> {
|
struct MintConfig<'a> {
|
||||||
active_keysets: HashMap<CurrencyUnit, Id>,
|
active_keysets: HashMap<CurrencyUnit, Id>,
|
||||||
@@ -671,7 +663,6 @@ mod tests {
|
|||||||
blinded_signatures: HashMap<[u8; 33], BlindSignature>,
|
blinded_signatures: HashMap<[u8; 33], BlindSignature>,
|
||||||
quote_proofs: HashMap<Uuid, Vec<PublicKey>>,
|
quote_proofs: HashMap<Uuid, Vec<PublicKey>>,
|
||||||
quote_signatures: HashMap<Uuid, Vec<BlindSignature>>,
|
quote_signatures: HashMap<Uuid, Vec<BlindSignature>>,
|
||||||
mint_url: &'a str,
|
|
||||||
seed: &'a [u8],
|
seed: &'a [u8],
|
||||||
mint_info: MintInfo,
|
mint_info: MintInfo,
|
||||||
supported_units: HashMap<CurrencyUnit, (u64, u8)>,
|
supported_units: HashMap<CurrencyUnit, (u64, u8)>,
|
||||||
@@ -697,7 +688,6 @@ mod tests {
|
|||||||
);
|
);
|
||||||
|
|
||||||
Mint::new(
|
Mint::new(
|
||||||
config.mint_url,
|
|
||||||
config.seed,
|
config.seed,
|
||||||
config.mint_info,
|
config.mint_info,
|
||||||
config.quote_ttl,
|
config.quote_ttl,
|
||||||
@@ -712,12 +702,10 @@ mod tests {
|
|||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn mint_mod_new_mint() -> Result<(), Error> {
|
async fn mint_mod_new_mint() -> Result<(), Error> {
|
||||||
let config = MintConfig::<'_> {
|
let config = MintConfig::<'_> {
|
||||||
mint_url: "http://example.com",
|
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
let mint = create_mint(config).await?;
|
let mint = create_mint(config).await?;
|
||||||
|
|
||||||
assert_eq!(mint.get_mint_url().to_string(), "http://example.com");
|
|
||||||
let info = mint.mint_info();
|
let info = mint.mint_info();
|
||||||
assert!(info.name.is_none());
|
assert!(info.name.is_none());
|
||||||
assert!(info.pubkey.is_none());
|
assert!(info.pubkey.is_none());
|
||||||
@@ -751,7 +739,6 @@ mod tests {
|
|||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn mint_mod_rotate_keyset() -> Result<(), Error> {
|
async fn mint_mod_rotate_keyset() -> Result<(), Error> {
|
||||||
let config = MintConfig::<'_> {
|
let config = MintConfig::<'_> {
|
||||||
mint_url: "http://example.com",
|
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
let mint = create_mint(config).await?;
|
let mint = create_mint(config).await?;
|
||||||
@@ -796,7 +783,6 @@ mod tests {
|
|||||||
println!("{}", seed);
|
println!("{}", seed);
|
||||||
|
|
||||||
let config = MintConfig::<'_> {
|
let config = MintConfig::<'_> {
|
||||||
mint_url: "http://example.com",
|
|
||||||
seed: &seed.to_seed_normalized(""),
|
seed: &seed.to_seed_normalized(""),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user