3
0
mirror of https://github.com/Qortal/altcoinj.git synced 2025-01-31 15:22:16 +00:00

Fix a payment protocol unit test that had a forgotten @Test annotation and thus didn't actually work.

This commit is contained in:
Mike Hearn 2014-07-05 17:27:22 +02:00
parent 5580fd9d92
commit bb40036453
2 changed files with 31 additions and 25 deletions

View File

@ -23,6 +23,7 @@ import com.google.bitcoin.core.NetworkParameters;
import com.google.bitcoin.core.Transaction;
import com.google.bitcoin.crypto.X509Utils;
import com.google.bitcoin.script.ScriptBuilder;
import com.google.common.base.Objects;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
import com.google.protobuf.ByteString;
@ -269,6 +270,16 @@ public class PaymentProtocol {
throw new PaymentProtocolException.PkiVerificationException(x);
}
}
@Override
public String toString() {
return Objects.toStringHelper(this)
.add("displayName", displayName)
.add("rootAuthorityName", rootAuthorityName)
.add("merchantSigningKey", merchantSigningKey)
.add("rootAuthority", rootAuthority)
.toString();
}
}
/**

View File

@ -16,16 +16,15 @@
package com.google.bitcoin.protocols.payments;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import java.security.KeyStore;
import java.security.PrivateKey;
import java.security.cert.X509Certificate;
import java.util.LinkedList;
import java.util.List;
import com.google.bitcoin.core.*;
import com.google.bitcoin.crypto.X509Utils;
import com.google.bitcoin.params.TestNet3Params;
import com.google.bitcoin.params.UnitTestParams;
import com.google.bitcoin.protocols.payments.PaymentProtocol.Output;
import com.google.bitcoin.protocols.payments.PaymentProtocol.PkiVerificationData;
import com.google.bitcoin.protocols.payments.PaymentProtocolException.PkiVerificationException;
import com.google.bitcoin.script.ScriptBuilder;
import com.google.bitcoin.testing.FakeTxBuilder;
import org.bitcoin.protocols.payments.Protos;
import org.bitcoin.protocols.payments.Protos.Payment;
import org.bitcoin.protocols.payments.Protos.PaymentACK;
@ -33,18 +32,13 @@ import org.bitcoin.protocols.payments.Protos.PaymentRequest;
import org.junit.Before;
import org.junit.Test;
import com.google.bitcoin.core.Address;
import com.google.bitcoin.core.Coin;
import com.google.bitcoin.core.ECKey;
import com.google.bitcoin.core.NetworkParameters;
import com.google.bitcoin.core.Transaction;
import com.google.bitcoin.crypto.X509Utils;
import com.google.bitcoin.params.UnitTestParams;
import com.google.bitcoin.protocols.payments.PaymentProtocol.Output;
import com.google.bitcoin.protocols.payments.PaymentProtocol.PkiVerificationData;
import com.google.bitcoin.protocols.payments.PaymentProtocolException.PkiVerificationException;
import com.google.bitcoin.script.ScriptBuilder;
import com.google.bitcoin.testing.FakeTxBuilder;
import java.security.KeyStore;
import java.security.PrivateKey;
import java.security.cert.X509Certificate;
import java.util.LinkedList;
import java.util.List;
import static org.junit.Assert.*;
public class PaymentProtocolTest {
@ -105,9 +99,10 @@ public class PaymentProtocolTest {
return paymentRequest.build();
}
@Test
public void testPaymentRequest() throws Exception {
// Create
PaymentRequest paymentRequest = PaymentProtocol.createPaymentRequest(NETWORK_PARAMS, AMOUNT, TO_ADDRESS, MEMO,
PaymentRequest paymentRequest = PaymentProtocol.createPaymentRequest(TestNet3Params.get(), AMOUNT, TO_ADDRESS, MEMO,
PAYMENT_URL, MERCHANT_DATA).build();
byte[] paymentRequestBytes = paymentRequest.toByteArray();
@ -117,10 +112,10 @@ public class PaymentProtocolTest {
final List<Output> parsedOutputs = parsedPaymentRequest.getOutputs();
assertEquals(1, parsedOutputs.size());
assertEquals(AMOUNT, parsedOutputs.get(0).amount);
assertEquals(ScriptBuilder.createOutputScript(TO_ADDRESS).getProgram(), parsedOutputs.get(0).scriptData);
assertArrayEquals(ScriptBuilder.createOutputScript(TO_ADDRESS).getProgram(), parsedOutputs.get(0).scriptData);
assertEquals(MEMO, parsedPaymentRequest.getMemo());
assertEquals(PAYMENT_URL, parsedPaymentRequest.getPaymentUrl());
assertEquals(MERCHANT_DATA, parsedPaymentRequest.getMerchantData());
assertArrayEquals(MERCHANT_DATA, parsedPaymentRequest.getMerchantData());
}
@Test