// Path: wallet_lib/src/main/java/de/uni_bonn/bit/BitcoinECMathHelper.java
// public static ECKey convertBigIntToPrivKey(BigInteger bigInt){
//     checkArgument(bigInt.compareTo(BigInteger.ONE) >= 0, "A private key must be >= 1");
//     checkArgument(bigInt.compareTo(ECKey.CURVE.getN()) < 0, "A private key must be <= N_EC");
//     return ECKey.fromPrivate(bigInt);
// }


import org.bitcoinj.core.*;
import org.bitcoinj.params.UnitTestParams;
import de.uni_bonn.bit.wallet_protocol.*;
import org.apache.avro.ipc.NettyServer;
import org.apache.avro.ipc.NettyTransceiver;
import org.apache.avro.ipc.reflect.ReflectRequestor;
import org.apache.avro.ipc.reflect.ReflectResponder;
import org.junit.Test;
import java.io.IOException;
import java.math.BigInteger;
import java.net.InetSocketAddress;
import java.util.Map;
import static de.uni_bonn.bit.BitcoinECMathHelper.convertBigIntToPrivKey;
/*
* Copyright 2014 Christopher Mann
*
* 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 de.uni_bonn.bit;




/**
 * This class performs the same tests as {@link de.uni_bonn.bit.TransactionSignerTests}, but all messages
 * are exchanged via serialization. This class primarily checks that the Avro serialization used for the
 * communication between desktop and phone can successfully (de)serialize all objects required for the
 * protocol.
 */
public class TransactionSignerSerializationTests extends TransactionSignerBaseTest {

    /**
     * Similar to {@link TransactionSignerTests#testTheTransactionSigners()}, this test signs a
     * Bitcoin transaction with the two-party ECDSA signature protocol. All messages exchanged between
     * the {@link de.uni_bonn.bit.DesktopTransactionSigner} and the {@link de.uni_bonn.bit.PhoneTransactionSigner}
     * are serialized and sent over the local loopback. This test primarily exists to check that the
     * (de)serialization with avro works correctly.
     * @throws InsufficientMoneyException
     */
    @Test
    public void testTheTransactionSigners() throws InsufficientMoneyException, IOException, InterruptedException {
// Path: wallet_lib/src/main/java/de/uni_bonn/bit/BitcoinECMathHelper.java
// public static ECKey convertBigIntToPrivKey(BigInteger bigInt){
//     checkArgument(bigInt.compareTo(BigInteger.ONE) >= 0, "A private key must be >= 1");
//     checkArgument(bigInt.compareTo(ECKey.CURVE.getN()) < 0, "A private key must be <= N_EC");
//     return ECKey.fromPrivate(bigInt);
// }


// Path: wallet_lib/src/test/java/de/uni_bonn/bit/TransactionSignerSerializationTests.java
import org.bitcoinj.core.*;
import org.bitcoinj.params.UnitTestParams;
import de.uni_bonn.bit.wallet_protocol.*;
import org.apache.avro.ipc.NettyServer;
import org.apache.avro.ipc.NettyTransceiver;
import org.apache.avro.ipc.reflect.ReflectRequestor;
import org.apache.avro.ipc.reflect.ReflectResponder;
import org.junit.Test;
import java.io.IOException;
import java.math.BigInteger;
import java.net.InetSocketAddress;
import java.util.Map;
import static de.uni_bonn.bit.BitcoinECMathHelper.convertBigIntToPrivKey;

/*
* Copyright 2014 Christopher Mann
*
* 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 de.uni_bonn.bit;




/**
 * This class performs the same tests as {@link de.uni_bonn.bit.TransactionSignerTests}, but all messages
 * are exchanged via serialization. This class primarily checks that the Avro serialization used for the
 * communication between desktop and phone can successfully (de)serialize all objects required for the
 * protocol.
 */
public class TransactionSignerSerializationTests extends TransactionSignerBaseTest {

    /**
     * Similar to {@link TransactionSignerTests#testTheTransactionSigners()}, this test signs a
     * Bitcoin transaction with the two-party ECDSA signature protocol. All messages exchanged between
     * the {@link de.uni_bonn.bit.DesktopTransactionSigner} and the {@link de.uni_bonn.bit.PhoneTransactionSigner}
     * are serialized and sent over the local loopback. This test primarily exists to check that the
     * (de)serialization with avro works correctly.
     * @throws InsufficientMoneyException
     */
    @Test
    public void testTheTransactionSigners() throws InsufficientMoneyException, IOException, InterruptedException {
        ECKey receiverKey = convertBigIntToPrivKey(new BigInteger("100"));