Skip to content
This repository has been archived by the owner on May 7, 2024. It is now read-only.

Commit

Permalink
Refactor test
Browse files Browse the repository at this point in the history
  • Loading branch information
aurexav committed Jan 21, 2024
1 parent efc61e3 commit fb922d2
Showing 1 changed file with 29 additions and 19 deletions.
48 changes: 29 additions & 19 deletions src/electrumx/test.rs
Original file line number Diff line number Diff line change
@@ -1,30 +1,40 @@
// std
use std::future::Future;
// crates.io
use tokio::runtime::Runtime;
// atomicalsir
use super::*;

#[tokio::test]
async fn get_by_ticker_should_work() {
fn test<F, Fut>(f: F)
where
F: FnOnce(ElectrumX) -> Fut,
Fut: Future<Output = ()>,
{
let _ = tracing_subscriber::fmt::try_init();
let e = ElectrumXBuilder::testnet().build().unwrap();

ElectrumXBuilder::testnet().build().unwrap().get_by_ticker("quark").await.unwrap();
Runtime::new().unwrap().block_on(f(e));
}

#[tokio::test]
async fn get_ft_info_should_work() {
let _ = tracing_subscriber::fmt::try_init();

let e = ElectrumXBuilder::testnet().build().unwrap();

e.get_ft_info(e.get_by_ticker("quark").await.unwrap().atomical_id).await.unwrap();
#[test]
fn get_by_ticker_should_work() {
test(|e| async move {
e.get_by_ticker("quark").await.unwrap();
});
}

#[tokio::test]
async fn get_unspent_address_should_work() {
let _ = tracing_subscriber::fmt::try_init();
#[test]
fn get_ft_info_should_work() {
test(|e| async move {
e.get_ft_info(e.get_by_ticker("quark").await.unwrap().atomical_id).await.unwrap();
});
}

ElectrumXBuilder::testnet()
.build()
.unwrap()
.get_unspent_address("tb1pemen3j4wvlryktkqsew8ext7wnsgqhmuzl7267rm3xk0th3gh04qr9wcec")
.await
.unwrap();
#[test]
fn get_unspent_address_should_work() {
test(|e| async move {
e.get_unspent_address("tb1pemen3j4wvlryktkqsew8ext7wnsgqhmuzl7267rm3xk0th3gh04qr9wcec")
.await
.unwrap();
});
}

0 comments on commit fb922d2

Please sign in to comment.