V2 Foreign API RPC Tests (#28)

* build_coinbase api doctest

* rustfmt

* foreign api recieve tx rpc

* rustfmt

* re-export grin dependencies

* re-export grin dependencies

* all foreign API rpc tests working
This commit is contained in:
Yeastplume
2019-03-26 16:02:31 +00:00
committed by GitHub
parent 94960b3edd
commit afa6003a8b
47 changed files with 686 additions and 439 deletions
+14 -4
View File
@@ -14,8 +14,8 @@
//! Generic implementation of owner API functions
use crate::grin_keychain::Keychain;
use crate::internal::{tx, updater};
use crate::keychain::Keychain;
use crate::slate::Slate;
use crate::types::{BlockFees, CbData, NodeClient, TxLogEntryType, WalletBackend};
use crate::{Error, ErrorKind};
@@ -23,13 +23,17 @@ use crate::{Error, ErrorKind};
const USER_MESSAGE_MAX_LEN: usize = 256;
/// Build a coinbase transaction
pub fn build_coinbase<T: ?Sized, C, K>(w: &mut T, block_fees: &BlockFees) -> Result<CbData, Error>
pub fn build_coinbase<T: ?Sized, C, K>(
w: &mut T,
block_fees: &BlockFees,
test_mode: bool,
) -> Result<CbData, Error>
where
T: WalletBackend<C, K>,
C: NodeClient,
K: Keychain,
{
updater::build_coinbase(&mut *w, block_fees)
updater::build_coinbase(&mut *w, block_fees, test_mode)
}
/// verify slate messages
@@ -61,7 +65,13 @@ where
None => w.parent_key_id(),
};
// Don't do this multiple times
let tx = updater::retrieve_txs(&mut *w, None, Some(slate.id), Some(&parent_key_id), false)?;
let tx = updater::retrieve_txs(
&mut *w,
None,
Some(slate.id),
Some(&parent_key_id),
use_test_rng,
)?;
for t in &tx {
if t.tx_type == TxLogEntryType::TxReceived {
return Err(ErrorKind::TransactionAlreadyReceived(slate.id.to_string()).into());
+6 -5
View File
@@ -16,12 +16,13 @@
use uuid::Uuid;
use crate::core::core::hash::Hashed;
use crate::core::core::Transaction;
use crate::core::ser;
use crate::grin_core::core::hash::Hashed;
use crate::grin_core::core::Transaction;
use crate::grin_core::ser;
use crate::grin_util;
use crate::grin_keychain::{Identifier, Keychain};
use crate::internal::{keys, selection, tx, updater};
use crate::keychain::{Identifier, Keychain};
use crate::slate::Slate;
use crate::types::{
AcctPathMapping, NodeClient, OutputCommitMapping, TxEstimation, TxLogEntry, TxWrapper,
@@ -305,7 +306,7 @@ pub fn post_tx<C>(client: &C, tx: &Transaction, fluff: bool) -> Result<(), Error
where
C: NodeClient,
{
let tx_hex = util::to_hex(ser::ser_vec(tx).unwrap());
let tx_hex = grin_util::to_hex(ser::ser_vec(tx).unwrap());
let res = client.post_tx(&TxWrapper { tx_hex: tx_hex }, fluff);
if let Err(e) = res {
error!("api: post_tx: failed with error: {}", e);