Skip to content

Commit

Permalink
Try to fix functional tests
Browse files Browse the repository at this point in the history
  • Loading branch information
h4sh3d committed Nov 26, 2021
1 parent aab2c0b commit 349d860
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 12 deletions.
9 changes: 6 additions & 3 deletions src/syncerd/bitcoin_syncer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,8 @@ fn address_polling(
Ok(client) => client,
Err(err) => {
error!(
"failed to spawn electrum rpc client in address polling: {:?}",
"failed to spawn electrum rpc client ({}) t in address polling: {:?}",
&electrum_server,
err
);
// wait a bit before retrying the connection
Expand Down Expand Up @@ -588,7 +589,8 @@ fn height_polling(
Ok(client) => client,
Err(err) => {
error!(
"failed to spawn electrum rpc client in height polling: {:?}",
"failed to spawn electrum rpc client ({}) in height polling: {:?}",
&electrum_server,
err
);
// wait a bit before retrying the connection
Expand Down Expand Up @@ -646,7 +648,8 @@ fn transaction_polling(
Ok(client) => client,
Err(err) => {
error!(
"failed to spawn electrum rpc client in transaction polling: {:?}",
"failed to spawn electrum rpc client ({}) in transaction polling: {:?}",
&electrum_server,
err
);
// wait a bit before retrying the connection
Expand Down
19 changes: 13 additions & 6 deletions tests/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: "3.7"
services:
bitcoin-core:
image: ghcr.io/farcaster-project/containers/bitcoin-core:latest
image: ghcr.io/farcaster-project/containers/bitcoin-core:22.0
environment:
NETWORK: regtest
RPC_PORT: 18443
Expand All @@ -10,15 +10,18 @@ services:
- ./data_dir:/data
ports:
- 18443:18443
- 18444:18444
electrs:
image: ghcr.io/farcaster-project/containers/electrs:latest
command: "/usr/bin/electrs -vv --network regtest --daemon-dir /data --daemon-rpc-addr bitcoin-core:18443 --electrum-rpc-addr 0.0.0.0:50001 --txid-limit 100000"
image: ghcr.io/farcaster-project/containers/electrs:0.9.3
command: "/usr/bin/electrs --log-filters info --network regtest --daemon-dir /data --daemon-rpc-addr bitcoin-core:18443 --daemon-p2p-addr bitcoin-core:18444 --electrum-rpc-addr 0.0.0.0:50001"
depends_on:
- "bitcoin-core"
volumes:
- ./data_dir:/data
ports:
- 50001:50001
monerod:
image: ghcr.io/farcaster-project/containers/monerod:latest
image: ghcr.io/farcaster-project/containers/monerod:0.17.2.3
environment:
NETWORK: regtest
MONEROD_RPC_PORT: 18081
Expand All @@ -27,15 +30,19 @@ services:
ports:
- 18081:18081
monero-wallet-rpc-1:
image: ghcr.io/farcaster-project/containers/monero-wallet-rpc:latest
image: ghcr.io/farcaster-project/containers/monero-wallet-rpc:0.17.2.3
environment:
MONEROD_ADDRESS: monerod:18081
depends_on:
- "monerod"
ports:
- 18083:18083
monero-wallet-rpc-2:
image: ghcr.io/farcaster-project/containers/monero-wallet-rpc:latest
image: ghcr.io/farcaster-project/containers/monero-wallet-rpc:0.17.2.3
environment:
MONEROD_ADDRESS: monerod:18081
depends_on:
- "monerod"
ports:
- 18084:18083

15 changes: 12 additions & 3 deletions tests/functional.rs
Original file line number Diff line number Diff line change
Expand Up @@ -786,6 +786,7 @@ fn create_bitcoin_syncer(
polling: bool,
socket_name: &str,
) -> (std::sync::mpsc::Sender<SyncerdTask>, zmq::Socket) {
env_logger::init();
let addr = format!("inproc://testmonerobridge-{}", socket_name);

let (tx, rx): (Sender<SyncerdTask>, Receiver<SyncerdTask>) = std::sync::mpsc::channel();
Expand All @@ -795,7 +796,12 @@ fn create_bitcoin_syncer(
rx_event.bind(&addr).unwrap();
let mut syncer = BitcoinSyncer::new();

let opts = Opts::parse_from(vec!["--electrum-server", "tcp://localhost:50001"]);
let opts = Opts::parse_from(vec!["syncerd"].into_iter().chain(vec![
"--coin",
"Bitcoin",
"--electrum-server",
"tcp://localhost:50001",
]));

syncer
.run(
Expand Down Expand Up @@ -1507,6 +1513,7 @@ async fn setup_monero() -> (monero_rpc::RegtestDaemonClient, monero_rpc::WalletC
}

fn create_monero_syncer(socket_name: &str) -> (std::sync::mpsc::Sender<SyncerdTask>, zmq::Socket) {
env_logger::init();
let addr = format!("inproc://testmonerobridge-{}", socket_name);
let (tx, rx): (Sender<SyncerdTask>, Receiver<SyncerdTask>) = std::sync::mpsc::channel();
let tx_event = ZMQ_CONTEXT.socket(zmq::PAIR).unwrap();
Expand All @@ -1515,12 +1522,14 @@ fn create_monero_syncer(socket_name: &str) -> (std::sync::mpsc::Sender<SyncerdTa
rx_event.bind(&addr).unwrap();
let mut syncer = MoneroSyncer::new();

let opts = Opts::parse_from(vec![
let opts = Opts::parse_from(vec!["syncerd"].into_iter().chain(vec![
"--coin",
"Monero",
"--monero-daemon",
"http://localhost:18081",
"--monero-rpc-wallet",
"http://localhost:18084",
]);
]));

syncer
.run(
Expand Down

0 comments on commit 349d860

Please sign in to comment.