Skip to content
Permalink
Browse files

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
  • Loading branch information...
gakonst committed Aug 6, 2019
1 parent f86937f commit 7e2ff6304e5fbf240e40a4bcb88225ebe10201da
@@ -34,6 +34,15 @@ jobs:
source ~/.nvm/nvm.sh
nvm install node
npm install -g ganache-cli
- run:
name: Install the XRP Engine
command: |
sudo apt-get install git
git clone https://github.com/interledgerjs/settlement-xrp
# make the engine globally available
source ~/.nvm/nvm.sh
cd settlement-xrp && npm install
./node_modules/typescript/bin/tsc && npm link && cd ../
- run:
name: Build
command: cargo build --all-features --all-targets
@@ -7,7 +7,7 @@ use futures::{
use hyper::{Response, StatusCode};
use interledger_settlement::Quantity;
use interledger_settlement::{IdempotentData, IdempotentStore};
use log::error;
use log::trace;
use ring::digest::{digest, SHA256};
use tokio::executor::spawn;
use tower_web::{net::ConnectionStream, ServiceBuilder};
@@ -81,8 +81,8 @@ impl_web! {
self.store
.load_idempotent_data(idempotency_key.clone())
.map_err(move |_| {
let error_msg = "Couldn' load idempotent data".to_owned();
error!("{}", error_msg);
let error_msg = "Couldn't load idempotent data".to_owned();
trace!("{}", error_msg);
error_msg
})
.and_then(move |ret: IdempotentData| {
@@ -240,9 +240,10 @@ where
tokio::run(
Interval::new(Instant::now(), interval)
.for_each(move |instant| {
debug!(
trace!(
"[{:?}] Getting settlement data from the blockchain; instant={:?}",
address, instant
address,
instant
);
tokio::spawn(_self.handle_received_transactions());
Ok(())
@@ -290,21 +291,22 @@ where
.block_number()
.map_err(move |err| error!("Could not fetch current block number {:?}", err))
.and_then(move |current_block| {
debug!("Current block {}", current_block);
trace!("Current block {}", current_block);
// get the safe number of blocks to avoid reorgs
let fetch_until = current_block - confirmations;
// U256 does not implement IntoFuture so we must wrap it
Ok((Ok(fetch_until), store.load_recently_observed_block()))
})
.flatten()
.and_then(move |(fetch_until, last_observed_block)| {
debug!(
trace!(
"Will fetch txs from block {} until {}",
last_observed_block, fetch_until
last_observed_block,
fetch_until
);

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

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

fn notify_eth_txs_in_block(&self, block_number: u64) -> impl Future<Item = (), Error = ()> {
debug!("Getting txs for block {}", block_number);
trace!("Getting txs for block {}", block_number);
let self_clone = self.clone();
// Get the block at `block_number`
self.web3
@@ -412,7 +414,7 @@ where
join_all(submit_txs_to_connector_future)
})
.and_then(move |_res| {
debug!(
trace!(
"Successfully logged transactions in block: {:?}",
block_number
);
@@ -678,7 +680,7 @@ where
let data = prefixed_mesage(challenge_clone);
let challenge_hash = Sha3::digest(&data);
let recovered_address = payment_details.sig.recover(&challenge_hash);
debug!("Received payment details {:?}", payment_details);
trace!("Received payment details {:?}", payment_details);
result(recovered_address)
.map_err(move |err| {
let err = format!("Could not recover address {:?}", err);
@@ -695,7 +697,8 @@ where
} else {
let error_msg = format!(
"Recovered address did not match: {:?}. Expected {:?}",
recovered_address, payment_details.to
recovered_address.to_string(),
payment_details.to
);
error!("{}", error_msg);
err((StatusCode::from_u16(502).unwrap(), error_msg))
@@ -10,7 +10,7 @@ use std::collections::HashMap;
use crate::engines::ethereum_ledger::{EthereumAccount, EthereumAddresses, EthereumStore};
use redis::{self, cmd, r#async::SharedConnection, ConnectionInfo, PipelineCommands, Value};

use log::{debug, error};
use log::{error, trace};

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

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

0 comments on commit 7e2ff63

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