Skip to content

Commit 7e2ff63

Browse files
authored
XRP and ETH Engine E2E Tests (#184)
* ci: Install the XRP engine in Circle * test(xrp-engine): add test helper to launch a redis server with a specific port we need this helper because we need a redis store's port to give as an env variable to the xrp engine * test(xrp-engine): add e2e test for XRP ledger engine * examples: add example script for running xrp test * feat: add test XRP - ETH 3 Node E2E Test + Settlement (#187) * test(engines): add e2e test with 3 nodes and settlement in XRP and ETH * test(engines): refactor commonly used functions in test helpers use helpers in xrp test use helpers in interop test * add README for interop test
1 parent f86937f commit 7e2ff63

File tree

19 files changed

+1718
-255
lines changed

19 files changed

+1718
-255
lines changed

.circleci/config.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,15 @@ jobs:
3434
source ~/.nvm/nvm.sh
3535
nvm install node
3636
npm install -g ganache-cli
37+
- run:
38+
name: Install the XRP Engine
39+
command: |
40+
sudo apt-get install git
41+
git clone https://github.com/interledgerjs/settlement-xrp
42+
# make the engine globally available
43+
source ~/.nvm/nvm.sh
44+
cd settlement-xrp && npm install
45+
./node_modules/typescript/bin/tsc && npm link && cd ../
3746
- run:
3847
name: Build
3948
command: cargo build --all-features --all-targets

crates/interledger-settlement-engines/src/api.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use futures::{
77
use hyper::{Response, StatusCode};
88
use interledger_settlement::Quantity;
99
use interledger_settlement::{IdempotentData, IdempotentStore};
10-
use log::error;
10+
use log::trace;
1111
use ring::digest::{digest, SHA256};
1212
use tokio::executor::spawn;
1313
use tower_web::{net::ConnectionStream, ServiceBuilder};
@@ -81,8 +81,8 @@ impl_web! {
8181
self.store
8282
.load_idempotent_data(idempotency_key.clone())
8383
.map_err(move |_| {
84-
let error_msg = "Couldn' load idempotent data".to_owned();
85-
error!("{}", error_msg);
84+
let error_msg = "Couldn't load idempotent data".to_owned();
85+
trace!("{}", error_msg);
8686
error_msg
8787
})
8888
.and_then(move |ret: IdempotentData| {

crates/interledger-settlement-engines/src/engines/ethereum_ledger/eth_engine.rs

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -240,9 +240,10 @@ where
240240
tokio::run(
241241
Interval::new(Instant::now(), interval)
242242
.for_each(move |instant| {
243-
debug!(
243+
trace!(
244244
"[{:?}] Getting settlement data from the blockchain; instant={:?}",
245-
address, instant
245+
address,
246+
instant
246247
);
247248
tokio::spawn(_self.handle_received_transactions());
248249
Ok(())
@@ -290,21 +291,22 @@ where
290291
.block_number()
291292
.map_err(move |err| error!("Could not fetch current block number {:?}", err))
292293
.and_then(move |current_block| {
293-
debug!("Current block {}", current_block);
294+
trace!("Current block {}", current_block);
294295
// get the safe number of blocks to avoid reorgs
295296
let fetch_until = current_block - confirmations;
296297
// U256 does not implement IntoFuture so we must wrap it
297298
Ok((Ok(fetch_until), store.load_recently_observed_block()))
298299
})
299300
.flatten()
300301
.and_then(move |(fetch_until, last_observed_block)| {
301-
debug!(
302+
trace!(
302303
"Will fetch txs from block {} until {}",
303-
last_observed_block, fetch_until
304+
last_observed_block,
305+
fetch_until
304306
);
305307

306308
let notify_all_txs_fut = if let Some(token_address) = token_address {
307-
debug!("Settling for ERC20 transactions");
309+
trace!("Settling for ERC20 transactions");
308310
// get all erc20 transactions
309311
let notify_all_erc20_txs_fut = filter_transfer_logs(
310312
web3.clone(),
@@ -325,7 +327,7 @@ where
325327
// combine all erc20 futures for that range of blocks
326328
Either::A(notify_all_erc20_txs_fut)
327329
} else {
328-
debug!("Settling for ETH transactions");
330+
trace!("Settling for ETH transactions");
329331
let checked_blocks = last_observed_block.low_u64()..=fetch_until.low_u64();
330332
// for each block create a future which will notify the
331333
// connector about all the transactions in that block that are sent to our account
@@ -337,7 +339,7 @@ where
337339
};
338340

339341
notify_all_txs_fut.and_then(move |ret| {
340-
debug!("Transactions settled {:?}", ret);
342+
trace!("Transactions settled {:?}", ret);
341343
// now that all transactions have been processed successfully, we
342344
// can save `fetch_until` as the latest observed block
343345
store_clone.save_recently_observed_block(fetch_until)
@@ -384,7 +386,7 @@ where
384386
}
385387

386388
fn notify_eth_txs_in_block(&self, block_number: u64) -> impl Future<Item = (), Error = ()> {
387-
debug!("Getting txs for block {}", block_number);
389+
trace!("Getting txs for block {}", block_number);
388390
let self_clone = self.clone();
389391
// Get the block at `block_number`
390392
self.web3
@@ -412,7 +414,7 @@ where
412414
join_all(submit_txs_to_connector_future)
413415
})
414416
.and_then(move |_res| {
415-
debug!(
417+
trace!(
416418
"Successfully logged transactions in block: {:?}",
417419
block_number
418420
);
@@ -678,7 +680,7 @@ where
678680
let data = prefixed_mesage(challenge_clone);
679681
let challenge_hash = Sha3::digest(&data);
680682
let recovered_address = payment_details.sig.recover(&challenge_hash);
681-
debug!("Received payment details {:?}", payment_details);
683+
trace!("Received payment details {:?}", payment_details);
682684
result(recovered_address)
683685
.map_err(move |err| {
684686
let err = format!("Could not recover address {:?}", err);
@@ -695,7 +697,8 @@ where
695697
} else {
696698
let error_msg = format!(
697699
"Recovered address did not match: {:?}. Expected {:?}",
698-
recovered_address, payment_details.to
700+
recovered_address.to_string(),
701+
payment_details.to
699702
);
700703
error!("{}", error_msg);
701704
err((StatusCode::from_u16(502).unwrap(), error_msg))

crates/interledger-settlement-engines/src/stores/redis_ethereum_ledger/store.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use std::collections::HashMap;
1010
use crate::engines::ethereum_ledger::{EthereumAccount, EthereumAddresses, EthereumStore};
1111
use redis::{self, cmd, r#async::SharedConnection, ConnectionInfo, PipelineCommands, Value};
1212

13-
use log::{debug, error};
13+
use log::{error, trace};
1414

1515
use crate::stores::redis_store_common::{EngineRedisStore, EngineRedisStoreBuilder};
1616

@@ -112,7 +112,6 @@ impl EthereumStore for EthereumLedgerRedisStore {
112112
&self,
113113
account_ids: Vec<<Self::Account as AccountTrait>::AccountId>,
114114
) -> Box<dyn Future<Item = Vec<EthereumAddresses>, Error = ()> + Send> {
115-
debug!("Loading account addresses {:?}", account_ids);
116115
let mut pipe = redis::pipe();
117116
for account_id in account_ids.iter() {
118117
pipe.hgetall(ethereum_ledger_key(*account_id));
@@ -127,7 +126,7 @@ impl EthereumStore for EthereumLedgerRedisStore {
127126
})
128127
.and_then(
129128
move |(_conn, addresses): (_, Vec<HashMap<String, Vec<u8>>>)| {
130-
debug!("Loaded account addresses {:?}", addresses);
129+
trace!("Loaded account addresses {:?}", addresses);
131130
let mut ret = Vec::with_capacity(addresses.len());
132131
for addr in &addresses {
133132
let own_address = if let Some(own_address) = addr.get("own_address") {

0 commit comments

Comments
 (0)