Skip to content

Commit

Permalink
clean up warnings in controller crate
Browse files Browse the repository at this point in the history
  • Loading branch information
yeastplume committed Aug 9, 2023
1 parent c71ca3c commit c9b1cc8
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 32 deletions.
3 changes: 1 addition & 2 deletions api/src/foreign.rs
Original file line number Diff line number Diff line change
Expand Up @@ -483,13 +483,12 @@ where
/// TODO
pub fn verify_payment_proof_invoice(
&self,
keychain_mask: Option<&SecretKey>,
recipient_address: &DalekPublicKey,
proof: &InvoiceProof,
) -> Result<(), Error> {
let mut w_lock = self.wallet_inst.lock();
let w = w_lock.lc_provider()?.wallet_inst()?;
foreign::verify_payment_proof_invoice(&mut **w, keychain_mask, recipient_address, proof)
foreign::verify_payment_proof_invoice(&mut **w, recipient_address, proof)
}
}

Expand Down
26 changes: 24 additions & 2 deletions api/src/owner_rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -513,21 +513,43 @@ pub trait OwnerRpc {
```
*/

/**
TODO: Full docs once API has stabilised
*/
fn init_send_tx(&self, token: Token, args: InitTxArgs) -> Result<VersionedSlate, Error>;
fn contract_new(&self, token: Token, args: ContractNewArgsAPI)
-> Result<VersionedSlate, Error>;

/**
TODO: Implement
*/
// fn contract_setup(
// &self,
// token: Token,
// slate: VersionedSlate,
// args: ContractSetupArgsAPI,
// ) -> Result<VersionedSlate, Error>;

/**
TODO: Full docs once API has stabilised
*/

fn contract_new(&self, token: Token, args: ContractNewArgsAPI)
-> Result<VersionedSlate, Error>;

/**
TODO: Full docs once API has stabilised
*/

fn contract_sign(
&self,
token: Token,
slate: VersionedSlate,
args: ContractSetupArgsAPI,
) -> Result<VersionedSlate, Error>;

/**
TODO: Full docs once API has stabilised
*/

fn contract_revoke(
&self,
token: Token,
Expand Down
1 change: 1 addition & 0 deletions controller/tests/common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ pub fn open_local_wallet(
}

// Creates the given number of wallets and spawns a thread that runs the wallet proxy
#[allow(dead_code)]
pub fn create_wallets(
wallets_def: Vec<Vec<(&'static str, u64)>>, // a vector of boolean that represent whether we mine into a wallet
test_dir: &'static str,
Expand Down
6 changes: 2 additions & 4 deletions controller/tests/contract_accounts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,8 @@ use self::core::global;
use self::keychain::{ExtKeychain, Keychain};
use grin_wallet_libwallet as libwallet;
use impls::test_framework::{self};
use libwallet::contract::my_fee_contribution;
use libwallet::contract::types::{ContractNewArgsAPI, ContractSetupArgsAPI};
use libwallet::{Slate, SlateState, TxLogEntryType};
use libwallet::{Slate, SlateState};
use std::sync::atomic::Ordering;
use std::thread;
use std::time::Duration;
Expand All @@ -38,7 +37,7 @@ use common::{clean_output_dir, create_wallets, setup};
/// contract accounts testing (mostly the same as accounts.rs)
fn contract_accounts_impl(test_dir: &'static str) -> Result<(), libwallet::Error> {
// create two wallets with some extra accounts and don't mine anything in them
let (wallets, chain, stopper, mut bh) = create_wallets(
let (wallets, chain, stopper, _bh) = create_wallets(
vec![
vec![
("default", 0),
Expand Down Expand Up @@ -184,7 +183,6 @@ fn contract_accounts_impl(test_dir: &'static str) -> Result<(), libwallet::Error
api.post_tx(m, &slate, false)?;
Ok(())
})?;
bh += 1;

wallet::controller::owner_single_use(Some(wallet1.clone()), mask1, None, |api, m| {
let (wallet1_refreshed, wallet1_info) = api.retrieve_summary_info(m, true, 1)?;
Expand Down
9 changes: 2 additions & 7 deletions controller/tests/contract_accounts_switch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,10 @@ extern crate grin_wallet_impls as impls;
extern crate log;

use grin_core as core;
use grin_keychain as keychain;

use self::core::global;
use self::keychain::{ExtKeychain, Keychain};
use grin_wallet_libwallet as libwallet;
use impls::test_framework::{self};
use libwallet::contract::my_fee_contribution;
use libwallet::contract::types::{ContractNewArgsAPI, ContractSetupArgsAPI};
use libwallet::{Slate, SlateState, TxLogEntryType};
use libwallet::{Slate, SlateState};
use std::sync::atomic::Ordering;
use std::thread;
use std::time::Duration;
Expand All @@ -38,7 +33,7 @@ use common::{clean_output_dir, create_wallets, setup};
/// contract accounts testing when switching between accounts during transaction building
fn contract_accounts_switch_impl(test_dir: &'static str) -> Result<(), libwallet::Error> {
// create two wallets with some extra accounts and don't mine anything in them
let (wallets, chain, stopper, mut bh) = create_wallets(
let (wallets, _chain, stopper, _bh) = create_wallets(
vec![
vec![("default", 0), ("account1", 1), ("account2", 2)],
vec![("default", 0), ("account1", 3), ("account2", 4)],
Expand Down
7 changes: 3 additions & 4 deletions controller/tests/contract_early_lock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,9 @@ extern crate log;
use grin_wallet_libwallet as libwallet;

use grin_core::consensus;
use impls::test_framework::{self};
use libwallet::contract::my_fee_contribution;
use libwallet::contract::types::{ContractNewArgsAPI, ContractSetupArgsAPI, OutputSelectionArgs};
use libwallet::{OutputCommitMapping, OutputStatus, Slate, SlateState, TxLogEntryType};
use libwallet::contract::types::{ContractNewArgsAPI, ContractSetupArgsAPI};
use libwallet::{OutputStatus, Slate, SlateState};
use std::sync::atomic::Ordering;
use std::thread;
use std::time::Duration;
Expand All @@ -35,7 +34,7 @@ use common::{clean_output_dir, create_wallets, setup};
/// contract new with --add-outputs
fn contract_early_lock_tx_impl(test_dir: &'static str) -> Result<(), libwallet::Error> {
// create a single wallet and mine 5 blocks
let (wallets, chain, stopper, mut bh) =
let (wallets, _chain, stopper, _bh) =
create_wallets(vec![vec![("default", 5)]], test_dir).unwrap();
let send_wallet = wallets[0].0.clone();
let send_mask = wallets[0].1.as_ref();
Expand Down
15 changes: 4 additions & 11 deletions controller/tests/contract_early_proofs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,10 @@ extern crate grin_wallet_controller as wallet;
extern crate grin_wallet_impls as impls;
extern crate log;

use grin_core::consensus::KERNEL_WEIGHT;
use grin_wallet_libwallet as libwallet;

use grin_util::static_secp_instance;
use impls::test_framework::{self};
use libwallet::contract::my_fee_contribution;
use libwallet::contract::proofs::{InvoiceProof, ProofWitness};
use libwallet::contract::types::{ContractNewArgsAPI, ContractSetupArgsAPI};
use libwallet::{Slate, SlateState, TxLogEntryType};
use std::sync::atomic::Ordering;
Expand Down Expand Up @@ -70,7 +67,7 @@ fn contract_early_proofs_test_impl(test_dir: &'static str) -> Result<(), libwall
let mut recipient_address = None;
wallet::controller::owner_single_use(Some(recv_wallet.clone()), recv_mask, None, |api, m| {
// Receive wallet calls --receive=5
let mut args = &mut ContractSetupArgsAPI {
let args = &mut ContractSetupArgsAPI {
net_change: Some(5_000_000_000),
..Default::default()
};
Expand Down Expand Up @@ -145,7 +142,7 @@ fn contract_early_proofs_test_impl(test_dir: &'static str) -> Result<(), libwall

let mut invoice_proof = None;
// Now some time has passed, sender retrieves and verify the payment proof
wallet::controller::owner_single_use(Some(send_wallet.clone()), send_mask, None, |api, m| {
wallet::controller::owner_single_use(Some(send_wallet.clone()), send_mask, None, |api, _m| {
// Extract the stored data as an invoice proof
invoice_proof =
Some(api.retrieve_payment_proof_invoice(send_mask, true, None, Some(slate.id))?);
Expand All @@ -160,14 +157,10 @@ fn contract_early_proofs_test_impl(test_dir: &'static str) -> Result<(), libwall

wallet::controller::foreign_single_use(recv_wallet.clone(), recv_mask.cloned(), |api| {
let mut proof = serde_json::from_str(&invoice_proof_json).unwrap();
api.verify_payment_proof_invoice(recv_mask, recipient_address.as_ref().unwrap(), &proof)?;
api.verify_payment_proof_invoice(recipient_address.as_ref().unwrap(), &proof)?;
// tweak something and it shouldn't verify
proof.amount = 400000;
let retval = api.verify_payment_proof_invoice(
recv_mask,
recipient_address.as_ref().unwrap(),
&proof,
);
let retval = api.verify_payment_proof_invoice(recipient_address.as_ref().unwrap(), &proof);
assert!(retval.is_err());
Ok(())
})?;
Expand Down
2 changes: 0 additions & 2 deletions impls/src/backends/lmdb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ use std::io::{Read, Write};
use std::marker::PhantomData;
use std::path::Path;

use uuid::Uuid;

use crate::blake2::blake2b::{Blake2b, Blake2bResult};

use crate::keychain::{ChildNumber, ExtKeychain, Identifier, Keychain, SwitchCommitmentType};
Expand Down

0 comments on commit c9b1cc8

Please sign in to comment.