mirror of
https://github.com/jwinterm/grin-wallet.git
synced 2026-10-17 07:11:36 +02:00
Contracts: clear the warnings introduced by this PR
- Remove unused imports in api_impl::owner, backend, contract::utils, v5_bin and the contract tests. - Remove unused test bindings, and document the shared slate test fixtures module. - Drop the commented-out assertion block in the mwixnet contract test, along with the height bookkeeping and import that only it used.
This commit is contained in:
@@ -27,7 +27,7 @@ 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, Slatepack, Slatepacker, SlatepackerArgs, TxLogEntryType};
|
||||
use libwallet::{Slate, SlateState, Slatepacker, SlatepackerArgs, TxLogEntryType};
|
||||
use std::sync::atomic::Ordering;
|
||||
use std::thread;
|
||||
use std::time::Duration;
|
||||
@@ -55,7 +55,7 @@ fn contract_early_proofs_rsr_test_impl(test_dir: &'static str) -> Result<(), lib
|
||||
send_wallet.clone(),
|
||||
send_mask,
|
||||
PathBuf::from(test_dir),
|
||||
|api, m| {
|
||||
|api, _m| {
|
||||
sender_address = Some(api.get_slatepack_address(send_mask, 0)?.pub_key);
|
||||
Ok(())
|
||||
},
|
||||
|
||||
@@ -19,8 +19,6 @@ extern crate log;
|
||||
|
||||
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 std::sync::atomic::Ordering;
|
||||
@@ -35,7 +33,7 @@ use std::path::PathBuf;
|
||||
/// contract self-spend flow
|
||||
fn contract_self_spend_cancel_impl(test_dir: &'static str) -> Result<(), libwallet::Error> {
|
||||
// create a single wallet and mine 4 blocks
|
||||
let (wallets, chain, stopper, mut bh) =
|
||||
let (wallets, _chain, stopper, _bh) =
|
||||
create_wallets(vec![vec![("default", 4)]], test_dir).unwrap();
|
||||
let send_wallet = wallets[0].0.clone();
|
||||
let send_mask = wallets[0].1.as_ref();
|
||||
|
||||
@@ -21,10 +21,9 @@ use grin_util::{secp::SecretKey, static_secp_instance};
|
||||
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::mwixnet::MixnetReqCreationParams;
|
||||
use libwallet::{Slate, SlateState, TxLogEntryType};
|
||||
use libwallet::{Slate, SlateState};
|
||||
use std::sync::atomic::Ordering;
|
||||
use std::thread;
|
||||
use std::time::Duration;
|
||||
@@ -37,7 +36,7 @@ use std::path::PathBuf;
|
||||
/// contract SRS flow - just creating an mwixnet tx at the moment
|
||||
fn contract_srs_mwixnet_tx_impl(test_dir: &'static str) -> Result<(), libwallet::Error> {
|
||||
// create two wallets and mine 4 blocks in each (we want both to have balance to get a payjoin)
|
||||
let (wallets, chain, stopper, mut bh) =
|
||||
let (wallets, chain, stopper, _bh) =
|
||||
create_wallets(vec![vec![("default", 4)], vec![("default", 4)]], test_dir).unwrap();
|
||||
let send_wallet = wallets[0].0.clone();
|
||||
let send_mask = wallets[0].1.as_ref();
|
||||
@@ -107,11 +106,9 @@ fn contract_srs_mwixnet_tx_impl(test_dir: &'static str) -> Result<(), libwallet:
|
||||
Ok(())
|
||||
},
|
||||
)?;
|
||||
bh += 1;
|
||||
|
||||
let _ =
|
||||
test_framework::award_blocks_to_wallet(&chain, send_wallet.clone(), send_mask, 3, false);
|
||||
bh += 3;
|
||||
|
||||
// Recipient wallet sends outputs to mwixnet
|
||||
wallet::controller::owner_single_use(
|
||||
@@ -158,52 +155,6 @@ fn contract_srs_mwixnet_tx_impl(test_dir: &'static str) -> Result<(), libwallet:
|
||||
},
|
||||
)?;
|
||||
|
||||
bh += 1;
|
||||
|
||||
/*
|
||||
let _ =
|
||||
test_framework::award_blocks_to_wallet(&chain, send_wallet.clone(), send_mask, 3, false);
|
||||
bh += 3;
|
||||
|
||||
// Assert changes in receive wallet
|
||||
wallet::controller::owner_single_use(recv_wallet.clone(), recv_mask, PathBuf::from(test_dir), |api, m| {
|
||||
let (_, wallet_info) = api.retrieve_summary_info(m, true, 1)?;
|
||||
let (refreshed, txs) = api.retrieve_txs(m, true, None, None, None)?;
|
||||
assert_eq!(wallet_info.last_confirmed_height, bh);
|
||||
assert!(refreshed);
|
||||
assert_eq!(txs.len(), 5); // 4 mined and 1 received
|
||||
let tx_log = txs[4].clone();
|
||||
assert_eq!(tx_log.tx_type, TxLogEntryType::TxReceived);
|
||||
assert_eq!(tx_log.amount_credited, 5_000_000_000);
|
||||
assert_eq!(tx_log.amount_debited, 0);
|
||||
assert_eq!(tx_log.num_inputs, 1);
|
||||
assert_eq!(tx_log.num_outputs, 1);
|
||||
let expected_fees_paid = Some(my_fee_contribution(1, 1, 1, 2)?);
|
||||
assert_eq!(tx_log.fee, expected_fees_paid);
|
||||
assert_eq!(
|
||||
wallet_info.amount_currently_spendable,
|
||||
4 * 60_000_000_000 + 5_000_000_000 - expected_fees_paid.unwrap().fee() // we expect the balance of 4 mined blocks + 5 Grin - fees paid
|
||||
);
|
||||
Ok(())
|
||||
})?;
|
||||
|
||||
// Assert changes in send wallet
|
||||
wallet::controller::owner_single_use(send_wallet.clone(), send_mask, PathBuf::from(test_dir), |api, m| {
|
||||
let (_, wallet_info) = api.retrieve_summary_info(m, true, 1)?;
|
||||
let (refreshed, txs) = api.retrieve_txs(m, true, None, None, None)?;
|
||||
assert_eq!(wallet_info.last_confirmed_height, bh);
|
||||
assert!(refreshed);
|
||||
assert_eq!(txs.len() as u64, bh - 4 + 1); // send wallet didn't mine 4 blocks and made 1 tx
|
||||
let tx_log = txs[txs.len() - 5].clone(); // TODO: why -5 and not -4?
|
||||
assert_eq!(tx_log.tx_type, TxLogEntryType::TxSent);
|
||||
assert_eq!(tx_log.amount_credited, 0);
|
||||
assert_eq!(tx_log.amount_debited, 5_000_000_000);
|
||||
assert_eq!(tx_log.num_inputs, 1);
|
||||
assert_eq!(tx_log.num_outputs, 1);
|
||||
assert_eq!(tx_log.fee, Some(my_fee_contribution(1, 1, 1, 2)?));
|
||||
Ok(())
|
||||
})?;*/
|
||||
|
||||
// let logging finish
|
||||
stopper.store(false, Ordering::Relaxed);
|
||||
thread::sleep(Duration::from_millis(200));
|
||||
|
||||
@@ -109,7 +109,7 @@ fn self_send_cancel_test_impl(test_dir: &'static str) -> Result<(), libwallet::E
|
||||
wallet1.clone(),
|
||||
mask1,
|
||||
PathBuf::from(test_dir),
|
||||
|api, m| {
|
||||
|api, _m| {
|
||||
let query = RetrieveTxQueryArgs {
|
||||
include_outstanding_only: Some(true),
|
||||
exclude_cancelled: Some(true),
|
||||
|
||||
@@ -24,10 +24,9 @@ use crate::grin_core::core::{FeeFields, Output, OutputFeatures, Transaction};
|
||||
use crate::grin_core::libtx::proof;
|
||||
use crate::grin_keychain::ViewKey;
|
||||
use crate::grin_util::secp::key::SecretKey;
|
||||
use crate::grin_util::secp::pedersen;
|
||||
use crate::grin_util::secp::pedersen::Commitment;
|
||||
use crate::grin_util::{static_secp_instance, Mutex, ToHex};
|
||||
use crate::util::{OnionV3Address, OnionV3AddressError};
|
||||
use crate::grin_util::{Mutex, ToHex};
|
||||
use crate::util::OnionV3Address;
|
||||
|
||||
use crate::api_impl::owner_updater::StatusMessage;
|
||||
use crate::contract::types::{ContractNewArgsAPI, ContractRevokeArgsAPI, ContractSetupArgsAPI};
|
||||
|
||||
@@ -17,7 +17,6 @@ use std::fs;
|
||||
use std::fs::File;
|
||||
use std::io::{Read, Write};
|
||||
use std::path::Path;
|
||||
use uuid::Uuid;
|
||||
|
||||
use crate::blake2::blake2b::{Blake2b, Blake2bResult};
|
||||
|
||||
|
||||
@@ -25,7 +25,6 @@ use crate::types::{Context, NodeClient, StoredProofInfo, TxLogEntryType};
|
||||
use crate::util::OnionV3Address;
|
||||
use crate::{address, Error, OutputData, OutputStatus, TxLogEntry};
|
||||
use grin_core::core::FeeFields;
|
||||
use grin_util::file::delete;
|
||||
use uuid::Uuid;
|
||||
|
||||
/// Creates an initial TxLogEntry without input/output or kernel information
|
||||
|
||||
@@ -142,6 +142,7 @@ impl VersionedCoinbase {
|
||||
}
|
||||
}
|
||||
}
|
||||
/// Shared slate fixtures, used by the version conversion tests
|
||||
#[cfg(test)]
|
||||
pub mod tests {
|
||||
use crate::grin_core::core::transaction::OutputFeatures;
|
||||
@@ -161,7 +162,7 @@ pub mod tests {
|
||||
use grin_keychain::{ExtKeychain, Keychain, SwitchCommitmentType};
|
||||
use std::convert::TryInto;
|
||||
|
||||
// Populate a test internal slate with all fields to test conversions
|
||||
/// Populate a test internal slate with all fields to test conversions
|
||||
pub fn populate_test_slate() -> Result<Slate, Error> {
|
||||
let keychain = ExtKeychain::from_random_seed(true).unwrap();
|
||||
let switch = SwitchCommitmentType::Regular;
|
||||
|
||||
@@ -25,7 +25,6 @@ use chrono::{DateTime, NaiveDateTime, Utc};
|
||||
use ed25519_dalek::Signature as DalekSignature;
|
||||
use ed25519_dalek::VerifyingKey as DalekPublicKey;
|
||||
use std::convert::{TryFrom, TryInto};
|
||||
use std::f64::consts::E;
|
||||
|
||||
use crate::slate_versions::v5::{
|
||||
CommitsV5, KernelFeaturesArgsV5, ParticipantDataV5, PaymentInfoV5, PaymentMemoV5, SlateStateV5,
|
||||
|
||||
@@ -1489,7 +1489,7 @@ where
|
||||
let broadcast_tx = !sign_args.is_present("no-broadcast");
|
||||
command::contract_sign(owner_api, km, setup_args, broadcast_tx)
|
||||
}
|
||||
("view", Some(view_args)) => {
|
||||
("view", Some(_view_args)) => {
|
||||
Err(Error::ArgumentError(String::from("Not implemented")).into())
|
||||
}
|
||||
("revoke", Some(revoke_args)) => {
|
||||
|
||||
Reference in New Issue
Block a user