mirror of
https://github.com/serai-dex/serai.git
synced 2025-12-09 12:49:23 +00:00
Add a send test
This commit is contained in:
@@ -22,9 +22,6 @@ pub mod clsag;
|
||||
pub mod rpc;
|
||||
pub mod transaction;
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests;
|
||||
|
||||
#[link(name = "wrapper")]
|
||||
extern "C" {
|
||||
pub(crate) fn free(ptr: *const u8);
|
||||
|
||||
@@ -21,9 +21,9 @@ use serde_json::json;
|
||||
use reqwest;
|
||||
|
||||
#[derive(Deserialize, Debug)]
|
||||
struct EmptyResponse {}
|
||||
pub struct EmptyResponse {}
|
||||
#[derive(Deserialize, Debug)]
|
||||
struct JsonRpcResponse<T> {
|
||||
pub struct JsonRpcResponse<T> {
|
||||
result: T
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ impl Rpc {
|
||||
Rpc(daemon)
|
||||
}
|
||||
|
||||
async fn rpc_call<
|
||||
pub async fn rpc_call<
|
||||
Params: Serialize + Debug,
|
||||
Response: DeserializeOwned + Debug
|
||||
>(&self, method: &str, params: Option<Params>) -> Result<Response, RpcError> {
|
||||
@@ -71,7 +71,7 @@ impl Rpc {
|
||||
self.call_tail(method, builder).await
|
||||
}
|
||||
|
||||
async fn bin_call<
|
||||
pub async fn bin_call<
|
||||
Response: DeserializeOwned + Debug
|
||||
>(&self, method: &str, params: Vec<u8>) -> Result<Response, RpcError> {
|
||||
let client = reqwest::Client::new();
|
||||
@@ -236,18 +236,4 @@ impl Rpc {
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
pub async fn mine_block(&self, address: String) -> Result<(), RpcError> {
|
||||
let _: EmptyResponse = self.rpc_call("json_rpc", Some(json!({
|
||||
"jsonrpc": "2.0",
|
||||
"id": (),
|
||||
"method": "generateblocks",
|
||||
"params": {
|
||||
"wallet_address": address,
|
||||
"amount_of_blocks": 10
|
||||
},
|
||||
}))).await?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -365,7 +365,7 @@ pub async fn send<R: RngCore + CryptoRng>(
|
||||
payments: &[(Address, u64)],
|
||||
change: Address,
|
||||
fee_per_byte: u64
|
||||
) -> Result<Hash, TransactionError> {
|
||||
) -> Result<Transaction, TransactionError> {
|
||||
let (_, mask_sum, mut tx) = prepare_outputs(
|
||||
&mut Preparation::Leader(rng),
|
||||
inputs,
|
||||
@@ -386,7 +386,5 @@ pub async fn send<R: RngCore + CryptoRng>(
|
||||
prunable.Clsags = clsags.iter().map(|clsag| clsag.0.clone()).collect();
|
||||
prunable.pseudo_outs = clsags.iter().map(|clsag| Key { key: clsag.1.compress().to_bytes() }).collect();
|
||||
tx.rct_signatures.p = Some(prunable);
|
||||
|
||||
rpc.publish_transaction(&tx).await.map_err(|e| TransactionError::InvalidTransaction(e))?;
|
||||
Ok(tx.hash())
|
||||
Ok(tx)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user