From dd8c4ed3728723844fc9407ca89a29006c993c14 Mon Sep 17 00:00:00 2001 From: Sean Gilligan Date: Mon, 14 Aug 2023 15:00:17 -0700 Subject: [PATCH] BlockFileLoaderBitcoindTest: new (ignored) integration test that reads bitcoind blocks This is ignored because: a) It requires bitcoind installation with a blockchain directory b) It takes about 1 hour to run --- .../util/BlockFileLoaderBitcoindTest.java | 52 +++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 integration-test/src/test/java/org/bitcoinj/util/BlockFileLoaderBitcoindTest.java diff --git a/integration-test/src/test/java/org/bitcoinj/util/BlockFileLoaderBitcoindTest.java b/integration-test/src/test/java/org/bitcoinj/util/BlockFileLoaderBitcoindTest.java new file mode 100644 index 000000000..0250ae92a --- /dev/null +++ b/integration-test/src/test/java/org/bitcoinj/util/BlockFileLoaderBitcoindTest.java @@ -0,0 +1,52 @@ +/* + * Copyright by the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.bitcoinj.util; + +import org.bitcoinj.base.BitcoinNetwork; +import org.bitcoinj.core.Block; +import org.bitcoinj.core.Context; +import org.bitcoinj.utils.BlockFileLoader; +import org.junit.Before; +import org.junit.Ignore; +import org.junit.Test; + +import static org.junit.jupiter.api.Assertions.assertTrue; + + +/** + * This is an integration test that REQUIRES a local Bitcoin Core installation + */ +@Ignore("This requires a bitcoind installation AND takes a long time to run.") +public class BlockFileLoaderBitcoindTest { + + @Before + public void setUp() { + Context.propagate(new Context()); + } + + @Test + public void iterateEntireBitcoindBlockchain() { + BlockFileLoader loader = new BlockFileLoader(BitcoinNetwork.MAINNET, BlockFileLoader.getReferenceClientBlockFileList()); + + long blockCount = 0; + for (Block b : loader) { + blockCount++; + System.out.println("Block count: " + blockCount); + } + assertTrue(blockCount > 1); + } +}