/*
 * 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.drausin.bitflow.bitcoin;

import static org.junit.Assert.assertTrue;

import com.google.common.collect.ImmutableList;
import org.drausin.bitflow.bitcoin.api.requests.BitcoinNodeRequest;
import org.drausin.bitflow.bitcoin.api.responses.BlockchainInfoResponse;
import org.drausin.bitflow.integration.AbstractIntegrationTest;
import org.junit.Test;

public final class BitcoinNodeServerIntegrationTests extends AbstractIntegrationTest {

    @Test
    public void testGetBlockchainInfo() {

        BitcoinNodeRequest request = BitcoinNodeRequest.of("getblockchaininfo", ImmutableList.of());
        BlockchainInfoResponse response = getBitcoinNode().getBlockchainInfo(request);

        assertTrue(response.validateResult());
        assertTrue(response.getResult().get().getNumBlocks() > 0);
    }
}

@@ -649,47 +649,36 @@
 ort 
-com.google.common.collect.ImmutableList
+org.bitcoinj.core.Sha256Hash
 ;%0Aim
@@ -739,24 +739,169 @@
 odeRequest;%0A
+import org.drausin.bitflow.bitcoin.api.requests.BitcoinNodeRequestFactory;%0Aimport org.drausin.bitflow.bitcoin.api.responses.BlockHeaderResponse;%0A
 import org.d
@@ -1217,17 +1217,31 @@
 Request 
-r
+blockchainInfoR
 equest =
@@ -1263,51 +1263,504 @@
 uest
-.of(%22getblockchaininfo%22, ImmutableList.of()
+Factory.createBlockchainInfoRequest();%0A        BlockchainInfoResponse blockchainInfoResponse = getBitcoinNode().getBlockchainInfo(blockchainInfoRequest);%0A%0A        assertTrue(blockchainInfoResponse.validateResult());%0A        assertTrue(blockchainInfoResponse.getResult().get().getNumBlocks() %3E 0);%0A    %7D%0A%0A    @Test%0A    public void testGetBlockHeader() %7B%0A%0A        // first get blockchain info%0A        BitcoinNodeRequest blockchainInfoRequest = BitcoinNodeRequestFactory.createBlockchainInfoRequest(
 );%0A 
@@ -1789,17 +1789,31 @@
 esponse 
-r
+blockchainInfoR
 esponse 
@@ -1849,17 +1849,428 @@
 ainInfo(
-r
+blockchainInfoRequest);%0A        blockchainInfoResponse.validateResult();%0A%0A        // make request for best block%0A        Sha256Hash headerHash = blockchainInfoResponse.getResult().get().getBestBlockHash();%0A        BitcoinNodeRequest blockHeaderRequest = BitcoinNodeRequestFactory.createBlockHeaderRequest(headerHash);%0A        BlockHeaderResponse blockHeaderResponse = getBitcoinNode().getBlockHeader(blockHeaderR
 equest);
@@ -2282,33 +2282,44 @@
      assertTrue(
-r
+blockHeaderR
 esponse.validate
@@ -2348,17 +2348,28 @@
 ertTrue(
-r
+blockHeaderR
 esponse.
@@ -2385,33 +2385,45 @@
 ().get().get
-NumBlocks
+TransactionIds().size
 () %3E 0);%0A   
@@ -2415,20 +2415,21 @@
 ize() %3E 0);%0A
+%0A
     %7D%0A%7D%0A

add simple getBlockHeader() test