Skip to content

Commit

Permalink
Merge branch 'development' into core-output-features-canonical-encoding
Browse files Browse the repository at this point in the history
* development:
  fix: remove unnecessary wallet dependency (tari-project#3438)
  test: simplify cucumber tests (tari-project#3457)
  • Loading branch information
sdbondi committed Oct 18, 2021
2 parents 58e6248 + 07c2c69 commit 19b2a9d
Show file tree
Hide file tree
Showing 69 changed files with 536 additions and 600 deletions.
4 changes: 2 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -129,15 +129,15 @@ commands:
- run:
name: Run cucumber scenarios
no_output_timeout: 20m
command: cd integration_tests && mkdir -p cucumber_output && node_modules/.bin/cucumber-js --tags "not @long-running and not @broken and not @wallet-ffi" --format json:cucumber_output/tests.cucumber --exit --retry 2 --retryTagFilter "@flaky and not @broken"
command: cd integration_tests && mkdir -p cucumber_output && node_modules/.bin/cucumber-js --profile "ci" --tags "not @long-running and not @broken and not @wallet-ffi" --format json:cucumber_output/tests.cucumber --exit --retry 2 --retryTagFilter "@flaky and not @broken"
- run:
name: Generate report
command: cd integration_tests && node ./generate_report.js
when: always
# Below step requires NodeJS v12 to run correctly, see explanation in WalletFFI.feature
- run:
name: Run FFI wallet library cucumber scenarios
command: cd integration_tests && mkdir -p cucumber_output && node_modules/.bin/cucumber-js --tags "not @long-running and not @broken and not @flaky and @wallet-ffi" --format json:cucumber_output/tests_ffi.cucumber --exit
command: cd integration_tests && mkdir -p cucumber_output && node_modules/.bin/cucumber-js --profile "ci" --tags "not @long-running and not @broken and not @flaky and @wallet-ffi" --format json:cucumber_output/tests_ffi.cucumber --exit
when: always
- run:
name: Generate report (ffi)
Expand Down
12 changes: 6 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 0 additions & 4 deletions applications/tari_app_grpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ edition = "2018"
[dependencies]
tari_common_types = { version = "^0.11", path = "../../base_layer/common_types"}
tari_core = { path = "../../base_layer/core"}
tari_wallet = { path = "../../base_layer/wallet", optional = true}
tari_crypto = { git = "https://github.com/tari-project/tari-crypto.git", branch = "main" }
tari_comms = { path = "../../comms"}

Expand All @@ -21,6 +20,3 @@ tonic = "0.5.2"

[build-dependencies]
tonic-build = "0.5.2"

[features]
wallet = ["tari_wallet"]
59 changes: 27 additions & 32 deletions applications/tari_app_grpc/src/conversions/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

use crate::tari_rpc as grpc;
use std::convert::{TryFrom, TryInto};
use tari_common_types::transaction::{self as tx, TxId};
use tari_core::{
crypto::{ristretto::RistrettoSecretKey, tari_utilities::ByteArray},
transactions::transaction::Transaction,
Expand Down Expand Up @@ -54,44 +55,38 @@ impl TryFrom<grpc::Transaction> for Transaction {
}
}

#[cfg(feature = "wallet")]
mod wallet {
use super::*;
use tari_wallet::{output_manager_service::TxId, transaction_service::storage::models};

impl From<models::TransactionStatus> for grpc::TransactionStatus {
fn from(status: models::TransactionStatus) -> Self {
use models::TransactionStatus::*;
match status {
Completed => grpc::TransactionStatus::Completed,
Broadcast => grpc::TransactionStatus::Broadcast,
MinedUnconfirmed => grpc::TransactionStatus::MinedUnconfirmed,
MinedConfirmed => grpc::TransactionStatus::MinedConfirmed,
Imported => grpc::TransactionStatus::Imported,
Pending => grpc::TransactionStatus::Pending,
Coinbase => grpc::TransactionStatus::Coinbase,
}
impl From<tx::TransactionDirection> for grpc::TransactionDirection {
fn from(status: tx::TransactionDirection) -> Self {
use tx::TransactionDirection::*;
match status {
Unknown => grpc::TransactionDirection::Unknown,
Inbound => grpc::TransactionDirection::Inbound,
Outbound => grpc::TransactionDirection::Outbound,
}
}
}

impl From<models::TransactionDirection> for grpc::TransactionDirection {
fn from(status: models::TransactionDirection) -> Self {
use models::TransactionDirection::*;
match status {
Unknown => grpc::TransactionDirection::Unknown,
Inbound => grpc::TransactionDirection::Inbound,
Outbound => grpc::TransactionDirection::Outbound,
}
impl From<tx::TransactionStatus> for grpc::TransactionStatus {
fn from(status: tx::TransactionStatus) -> Self {
use tx::TransactionStatus::*;
match status {
Completed => grpc::TransactionStatus::Completed,
Broadcast => grpc::TransactionStatus::Broadcast,
MinedUnconfirmed => grpc::TransactionStatus::MinedUnconfirmed,
MinedConfirmed => grpc::TransactionStatus::MinedConfirmed,
Imported => grpc::TransactionStatus::Imported,
Pending => grpc::TransactionStatus::Pending,
Coinbase => grpc::TransactionStatus::Coinbase,
}
}
}

impl grpc::TransactionInfo {
pub fn not_found(tx_id: TxId) -> Self {
Self {
tx_id,
status: grpc::TransactionStatus::NotFound as i32,
..Default::default()
}
impl grpc::TransactionInfo {
pub fn not_found(tx_id: TxId) -> Self {
Self {
tx_id,
status: grpc::TransactionStatus::NotFound as i32,
..Default::default()
}
}
}
5 changes: 0 additions & 5 deletions applications/tari_app_utilities/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ tari_crypto = { git = "https://github.com/tari-project/tari-crypto.git", branch
tari_common = { path = "../../common" }
tari_common_types = { path = "../../base_layer/common_types" }
tari_p2p = { path = "../../base_layer/p2p", features = ["auto-update"] }
tari_wallet = { path = "../../base_layer/wallet", optional = true }

config = { version = "0.9.3" }
futures = { version = "^0.3.16", default-features = false, features = ["alloc"] }
Expand All @@ -33,7 +32,3 @@ features = ["transactions"]

[build-dependencies]
tari_common = { path = "../../common", features = ["build", "static-application-info"] }

[features]
# TODO: This crate is supposed to hold common logic. Move code from this feature into the crate that is more specific to the wallet
wallet = ["tari_wallet"]
3 changes: 1 addition & 2 deletions applications/tari_app_utilities/src/identity_management.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,10 @@
// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
// USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

use crate::utilities::ExitCodes;
use log::*;
use rand::rngs::OsRng;
use std::{clone::Clone, fs, path::Path, string::ToString, sync::Arc};
use tari_common::configuration::bootstrap::prompt;
use tari_common::{configuration::bootstrap::prompt, exit_codes::ExitCodes};
use tari_common_types::types::PrivateKey;
use tari_comms::{multiaddr::Multiaddr, peer_manager::PeerFeatures, NodeIdentity};
use tari_crypto::{
Expand Down
3 changes: 2 additions & 1 deletion applications/tari_app_utilities/src/initialization.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
use crate::{consts, utilities::ExitCodes};
use crate::consts;
use config::Config;
use std::{path::PathBuf, str::FromStr};
use structopt::StructOpt;
use tari_common::{
configuration::{bootstrap::ApplicationType, Network},
exit_codes::ExitCodes,
ConfigBootstrap,
DatabaseType,
GlobalConfig,
Expand Down
150 changes: 1 addition & 149 deletions applications/tari_app_utilities/src/utilities.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,11 @@
use futures::future::Either;
use log::*;
use std::sync::Arc;
use thiserror::Error;
use tokio::{runtime, runtime::Runtime};

use tari_common::{CommsTransport, GlobalConfig, SocksAuthentication, TorControlAuthentication};
use tari_comms::{
connectivity::ConnectivityError,
peer_manager::{NodeId, PeerManagerError},
protocol::rpc::RpcError,
peer_manager::NodeId,
socks,
tor,
tor::TorIdentity,
Expand All @@ -47,151 +44,6 @@ use tari_comms::transports::predicate::FalsePredicate;

pub const LOG_TARGET: &str = "tari::application";

/// Enum to show failure information
#[derive(Debug, Clone, Error)]
pub enum ExitCodes {
#[error("There is an error in the wallet configuration: {0}")]
ConfigError(String),
#[error("The application exited because an unknown error occurred: {0}. Check the logs for more details.")]
UnknownError(String),
#[error("The application exited because an interface error occurred. Check the logs for details.")]
InterfaceError,
#[error("The application exited. {0}")]
WalletError(String),
#[error("The wallet was not able to start the GRPC server. {0}")]
GrpcError(String),
#[error("The application did not accept the command input: {0}")]
InputError(String),
#[error("Invalid command: {0}")]
CommandError(String),
#[error("IO error: {0}")]
IOError(String),
#[error("Recovery failed: {0}")]
RecoveryError(String),
#[error("The wallet exited because of an internal network error: {0}")]
NetworkError(String),
#[error("The wallet exited because it received a message it could not interpret: {0}")]
ConversionError(String),
#[error("Your password was incorrect.")]
IncorrectPassword,
#[error("Your application is encrypted but no password was provided.")]
NoPassword,
#[error("Tor connection is offline")]
TorOffline,
#[error("Database is in inconsistent state: {0}")]
DbInconsistentState(String),
}

impl ExitCodes {
pub fn as_i32(&self) -> i32 {
match self {
Self::ConfigError(_) => 101,
Self::UnknownError(_) => 102,
Self::InterfaceError => 103,
Self::WalletError(_) => 104,
Self::GrpcError(_) => 105,
Self::InputError(_) => 106,
Self::CommandError(_) => 107,
Self::IOError(_) => 108,
Self::RecoveryError(_) => 109,
Self::NetworkError(_) => 110,
Self::ConversionError(_) => 111,
Self::IncorrectPassword | Self::NoPassword => 112,
Self::TorOffline => 113,
Self::DbInconsistentState(_) => 115,
}
}

pub fn eprint_details(&self) {
use ExitCodes::*;
match self {
TorOffline => {
eprintln!("Unable to connect to the Tor control port.");
eprintln!(
"Please check that you have the Tor proxy running and that access to the Tor control port is \
turned on.",
);
eprintln!("If you are unsure of what to do, use the following command to start the Tor proxy:");
eprintln!(
"tor --allow-missing-torrc --ignore-missing-torrc --clientonly 1 --socksport 9050 --controlport \
127.0.0.1:9051 --log \"notice stdout\" --clientuseipv6 1",
);
},

e => {
eprintln!("{}", e);
},
}
}
}

impl From<tari_common::ConfigError> for ExitCodes {
fn from(err: tari_common::ConfigError) -> Self {
error!(target: LOG_TARGET, "{}", err);
Self::ConfigError(err.to_string())
}
}

impl From<ConnectivityError> for ExitCodes {
fn from(err: ConnectivityError) -> Self {
error!(target: LOG_TARGET, "{}", err);
Self::NetworkError(err.to_string())
}
}

impl From<RpcError> for ExitCodes {
fn from(err: RpcError) -> Self {
error!(target: LOG_TARGET, "{}", err);
Self::NetworkError(err.to_string())
}
}

#[cfg(feature = "wallet")]
mod wallet {
use super::*;
use tari_wallet::{
error::{WalletError, WalletStorageError},
output_manager_service::error::OutputManagerError,
};

impl From<WalletError> for ExitCodes {
fn from(err: WalletError) -> Self {
error!(target: LOG_TARGET, "{}", err);
Self::WalletError(err.to_string())
}
}

impl From<OutputManagerError> for ExitCodes {
fn from(err: OutputManagerError) -> Self {
error!(target: LOG_TARGET, "{}", err);
Self::WalletError(err.to_string())
}
}

impl From<WalletStorageError> for ExitCodes {
fn from(err: WalletStorageError) -> Self {
use WalletStorageError::*;
match err {
NoPasswordError => ExitCodes::NoPassword,
IncorrectPassword => ExitCodes::IncorrectPassword,
e => ExitCodes::WalletError(e.to_string()),
}
}
}
}

impl From<PeerManagerError> for ExitCodes {
fn from(err: PeerManagerError) -> Self {
ExitCodes::NetworkError(err.to_string())
}
}

impl ExitCodes {
pub fn grpc<M: std::fmt::Display>(err: M) -> Self {
ExitCodes::GrpcError(format!("GRPC connection error: {}", err))
}
}

/// Creates a transport type from the given configuration
///
/// ## Paramters
Expand Down
4 changes: 2 additions & 2 deletions applications/tari_base_node/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,9 @@ use tari_app_utilities::{
consts,
identity_management::setup_node_identity,
initialization::init_configuration,
utilities::{setup_runtime, ExitCodes},
utilities::setup_runtime,
};
use tari_common::{configuration::bootstrap::ApplicationType, ConfigBootstrap, GlobalConfig};
use tari_common::{configuration::bootstrap::ApplicationType, exit_codes::ExitCodes, ConfigBootstrap, GlobalConfig};
use tari_comms::{peer_manager::PeerFeatures, tor::HiddenServiceControllerError};
use tari_core::chain_storage::ChainStorageError;
use tari_shutdown::{Shutdown, ShutdownSignal};
Expand Down
3 changes: 1 addition & 2 deletions applications/tari_base_node/src/recovery.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ use std::{
use anyhow::anyhow;
use log::*;

use tari_app_utilities::utilities::ExitCodes;
use tari_common::{configuration::Network, DatabaseType, GlobalConfig};
use tari_common::{configuration::Network, exit_codes::ExitCodes, DatabaseType, GlobalConfig};
use tari_core::{
chain_storage::{
async_db::AsyncBlockchainDb,
Expand Down
Loading

0 comments on commit 19b2a9d

Please sign in to comment.