Skip to content

Commit 8d31b44

Browse files
committed
adapter - enable test-util for primitives
1 parent ad912f8 commit 8d31b44

File tree

5 files changed

+18
-26
lines changed

5 files changed

+18
-26
lines changed

adapter/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ edition = "2021"
1010

1111
[features]
1212

13-
test-util = []
13+
test-util = ["primitives/test-util"]
1414

1515
[dependencies]
1616
primitives = { path = "../primitives" }

adapter/src/ethereum.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,10 @@ mod test {
501501
use super::test_util::*;
502502
use super::*;
503503
use chrono::Utc;
504-
use primitives::{config::DEVELOPMENT_CONFIG, test_util::{LEADER, CREATOR, IDS}};
504+
use primitives::{
505+
config::DEVELOPMENT_CONFIG,
506+
test_util::{CREATOR, IDS, LEADER},
507+
};
505508
use web3::{transports::Http, Web3};
506509
use wiremock::{
507510
matchers::{method, path},

adapter/src/ethereum/test_util.rs

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -194,11 +194,7 @@ pub async fn deploy_sweeper_contract(
194194
opt.gas_price = Some(1.into());
195195
opt.gas = Some(6_721_975.into());
196196
}))
197-
.execute(
198-
*SWEEPER_BYTECODE,
199-
(),
200-
H160(LEADER.to_bytes()),
201-
)
197+
.execute(*SWEEPER_BYTECODE, (), H160(LEADER.to_bytes()))
202198
.await?;
203199

204200
let sweeper_address = Address::from(sweeper_contract.address().to_fixed_bytes());
@@ -217,18 +213,14 @@ pub async fn deploy_outpace_contract(
217213
opt.gas_price = Some(1.into());
218214
opt.gas = Some(6_721_975.into());
219215
}))
220-
.execute(
221-
*OUTPACE_BYTECODE,
222-
(),
223-
H160(LEADER.to_bytes()),
224-
)
216+
.execute(*OUTPACE_BYTECODE, (), H160(LEADER.to_bytes()))
225217
.await?;
226218
let outpace_address = Address::from(outpace_contract.address().to_fixed_bytes());
227219

228220
Ok((outpace_address, outpace_contract))
229221
}
230222

231-
/// Deploys the Mock Token contract from `GANACHE_ADDRESS['leader']`
223+
/// Deploys the Mock Token contract from [`LEADER`]
232224
pub async fn deploy_token_contract(
233225
web3: &Web3<Http>,
234226
min_token_units: u64,
@@ -240,11 +232,7 @@ pub async fn deploy_token_contract(
240232
opt.gas_price = Some(1.into());
241233
opt.gas = Some(6_721_975.into());
242234
}))
243-
.execute(
244-
*MOCK_TOKEN_BYTECODE,
245-
(),
246-
H160(LEADER.to_bytes()),
247-
)
235+
.execute(*MOCK_TOKEN_BYTECODE, (), H160(LEADER.to_bytes()))
248236
.await?;
249237

250238
let token_info = TokenInfo {

primitives/src/test_util.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ use crate::Address;
55
/// re-export all other statics before moving all of them to this module
66
pub use crate::util::tests::prep_db::*;
77

8-
pub static LEADER: Lazy<Address> = Lazy::new(|| ADDRESS_0.clone());
9-
pub static FOLLOWER: Lazy<Address> = Lazy::new(|| ADDRESS_1.clone());
10-
pub static GUARDIAN: Lazy<Address> = Lazy::new(|| ADDRESS_2.clone());
11-
pub static CREATOR: Lazy<Address> = Lazy::new(|| ADDRESS_3.clone());
12-
pub static ADVERTISER: Lazy<Address> = Lazy::new(|| ADDRESS_4.clone());
13-
pub static PUBLISHER: Lazy<Address> = Lazy::new(|| ADDRESS_5.clone());
14-
pub static GUARDIAN_2: Lazy<Address> = Lazy::new(|| ADDRESS_6.clone());
8+
pub static LEADER: Lazy<Address> = Lazy::new(|| *ADDRESS_0);
9+
pub static FOLLOWER: Lazy<Address> = Lazy::new(|| *ADDRESS_1);
10+
pub static GUARDIAN: Lazy<Address> = Lazy::new(|| *ADDRESS_2);
11+
pub static CREATOR: Lazy<Address> = Lazy::new(|| *ADDRESS_3);
12+
pub static ADVERTISER: Lazy<Address> = Lazy::new(|| *ADDRESS_4);
13+
pub static PUBLISHER: Lazy<Address> = Lazy::new(|| *ADDRESS_5);
14+
pub static GUARDIAN_2: Lazy<Address> = Lazy::new(|| *ADDRESS_6);
1515

1616
/// passhprase: ganache0
1717
pub static ADDRESS_0: Lazy<Address> = Lazy::new(|| {

sentry/src/spender.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ pub mod fee {
2020
#[cfg(test)]
2121
mod test {
2222
use primitives::{
23-
test_util::{PUBLISHER, DUMMY_VALIDATOR_LEADER}, UnifiedNum,
23+
test_util::{DUMMY_VALIDATOR_LEADER, PUBLISHER},
24+
UnifiedNum,
2425
};
2526

2627
use crate::spender::fee::calculate_fee;

0 commit comments

Comments
 (0)