Skip to content

Commit

Permalink
V2 Foreign API RPC Tests (#28)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
yeastplume authored Mar 26, 2019
1 parent 94960b3 commit afa6003
Show file tree
Hide file tree
Showing 47 changed files with 685 additions and 438 deletions.
165 changes: 72 additions & 93 deletions Cargo.lock

Large diffs are not rendered by default.

9 changes: 2 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ name = "grin-wallet"
path = "src/bin/grin-wallet.rs"

[workspace]
members = ["api", "config", "controller", "impls", "libwallet"]
members = ["api", "config", "controller", "impls", "libwallet", "util"]
exclude = ["integration"]

[dependencies]
Expand All @@ -35,12 +35,7 @@ grin_wallet_libwallet = { path = "./libwallet", version = "1.1.0" }
grin_wallet_controller = { path = "./controller", version = "1.1.0" }
grin_wallet_config = { path = "./config", version = "1.1.0" }

grin_core = { git = "https://github.com/mimblewimble/grin", branch = "milestone/1.1.0" }
grin_keychain = { git = "https://github.com/mimblewimble/grin", branch = "milestone/1.1.0" }
grin_chain = { git = "https://github.com/mimblewimble/grin", branch = "milestone/1.1.0" }
grin_util = { git = "https://github.com/mimblewimble/grin", branch = "milestone/1.1.0" }
grin_api = { git = "https://github.com/mimblewimble/grin", branch = "milestone/1.1.0" }
grin_store = { git = "https://github.com/mimblewimble/grin", branch = "milestone/1.1.0" }
grin_wallet_util = { path = "./util", version = "1.1.0" }

[build-dependencies]
built = "0.3"
7 changes: 1 addition & 6 deletions api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,7 @@ grin_wallet_libwallet = { path = "../libwallet", version = "1.1.0" }
grin_wallet_config = { path = "../config", version = "1.1.0" }
grin_wallet_impls = { path = "../impls", version = "1.1.0" }

grin_core = { git = "https://github.com/mimblewimble/grin", branch = "milestone/1.1.0" }
grin_keychain = { git = "https://github.com/mimblewimble/grin", branch = "milestone/1.1.0" }
grin_chain = { git = "https://github.com/mimblewimble/grin", branch = "milestone/1.1.0" }
grin_util = { git = "https://github.com/mimblewimble/grin", branch = "milestone/1.1.0" }
grin_api = { git = "https://github.com/mimblewimble/grin", branch = "milestone/1.1.0" }
grin_store = { git = "https://github.com/mimblewimble/grin", branch = "milestone/1.1.0" }
grin_wallet_util = { path = "../util", version = "1.1.0" }

[dev-dependencies]
serde_json = "1"
Expand Down
13 changes: 8 additions & 5 deletions api/src/foreign.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ where
/// Wallet, contains its keychain (TODO: Split these up into 2 traits
/// perhaps)
pub wallet: Arc<Mutex<W>>,
/// Flag to normalize some output during testing. Can mostly be ignored.
pub doctest_mode: bool,
phantom: PhantomData<K>,
phantom_c: PhantomData<C>,
}
Expand All @@ -57,19 +59,20 @@ where
K: Keychain,
{
/// Create new API instance
pub fn new(wallet_in: Arc<Mutex<W>>) -> Box<Self> {
Box::new(Foreign {
pub fn new(wallet_in: Arc<Mutex<W>>) -> Self {
Foreign {
wallet: wallet_in,
doctest_mode: false,
phantom: PhantomData,
phantom_c: PhantomData,
})
}
}

/// Build a new (potential) coinbase transaction in the wallet
pub fn build_coinbase(&self, block_fees: &BlockFees) -> Result<CbData, Error> {
let mut w = self.wallet.lock();
w.open_with_credentials()?;
let res = foreign::build_coinbase(&mut *w, block_fees);
let res = foreign::build_coinbase(&mut *w, block_fees, self.doctest_mode);
w.close()?;
res
}
Expand All @@ -88,7 +91,7 @@ where
) -> Result<(), Error> {
let mut w = self.wallet.lock();
w.open_with_credentials()?;
let res = foreign::receive_tx(&mut *w, slate, dest_acct_name, message, false);
let res = foreign::receive_tx(&mut *w, slate, dest_acct_name, message, self.doctest_mode);
w.close()?;
res
}
Expand Down
Loading

0 comments on commit afa6003

Please sign in to comment.