Skip to content
Permalink
Browse files

refactor: replace lazy_static with once_cell (#618)

* refactor: replace lazy_static with once_cell

* ci: ignore security advisory for lazy_static
  • Loading branch information
Ben Striegel
Ben Striegel committed Feb 4, 2020
1 parent a4885bc commit 96c187d3c5a5fe55b7010d581c306856f749dd5f
Showing with 615 additions and 618 deletions.
  1. +2 −3 .circleci/config.yml
  2. +20 −14 Cargo.lock
  3. +2 −2 crates/ilp-node/Cargo.toml
  4. +2 −4 crates/ilp-node/src/node.rs
  5. +1 −1 crates/interledger-api/Cargo.toml
  6. +8 −7 crates/interledger-api/src/routes/test_helpers.rs
  7. +1 −1 crates/interledger-btp/Cargo.toml
  8. +4 −5 crates/interledger-btp/src/lib.rs
  9. +40 −40 crates/interledger-btp/src/packet.rs
  10. +3 −5 crates/interledger-btp/src/service.rs
  11. +2 −2 crates/interledger-ccp/Cargo.toml
  12. +81 −59 crates/interledger-ccp/src/fixtures.rs
  13. +9 −9 crates/interledger-ccp/src/packet.rs
  14. +2 −4 crates/interledger-ccp/src/routing_table.rs
  15. +74 −68 crates/interledger-ccp/src/server.rs
  16. +19 −20 crates/interledger-ccp/src/test_helpers.rs
  17. +1 −1 crates/interledger-errors/Cargo.toml
  18. +7 −8 crates/interledger-errors/src/error/error_types.rs
  19. +2 −4 crates/interledger-errors/src/error/mod.rs
  20. +1 −1 crates/interledger-http/Cargo.toml
  21. +8 −7 crates/interledger-http/src/server.rs
  22. +1 −1 crates/interledger-ildcp/Cargo.toml
  23. +3 −5 crates/interledger-ildcp/src/packet.rs
  24. +4 −5 crates/interledger-ildcp/src/server.rs
  25. +1 −1 crates/interledger-packet/Cargo.toml
  26. +38 −39 crates/interledger-packet/benches/packets.rs
  27. +4 −6 crates/interledger-packet/src/address.rs
  28. +29 −33 crates/interledger-packet/src/fixtures.rs
  29. +12 −14 crates/interledger-packet/src/oer.rs
  30. +1 −1 crates/interledger-router/Cargo.toml
  31. +4 −5 crates/interledger-router/src/router.rs
  32. +1 −1 crates/interledger-service-util/Cargo.toml
  33. +4 −5 crates/interledger-service-util/src/echo_service.rs
  34. +8 −8 crates/interledger-service-util/src/exchange_rate_providers/coincap.rs
  35. +4 −6 crates/interledger-service-util/src/exchange_rate_providers/cryptocompare.rs
  36. +2 −4 crates/interledger-service-util/src/exchange_rates_service.rs
  37. +4 −5 crates/interledger-service-util/src/expiry_shortener_service.rs
  38. +5 −5 crates/interledger-service-util/src/validator_service.rs
  39. +1 −1 crates/interledger-service/Cargo.toml
  40. +4 −5 crates/interledger-service/src/lib.rs
  41. +3 −5 crates/interledger-service/src/username.rs
  42. +1 −1 crates/interledger-settlement/Cargo.toml
  43. +15 −14 crates/interledger-settlement/src/api/fixtures.rs
  44. +2 −4 crates/interledger-settlement/src/api/test_helpers.rs
  45. +2 −4 crates/interledger-settlement/src/core/backends_common/redis/test_helpers/store_helpers.rs
  46. +3 −5 crates/interledger-settlement/src/core/types.rs
  47. +1 −1 crates/interledger-store/Cargo.toml
  48. +23 −25 crates/interledger-store/src/account.rs
  49. +29 −23 crates/interledger-store/src/redis/mod.rs
  50. +66 −74 crates/interledger-store/tests/redis/redis_tests.rs
  51. +2 −4 crates/interledger-store/tests/redis/settlement_test.rs
  52. +2 −2 crates/interledger-stream/Cargo.toml
  53. +6 −6 crates/interledger-stream/src/congestion.rs
  54. +17 −13 crates/interledger-stream/src/crypto.rs
  55. +6 −6 crates/interledger-stream/src/lib.rs
  56. +18 −16 crates/interledger-stream/src/packet.rs
@@ -45,9 +45,8 @@ jobs:
- run:
name: Audit Dependencies
# Disable:
# 1. lazy_static advisory: https://github.com/interledger-rs/interledger-rs/issues/588
# 2. http/hyper advisory: outdated http due to yup-oauth2 3.1.1, tungstenite 0.9.2
command: cargo audit --ignore RUSTSEC-2019-0033 --ignore RUSTSEC-2019-0034 --ignore RUSTSEC-2019-0031
# 1. http/hyper advisory: outdated http due to yup-oauth2 3.1.1, tungstenite 0.9.2
command: cargo audit --ignore RUSTSEC-2019-0033 --ignore RUSTSEC-2019-0034

test-md:
docker:

Some generated files are not rendered by default. Learn more.

@@ -39,7 +39,7 @@ config = { version = "0.9.3", default-features = false, features = ["json", "tom
futures = { version = "0.3.1", default-features = false, features = ["compat"] }
hex = { version = "0.4.0", default-features = false }
interledger = { path = "../interledger", version = "^0.6.0", default-features = false, features = ["node"] }
lazy_static = { version = "1.4.0", default-features = false }
once_cell = "1.3.1"
num-bigint = { version = "0.2.3", default-features = false, features = ["std"] }
redis_crate = { package = "redis", version = "0.15.1", optional = true, features = ["tokio-rt-core"] }
ring = { version = "0.16.9", default-features = false }
@@ -79,4 +79,4 @@ tokio-retry = { version = "0.2.0", default-features = false }

[badges]
circle-ci = { repository = "interledger-rs/interledger-rs" }
codecov = { repository = "interledger-rs/interledger-rs" }
codecov = { repository = "interledger-rs/interledger-rs" }
@@ -54,8 +54,8 @@ use interledger::{
store::account::Account,
stream::{StreamNotificationsStore, StreamReceiverService},
};
use lazy_static::lazy_static;
use num_bigint::BigUint;
use once_cell::sync::Lazy;
use serde::{de::Error as DeserializeError, Deserialize, Deserializer};
use std::{convert::TryFrom, net::SocketAddr, str, str::FromStr, time::Duration};
use tokio::spawn;
@@ -72,9 +72,7 @@ use interledger::service_util::BalanceService;
#[doc(hidden)]
pub use interledger::service_util::ExchangeRateProvider;

lazy_static! {
static ref DEFAULT_ILP_ADDRESS: Address = Address::from_str("local.host").unwrap();
}
static DEFAULT_ILP_ADDRESS: Lazy<Address> = Lazy::new(|| Address::from_str("local.host").unwrap());

fn default_settlement_api_bind_address() -> SocketAddr {
SocketAddr::from(([127, 0, 0, 1], 7771))
@@ -32,7 +32,7 @@ url = { version = "2.1.0", default-features = false, features = ["serde"] }
uuid = { version = "0.8.1", default-features = false}
warp = { version = "0.2", default-features = false }
secrecy = { version = "0.6", default-features = false, features = ["serde"] }
lazy_static = "1.4.0"
once_cell = "1.3.1"
async-trait = "0.1.22"
interledger-errors = { path = "../interledger-errors", version = "^0.1.0", default-features = false, features = ["warp_errors"] }

@@ -18,7 +18,7 @@ use interledger_service::{
use interledger_service_util::{BalanceStore, ExchangeRateStore};
use interledger_settlement::core::types::{SettlementAccount, SettlementEngineDetails};
use interledger_stream::{PaymentNotification, StreamNotificationsStore};
use lazy_static::lazy_static;
use once_cell::sync::Lazy;
use secrecy::SecretString;
use serde::{Deserialize, Serialize};
use serde_json::Value;
@@ -101,17 +101,18 @@ pub fn test_accounts_api(
struct TestStore;

use serde_json::json;
lazy_static! {
pub static ref USERNAME: Username = Username::from_str("alice").unwrap();
pub static ref EXAMPLE_ADDRESS: Address = Address::from_str("example.alice").unwrap();
pub static ref DETAILS: Option<Value> = Some(json!({
pub static USERNAME: Lazy<Username> = Lazy::new(|| Username::from_str("alice").unwrap());
pub static EXAMPLE_ADDRESS: Lazy<Address> =
Lazy::new(|| Address::from_str("example.alice").unwrap());
pub static DETAILS: Lazy<Option<Value>> = Lazy::new(|| {
Some(json!({
"ilp_address": "example.alice",
"username": "alice",
"asset_code": "XYZ",
"asset_scale": 9,
"ilp_over_http_incoming_token" : "password",
}));
}
}))
});
const AUTH_PASSWORD: &str = "password";

#[derive(Clone, Debug, Deserialize, Serialize)]
@@ -32,7 +32,7 @@ warp = { version = "0.2", default-features = false, features = ["websocket"] }
secrecy = "0.6"
async-trait = "0.1.22"
tokio = { version = "0.2.8", features = ["rt-core", "time", "stream", "macros"] }
lazy_static = { version = "1.4.0", default-features = false }
once_cell = "1.3.1"
pin-project = "0.4.6"
thiserror = "1.0.10"

@@ -63,7 +63,7 @@ mod client_server {
};
use uuid::Uuid;

use lazy_static::lazy_static;
use once_cell::sync::Lazy;

fn get_open_port() -> SocketAddr {
for _i in 0..1000 {
@@ -76,10 +76,9 @@ mod client_server {
panic!("Cannot find open port!");
}

lazy_static! {
pub static ref ALICE: Username = Username::from_str("alice").unwrap();
pub static ref EXAMPLE_ADDRESS: Address = Address::from_str("example.alice").unwrap();
}
pub static ALICE: Lazy<Username> = Lazy::new(|| Username::from_str("alice").unwrap());
pub static EXAMPLE_ADDRESS: Lazy<Address> =
Lazy::new(|| Address::from_str("example.alice").unwrap());

#[derive(Clone, Debug)]
pub struct TestAccount {

0 comments on commit 96c187d

Please sign in to comment.
You can’t perform that action at this time.