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
+12 -16
View File
@@ -12,25 +12,25 @@
// See the License for the specific language governing permissions and
// limitations under the License.
use self::chain::Chain;
use self::core::core::{OutputFeatures, OutputIdentifier, Transaction};
use self::core::{consensus, global, pow, ser};
use self::util::secp::pedersen;
use self::util::Mutex;
use crate::api;
use crate::chain;
use crate::chain::Chain;
use crate::config::WalletConfig;
use crate::core;
use crate::core::core::{OutputFeatures, OutputIdentifier, Transaction};
use crate::core::{consensus, global, pow};
use crate::keychain;
use crate::libwallet;
use crate::libwallet::api_impl::{foreign, owner};
use crate::libwallet::types::{
BlockFees, CbData, NodeClient, WalletBackend, WalletInfo, WalletInst,
};
use crate::lmdb_wallet::LMDBBackend;
use crate::util;
use crate::util::secp::pedersen;
use crate::util::Mutex;
use crate::WalletSeed;
use chrono::Duration;
use grin_api as api;
use grin_chain as chain;
use grin_core as core;
use grin_keychain as keychain;
use grin_util as util;
use std::sync::Arc;
use std::thread;
@@ -79,15 +79,11 @@ fn get_outputs_by_pmmr_index_local(
pub fn add_block_with_reward(chain: &Chain, txs: Vec<&Transaction>, reward: CbData) {
let prev = chain.head_header().unwrap();
let next_header_info = consensus::next_difficulty(1, chain.difficulty_iter());
let out_bin = util::from_hex(reward.output).unwrap();
let kern_bin = util::from_hex(reward.kernel).unwrap();
let output = ser::deserialize(&mut &out_bin[..]).unwrap();
let kernel = ser::deserialize(&mut &kern_bin[..]).unwrap();
let mut b = core::core::Block::new(
&prev,
txs.into_iter().cloned().collect(),
next_header_info.clone().difficulty,
(output, kernel),
(reward.output, reward.kernel),
)
.unwrap();
b.header.timestamp = prev.timestamp + Duration::seconds(60);
@@ -128,7 +124,7 @@ where
let coinbase_tx = {
let mut w = wallet.lock();
w.open_with_credentials()?;
let res = foreign::build_coinbase(&mut *w, &block_fees)?;
let res = foreign::build_coinbase(&mut *w, &block_fees, false)?;
w.close()?;
res
};
+12 -15
View File
@@ -16,27 +16,24 @@
//! so that wallet API can be fully exercised
//! Operates directly on a chain instance
use self::chain::types::NoopAdapter;
use self::chain::Chain;
use self::core::core::verifier_cache::LruVerifierCache;
use self::core::core::Transaction;
use self::core::global::{set_mining_mode, ChainTypes};
use self::core::{pow, ser};
use self::keychain::Keychain;
use self::util::secp::pedersen;
use self::util::secp::pedersen::Commitment;
use self::util::{Mutex, RwLock, StopState};
use crate::api;
use crate::chain::types::NoopAdapter;
use crate::chain::Chain;
use crate::config::WalletConfig;
use crate::core::core::verifier_cache::LruVerifierCache;
use crate::core::core::Transaction;
use crate::core::global::{set_mining_mode, ChainTypes};
use crate::core::{pow, ser};
use crate::keychain::Keychain;
use crate::libwallet::api_impl::foreign;
use crate::libwallet::slate::Slate;
use crate::libwallet::types::*;
use crate::util;
use crate::util::secp::pedersen;
use crate::util::secp::pedersen::Commitment;
use crate::util::{Mutex, RwLock, StopState};
use crate::{libwallet, WalletCommAdapter};
use failure::ResultExt;
use grin_api as api;
use grin_chain as chain;
use grin_core as core;
use grin_keychain as keychain;
use grin_util as util;
use serde_json;
use std::collections::HashMap;
use std::marker::PhantomData;