Skip to content
This repository has been archived by the owner on Oct 22, 2023. It is now read-only.

Commit

Permalink
remove allow dead code
Browse files Browse the repository at this point in the history
  • Loading branch information
eauge committed Feb 15, 2019
1 parent 2071cdc commit f50b47e
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 23 deletions.
8 changes: 4 additions & 4 deletions gateway/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,11 @@ pub trait ChainNotify: Send + Sync {
pub struct Client {
client: runtime_ethereum::Client,
engine: Arc<EthEngine>,
#[allow(dead_code)]
#[cfg(not(test))]
snapshot_manager: Option<client_utils::db::Manager>,
eip86_transition: u64,
environment: Arc<Environment>,
#[allow(dead_code)]
#[cfg(not(test))]
storage_backend: Arc<StorageBackend>,
/// The most recent block for which we have sent notifications.
notified_block_number: Mutex<BlockNumber>,
Expand Down Expand Up @@ -119,9 +119,11 @@ impl Client {
Self {
client: client,
engine: spec.engine.clone(),
#[cfg(not(test))]
snapshot_manager: snapshot_manager,
eip86_transition: spec.params().eip86_transition,
environment,
#[cfg(not(test))]
storage_backend: backend,
// start at current block
notified_block_number: Mutex::new(current_block_number),
Expand All @@ -141,10 +143,8 @@ impl Client {
Self {
client: test_helpers::get_test_runtime_client(),
engine: spec.engine.clone(),
snapshot_manager: None,
eip86_transition: spec.params().eip86_transition,
environment: environment,
storage_backend: Arc::new(DummyStorageBackend::new()),
notified_block_number: Mutex::new(0),
listeners: RwLock::new(vec![]),
gas_price: U256::from(1_000_000_000),
Expand Down
6 changes: 2 additions & 4 deletions gateway/src/informant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,15 +110,13 @@ impl RpcStats {
.unwrap_or(0)
}

// used for tests
#[allow(dead_code)]
#[cfg(test)]
/// Returns number of open sessions
pub fn sessions(&self) -> usize {
self.sessions.read().len()
}

// used for tests
#[allow(dead_code)]
#[cfg(test)]
/// Returns requests rate
pub fn requests_rate(&self, id: &H256) -> usize {
self.sessions
Expand Down
12 changes: 6 additions & 6 deletions gateway/src/middleware.rs
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ mod tests {
let request_1 = make_request(1);

let response = dispatcher
.on_request(request_1, metadata.clone(), |request, meta| {
.on_request(request_1, metadata.clone(), |_request, _meta| {
Box::new(rpc::futures::finished(None))
})
.wait()
Expand Down Expand Up @@ -284,15 +284,15 @@ mod tests {
let request_1 = make_request(1);
let request_2 = make_request(2);

let response = dispatcher
.on_request(request_1, metadata.clone(), |request, meta| {
let _response = dispatcher
.on_request(request_1, metadata.clone(), |_request, _meta| {
Box::new(rpc::futures::finished(None))
})
.wait()
.unwrap();

let response = dispatcher
.on_request(request_2, metadata.clone(), |request, meta| {
.on_request(request_2, metadata.clone(), |_request, _meta| {
Box::new(rpc::futures::finished(None))
})
.wait()
Expand Down Expand Up @@ -348,7 +348,7 @@ mod tests {

// batch size: 1 (should pass)
let response_1 = middleware
.on_request(batch_1, (), |request, meta| {
.on_request(batch_1, (), |_request, _meta| {
Box::new(rpc::futures::finished(None))
})
.wait()
Expand All @@ -359,7 +359,7 @@ mod tests {

// batch size: 2 (should fail)
let response_2 = middleware
.on_request(batch_2, (), |request, meta| {
.on_request(batch_2, (), |_request, _meta| {
Box::new(rpc::futures::finished(None))
})
.wait()
Expand Down
3 changes: 2 additions & 1 deletion gateway/src/rpc_apis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ impl FromStr for Api {
#[derive(Debug, Clone)]
pub enum ApiSet {
// Used in tests.
#[allow(dead_code)]
#[cfg(test)]
// Safe context (like token-protected WS interface)
SafeContext,
// Unsafe context (like jsonrpc over http)
Expand Down Expand Up @@ -241,6 +241,7 @@ impl ApiSet {
match *self {
ApiSet::List(ref apis) => apis.clone(),
ApiSet::UnsafeContext => public_list,
#[cfg(test)]
ApiSet::SafeContext => public_list,
ApiSet::All => public_list,
}
Expand Down
2 changes: 1 addition & 1 deletion gateway/src/test_helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ impl Database for MockDb {
unimplemented!();
}

fn with_encryption_key<F, R>(&mut self, key: StateKeyType, _f: F) -> R
fn with_encryption_key<F, R>(&mut self, _key: StateKeyType, _f: F) -> R
where
F: FnOnce(&mut DatabaseHandle) -> R,
{
Expand Down
8 changes: 4 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ use std::sync::Arc;
use ekiden_core::error::{Error, Result};
use ekiden_storage_base::StorageBackend;
#[cfg(not(target_env = "sgx"))]
#[allow(dead_code)]
#[cfg(test)]
use ekiden_storage_dummy::DummyStorageBackend;
#[cfg(target_env = "sgx")]
use ekiden_trusted::db::untrusted::UntrustedStorageBackend;
Expand Down Expand Up @@ -155,7 +155,7 @@ pub fn get_block_height(_request: &bool, ctx: &mut RuntimeCallContext) -> Result
Ok(ectx.cache.get_latest_block_number().into())
}

#[allow(dead_code)]
#[cfg(not(feature = "test"))]
fn get_block_hash(id: &BlockId, ctx: &mut RuntimeCallContext) -> Result<Option<H256>> {
let ectx = ctx.runtime.downcast_mut::<EthereumContext>().unwrap();

Expand All @@ -168,7 +168,7 @@ fn get_block_hash(id: &BlockId, ctx: &mut RuntimeCallContext) -> Result<Option<H
Ok(hash)
}

#[allow(dead_code)]
#[cfg(not(feature = "test"))]
fn get_block(id: &BlockId, ctx: &mut RuntimeCallContext) -> Result<Option<Vec<u8>>> {
let ectx = ctx.runtime.downcast_mut::<EthereumContext>().unwrap();

Expand All @@ -189,7 +189,7 @@ fn get_block(id: &BlockId, ctx: &mut RuntimeCallContext) -> Result<Option<Vec<u8
}
}

#[allow(dead_code)]
#[cfg(not(feature = "test"))]
fn get_logs(filter: &Filter, ctx: &mut RuntimeCallContext) -> Result<Vec<Log>> {
let ectx = ctx.runtime.downcast_mut::<EthereumContext>().unwrap();

Expand Down
3 changes: 0 additions & 3 deletions src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -400,9 +400,6 @@ mod tests {

use self::ekiden_storage_dummy::DummyStorageBackend;

#[allow(dead_code)]
use lazy_static;

use super::*;

#[test]
Expand Down

0 comments on commit f50b47e

Please sign in to comment.