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:
parent
5580fd9d92
commit
bb40036453
@ -23,6 +23,7 @@ import com.google.bitcoin.core.NetworkParameters;
|
|||||||
import com.google.bitcoin.core.Transaction;
|
import com.google.bitcoin.core.Transaction;
|
||||||
import com.google.bitcoin.crypto.X509Utils;
|
import com.google.bitcoin.crypto.X509Utils;
|
||||||
import com.google.bitcoin.script.ScriptBuilder;
|
import com.google.bitcoin.script.ScriptBuilder;
|
||||||
|
import com.google.common.base.Objects;
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import com.google.protobuf.ByteString;
|
import com.google.protobuf.ByteString;
|
||||||
@ -269,6 +270,16 @@ public class PaymentProtocol {
|
|||||||
throw new PaymentProtocolException.PkiVerificationException(x);
|
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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -16,16 +16,15 @@
|
|||||||
|
|
||||||
package com.google.bitcoin.protocols.payments;
|
package com.google.bitcoin.protocols.payments;
|
||||||
|
|
||||||
import static org.junit.Assert.assertArrayEquals;
|
import com.google.bitcoin.core.*;
|
||||||
import static org.junit.Assert.assertEquals;
|
import com.google.bitcoin.crypto.X509Utils;
|
||||||
import static org.junit.Assert.assertNotNull;
|
import com.google.bitcoin.params.TestNet3Params;
|
||||||
|
import com.google.bitcoin.params.UnitTestParams;
|
||||||
import java.security.KeyStore;
|
import com.google.bitcoin.protocols.payments.PaymentProtocol.Output;
|
||||||
import java.security.PrivateKey;
|
import com.google.bitcoin.protocols.payments.PaymentProtocol.PkiVerificationData;
|
||||||
import java.security.cert.X509Certificate;
|
import com.google.bitcoin.protocols.payments.PaymentProtocolException.PkiVerificationException;
|
||||||
import java.util.LinkedList;
|
import com.google.bitcoin.script.ScriptBuilder;
|
||||||
import java.util.List;
|
import com.google.bitcoin.testing.FakeTxBuilder;
|
||||||
|
|
||||||
import org.bitcoin.protocols.payments.Protos;
|
import org.bitcoin.protocols.payments.Protos;
|
||||||
import org.bitcoin.protocols.payments.Protos.Payment;
|
import org.bitcoin.protocols.payments.Protos.Payment;
|
||||||
import org.bitcoin.protocols.payments.Protos.PaymentACK;
|
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.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import com.google.bitcoin.core.Address;
|
import java.security.KeyStore;
|
||||||
import com.google.bitcoin.core.Coin;
|
import java.security.PrivateKey;
|
||||||
import com.google.bitcoin.core.ECKey;
|
import java.security.cert.X509Certificate;
|
||||||
import com.google.bitcoin.core.NetworkParameters;
|
import java.util.LinkedList;
|
||||||
import com.google.bitcoin.core.Transaction;
|
import java.util.List;
|
||||||
import com.google.bitcoin.crypto.X509Utils;
|
|
||||||
import com.google.bitcoin.params.UnitTestParams;
|
import static org.junit.Assert.*;
|
||||||
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;
|
|
||||||
|
|
||||||
public class PaymentProtocolTest {
|
public class PaymentProtocolTest {
|
||||||
|
|
||||||
@ -105,9 +99,10 @@ public class PaymentProtocolTest {
|
|||||||
return paymentRequest.build();
|
return paymentRequest.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testPaymentRequest() throws Exception {
|
public void testPaymentRequest() throws Exception {
|
||||||
// Create
|
// 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();
|
PAYMENT_URL, MERCHANT_DATA).build();
|
||||||
byte[] paymentRequestBytes = paymentRequest.toByteArray();
|
byte[] paymentRequestBytes = paymentRequest.toByteArray();
|
||||||
|
|
||||||
@ -117,10 +112,10 @@ public class PaymentProtocolTest {
|
|||||||
final List<Output> parsedOutputs = parsedPaymentRequest.getOutputs();
|
final List<Output> parsedOutputs = parsedPaymentRequest.getOutputs();
|
||||||
assertEquals(1, parsedOutputs.size());
|
assertEquals(1, parsedOutputs.size());
|
||||||
assertEquals(AMOUNT, parsedOutputs.get(0).amount);
|
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(MEMO, parsedPaymentRequest.getMemo());
|
||||||
assertEquals(PAYMENT_URL, parsedPaymentRequest.getPaymentUrl());
|
assertEquals(PAYMENT_URL, parsedPaymentRequest.getPaymentUrl());
|
||||||
assertEquals(MERCHANT_DATA, parsedPaymentRequest.getMerchantData());
|
assertArrayEquals(MERCHANT_DATA, parsedPaymentRequest.getMerchantData());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
Loading…
Reference in New Issue
Block a user