Run blockchain tests on esplora

They were only being run on electrum before.
This commit is contained in:
LLFourn 2021-05-18 15:21:48 +10:00
parent 465ef6e674
commit fcae5adabd
No known key found for this signature in database
GPG Key ID: A27093B54DA11F65
5 changed files with 30 additions and 8 deletions

View File

@ -73,10 +73,19 @@ jobs:
- name: Test
run: cargo test --features test-md-docs --no-default-features -- doctest::ReadmeDoctests
test-electrum:
name: Test electrum
test-blockchains:
name: test ${{ matrix.blockchain.name }}
runs-on: ubuntu-16.04
container: bitcoindevkit/electrs:0.2.0
strategy:
matrix:
blockchain:
- name: electrum
container: bitcoindevkit/electrs
start: /root/electrs --network regtest --jsonrpc-import
- name: esplora
container: bitcoindevkit/esplora
start: /root/electrs --network regtest -vvv --cookie admin:passw --jsonrpc-import --electrum-rpc-addr=0.0.0.0:60401 --http-addr 0.0.0.0:3002
container: ${{ matrix.blockchain.container }}
env:
BDK_RPC_AUTH: USER_PASS
BDK_RPC_USER: admin
@ -84,6 +93,7 @@ jobs:
BDK_RPC_URL: 127.0.0.1:18443
BDK_RPC_WALLET: bdk-test
BDK_ELECTRUM_URL: tcp://127.0.0.1:60401
BDK_ESPLORA_URL: http://127.0.0.1:3002
steps:
- name: Checkout
uses: actions/checkout@v2
@ -95,6 +105,8 @@ jobs:
~/.cargo/git
target
key: ${{ runner.os }}-cargo-${{ github.job }}-${{ hashFiles('**/Cargo.toml','**/Cargo.lock') }}
- name: get pkg-config # running eslpora tests seems to need this
run: apt update && apt install -y --fix-missing pkg-config libssl-dev
- name: Install rustup
run: curl https://sh.rustup.rs -sSf | sh -s -- -y
- name: Set default toolchain
@ -105,8 +117,10 @@ jobs:
run: $HOME/.cargo/bin/rustup update
- name: Start core
run: ./ci/start-core.sh
- name: start ${{ matrix.blockchain.name }}
run: nohup ${{ matrix.blockchain.start }} & sleep 5
- name: Test
run: $HOME/.cargo/bin/cargo test --features test-electrum --no-default-features
run: $HOME/.cargo/bin/cargo test --features test-${{ matrix.blockchain.name }} --no-default-features ${{ matrix.blockchain.name }}::bdk_blockchain_tests
check-wasm:
name: Check WASM

View File

@ -55,6 +55,7 @@ keys-bip39 = ["tiny-bip39"]
# Debug/Test features
test-electrum = ["electrum"]
test-esplora = ["esplora"]
test-md-docs = ["electrum"]
[dev-dependencies]

View File

@ -11,7 +11,3 @@ done
echo "Generating 150 bitcoin blocks."
ADDR=$(/root/bitcoin-cli -regtest -rpcuser=$BDK_RPC_USER -rpcpassword=$BDK_RPC_PASS -rpcwallet=$BDK_RPC_WALLET getnewaddress)
/root/bitcoin-cli -regtest -rpcuser=$BDK_RPC_USER -rpcpassword=$BDK_RPC_PASS generatetoaddress 150 $ADDR
echo "Starting electrs node."
nohup /root/electrs --network regtest --jsonrpc-import &
sleep 5

View File

@ -414,3 +414,11 @@ impl_error!(reqwest::Error, Reqwest, EsploraError);
impl_error!(std::num::ParseIntError, Parsing, EsploraError);
impl_error!(consensus::encode::Error, BitcoinEncoding, EsploraError);
impl_error!(bitcoin::hashes::hex::Error, Hex, EsploraError);
#[cfg(all(feature = "test-esplora", test))]
testutils::bdk_blockchain_tests! {
bdk => crate,
fn test_instance() -> EsploraBlockchain {
EsploraBlockchain::new(std::env::var("BDK_ESPLORA_URL").unwrap_or("127.0.0.1:3002".into()).as_str(), None)
}
}

View File

@ -193,6 +193,9 @@ macro_rules! bdk_blockchain_tests {
assert_eq!(list_tx_item.height, None);
}
// FIXME: I would like this to be cfg_attr(not(feature = "test-esplora"), ignore) but it
// doesn't work for some reason.
#[cfg(not(feature = "test-esplora"))]
#[test]
#[serial]
fn test_sync_reorg_block() {