Repository: hyperledger/quilt
Pull request #396 (2019-12-05 16:09:20)

deprecate sender amount on request #390
Signed-off-by: Ian Simpson <ian.g.simpson@gmail.com>

codecov[bot]: # [Codecov](https://codecov.io/gh/hyperledger/quilt/pull/396?src=pr&el=h1) Report
> Merging [#396](https://codecov.io/gh/hyperledger/quilt/pull/396?src=pr&el=desc) into [master](https://codecov.io/gh/hyperledger/quilt/commit/731401ec79c9e40cc41135e9d28b0127fc95eb73?src=pr&el=desc) will **increase** coverage by `0.04%`.
> The diff coverage is `n/a`.

[![Impacted file tree graph](https://codecov.io/gh/hyperledger/quilt/pull/396/graphs/tree.svg?width=650&token=XEfCq6zC6W&height=150&src=pr)](https://codecov.io/gh/hyperledger/quilt/pull/396?src=pr&el=tree)

```diff
@@             Coverage Diff              @@
##             master     #396      +/-   ##
============================================
+ Coverage     82.41%   82.45%   +0.04%     
  Complexity      826      826              
============================================
  Files           249      249              
  Lines          3742     3740       -2     
  Branches        228      228              
============================================
  Hits           3084     3084              
+ Misses          562      560       -2     
  Partials         96       96
```


| [Impacted Files](https://codecov.io/gh/hyperledger/quilt/pull/396?src=pr&el=tree) | Coverage Δ | Complexity Δ | |
|---|---|---|---|
| [.../java/org/interledger/stream/SendMoneyRequest.java](https://codecov.io/gh/hyperledger/quilt/pull/396/diff?src=pr&el=tree#diff-c3RyZWFtLXBhcmVudC9zdHJlYW0tY29yZS9zcmMvbWFpbi9qYXZhL29yZy9pbnRlcmxlZGdlci9zdHJlYW0vU2VuZE1vbmV5UmVxdWVzdC5qYXZh) | `0% <ø> (ø)` | `0 <0> (ø)` | :arrow_down: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/hyperledger/quilt/pull/396?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/hyperledger/quilt/pull/396?src=pr&el=footer). Last update [731401e...df16939](https://codecov.io/gh/hyperledger/quilt/pull/396?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).


Patch:
diff --git a/examples-parent/send-money/src/main/java/org/interledger/examples/SendMoneyExample.java b/examples-parent/send-money/src/main/java/org/interledger/examples/SendMoneyExample.java
index d5deab5..4f9fc44 100644
--- a/examples-parent/send-money/src/main/java/org/interledger/examples/SendMoneyExample.java
+++ b/examples-parent/send-money/src/main/java/org/interledger/examples/SendMoneyExample.java
@@ -19,7 +19,6 @@ import org.interledger.spsp.client.rust.InterledgerRustNodeClient;
 import org.interledger.stream.Denominations;
 import org.interledger.stream.SendMoneyRequest;
 import org.interledger.stream.SendMoneyResult;
-import org.interledger.stream.SenderAmountMode;
 import org.interledger.stream.sender.FixedSenderAmountPaymentTracker;
 import org.interledger.stream.sender.SimpleStreamSender;
 
@@ -75,7 +74,6 @@ public class SendMoneyExample {
     SendMoneyResult result = simpleStreamSender.sendMoney(
         SendMoneyRequest.builder()
             .sourceAddress(SENDER_ADDRESS)
-            .senderAmountMode(SenderAmountMode.SENDER_AMOUNT)
             .amount(UnsignedLong.valueOf(100000))
             .denomination(Denominations.XRP)
             .destinationAddress(connectionDetails.destinationAddress())
diff --git a/stream-parent/stream-core/src/main/java/org/interledger/stream/SendMoneyRequest.java b/stream-parent/stream-core/src/main/java/org/interledger/stream/SendMoneyRequest.java
index 32920ae..5f6b75c 100644
--- a/stream-parent/stream-core/src/main/java/org/interledger/stream/SendMoneyRequest.java
+++ b/stream-parent/stream-core/src/main/java/org/interledger/stream/SendMoneyRequest.java
@@ -5,10 +5,10 @@ import org.interledger.core.InterledgerAddress;
 import org.interledger.core.SharedSecret;
 
 import com.google.common.primitives.UnsignedLong;
-import org.immutables.value.Value.Check;
 
 import java.time.Duration;
 import java.util.Optional;
+import javax.annotation.Nullable;
 
 @Immutable
 public interface SendMoneyRequest {
@@ -41,17 +41,20 @@ public interface SendMoneyRequest {
   InterledgerAddress destinationAddress();
 
   /**
-   * The amount of units to send. The denomination of this unit depends on the value of {@link #getSenderAmountMode()}.
+   * The amount of units to send.
    *
    * @return An {@link UnsignedLong} containing the amount of this payment.
    */
   UnsignedLong amount();
 
   /**
+   * @deprecated ascertained via the type of payment tracker used for sending.
    * Returns the {@link SenderAmountMode} for this payment tracker.
    *
    * @return A {@link SenderAmountMode} that indicates the meaning of {@link #amount()}.
    */
+  @Deprecated
+  @Nullable
   SenderAmountMode getSenderAmountMode();
 
   /**
@@ -81,15 +84,12 @@ public interface SendMoneyRequest {
   PaymentTracker<SenderAmountMode> paymentTracker();
 
   /**
-   * Ensures that this request's SenderAmountMode is compatible with {@link PaymentTracker#getOriginalAmountMode()}.
+   * @deprecated no longer performs a check on compatible SenderAmountMode since payment tracker is the authority
    *
-   * @return {@code true} if the SenderAmountMode is compatible with the PaymentTracker; {@code false} otherwise.
+   * @return this instance
    */
-  @Check
+  @Deprecated
   default SendMoneyRequest check() {
-    if (this.paymentTracker().getOriginalAmountMode() != this.getSenderAmountMode()) {
-      throw new IllegalStateException("PaymentTracker is not compatible with this SenderAmountMode");
-    }
     return this;
   }
 }


Test patch:
diff --git a/stream-parent/stream-client/src/test/java/org/interledger/stream/sender/SendMoneyAggregatorTest.java b/stream-parent/stream-client/src/test/java/org/interledger/stream/sender/SendMoneyAggregatorTest.java
index 12b69e7..8edd3d2 100644
--- a/stream-parent/stream-client/src/test/java/org/interledger/stream/sender/SendMoneyAggregatorTest.java
+++ b/stream-parent/stream-client/src/test/java/org/interledger/stream/sender/SendMoneyAggregatorTest.java
@@ -103,7 +103,6 @@ public class SendMoneyAggregatorTest {
     SendMoneyRequest request = SendMoneyRequest.builder()
         .sharedSecret(sharedSecret)
         .sourceAddress(sourceAddress)
-        .senderAmountMode(SenderAmountMode.SENDER_AMOUNT)
         .destinationAddress(destinationAddress)
         .amount(originalAmountToSend)
         .timeout(Optional.of(Duration.ofSeconds(60)))
@@ -214,7 +213,6 @@ public class SendMoneyAggregatorTest {
         .sharedSecret(sharedSecret)
         .sourceAddress(sourceAddress)
         .amount(originalAmountToSend)
-        .senderAmountMode(SenderAmountMode.SENDER_AMOUNT)
         .destinationAddress(destinationAddress)
         .timeout(Optional.of(Duration.ofSeconds(60)))
         .denomination(Denominations.XRP)
@@ -344,7 +342,6 @@ public class SendMoneyAggregatorTest {
     SendMoneyRequest request = SendMoneyRequest.builder()
         .sharedSecret(sharedSecret)
         .sourceAddress(sourceAddress)
-        .senderAmountMode(SenderAmountMode.SENDER_AMOUNT)
         .destinationAddress(destinationAddress)
         .amount(originalAmountToSend)
         .timeout(Optional.of(Duration.ofSeconds(60)))
diff --git a/stream-parent/stream-client/src/test/java/org/interledger/stream/sender/SimpleStreamSenderIT.java b/stream-parent/stream-client/src/test/java/org/interledger/stream/sender/SimpleStreamSenderIT.java
index 018d096..b2fc7d6 100644
--- a/stream-parent/stream-client/src/test/java/org/interledger/stream/sender/SimpleStreamSenderIT.java
+++ b/stream-parent/stream-client/src/test/java/org/interledger/stream/sender/SimpleStreamSenderIT.java
@@ -15,16 +15,15 @@ import org.interledger.link.http.OutgoingLinkSettings;
 import org.interledger.link.http.auth.SimpleBearerTokenSupplier;
 import org.interledger.spsp.PaymentPointer;
 import org.interledger.spsp.StreamConnectionDetails;
-import org.interledger.spsp.client.SpspClientDefaults;
 import org.interledger.spsp.client.SimpleSpspClient;
-import org.interledger.spsp.client.rust.RustNodeAccount;
+import org.interledger.spsp.client.SpspClientDefaults;
 import org.interledger.spsp.client.rust.ImmutableRustNodeAccount;
 import org.interledger.spsp.client.rust.InterledgerRustNodeClient;
+import org.interledger.spsp.client.rust.RustNodeAccount;
 import org.interledger.stream.Denomination;
 import org.interledger.stream.Denominations;
 import org.interledger.stream.SendMoneyRequest;
 import org.interledger.stream.SendMoneyResult;
-import org.interledger.stream.SenderAmountMode;
 import org.interledger.stream.calculators.ExchangeRateCalculator;
 import org.interledger.stream.calculators.NoExchangeRateException;
 import org.interledger.stream.calculators.NoOpExchangeRateCalculator;
@@ -169,7 +168,6 @@ public class SimpleStreamSenderIT {
         .sourceAddress(SENDER_ADDRESS)
         .amount(paymentAmount)
         .denomination(Denominations.XRP)
-        .senderAmountMode(SenderAmountMode.SENDER_AMOUNT)
         .destinationAddress(connectionDetails.destinationAddress())
         .paymentTracker(new FixedSenderAmountPaymentTracker(paymentAmount, new NoOpExchangeRateCalculator()))
         .sharedSecret(connectionDetails.sharedSecret())
@@ -204,7 +202,6 @@ public class SimpleStreamSenderIT {
             .sourceAddress(SENDER_ADDRESS)
             .amount(paymentAmount)
             .denomination(Denominations.XRP)
-            .senderAmountMode(SenderAmountMode.SENDER_AMOUNT)
             .destinationAddress(connectionDetails.destinationAddress())
             .paymentTracker(new FixedSenderAmountPaymentTracker(paymentAmount, new NoOpExchangeRateCalculator()))
             .sharedSecret(connectionDetails.sharedSecret())
@@ -244,7 +241,6 @@ public class SimpleStreamSenderIT {
               .sourceAddress(SENDER_ADDRESS)
               .amount(paymentAmount)
               .denomination(Denominations.XRP)
-              .senderAmountMode(SenderAmountMode.SENDER_AMOUNT)
               .destinationAddress(connectionDetails.destinationAddress())
               .sharedSecret(connectionDetails.sharedSecret())
               .paymentTracker(new FixedSenderAmountPaymentTracker(paymentAmount, new NoOpExchangeRateCalculator()))
@@ -305,7 +301,6 @@ public class SimpleStreamSenderIT {
         SendMoneyRequest.builder()
             .sourceAddress(SENDER_ADDRESS)
             .amount(paymentAmount)
-            .senderAmountMode(SenderAmountMode.SENDER_AMOUNT)
             .denomination(Denominations.XRP)
             .destinationAddress(connectionDetails.destinationAddress())
             .sharedSecret(connectionDetails.sharedSecret())
@@ -395,7 +390,6 @@ public class SimpleStreamSenderIT {
                 .sourceAddress(SENDER_ADDRESS)
                 .amount(paymentAmount)
                 .denomination(Denominations.XRP)
-                .senderAmountMode(SenderAmountMode.SENDER_AMOUNT)
                 .destinationAddress(connectionDetails.destinationAddress())
                 .sharedSecret(connectionDetails.sharedSecret())
                 .paymentTracker(new FixedSenderAmountPaymentTracker(paymentAmount, new NoOpExchangeRateCalculator()))
@@ -434,7 +428,6 @@ public class SimpleStreamSenderIT {
         .sourceAddress(SENDER_ADDRESS)
         .amount(paymentAmount)
         .denomination(Denominations.XRP)
-        .senderAmountMode(SenderAmountMode.SENDER_AMOUNT)
         .destinationAddress(connectionDetails.destinationAddress())
         .paymentTracker(new FixedSenderAmountPaymentTracker(paymentAmount, noExchangeRateExceptionCalculator))
         .sharedSecret(connectionDetails.sharedSecret())
@@ -467,7 +460,6 @@ public class SimpleStreamSenderIT {
         .sourceAddress(SENDER_ADDRESS)
         .amount(paymentAmount)
         .denomination(Denominations.XRP)
-        .senderAmountMode(SenderAmountMode.SENDER_AMOUNT)
         .destinationAddress(connectionDetails.destinationAddress())
         .paymentTracker(new FixedSenderAmountPaymentTracker(paymentAmount, new NoOpExchangeRateCalculator()))
         .sharedSecret(connectionDetails.sharedSecret())
@@ -498,7 +490,6 @@ public class SimpleStreamSenderIT {
         .sourceAddress(SENDER_ADDRESS)
         .amount(paymentAmount)
         .denomination(Denominations.XRP)
-        .senderAmountMode(SenderAmountMode.SENDER_AMOUNT)
         .destinationAddress(connectionDetails.destinationAddress())
         .paymentTracker(new FixedSenderAmountPaymentTracker(paymentAmount, new GreedyExchangeRateCalculator()))
         .sharedSecret(connectionDetails.sharedSecret())
@@ -555,7 +546,6 @@ public class SimpleStreamSenderIT {
             .destinationAddress(connectionDetails.destinationAddress())
             .amount(paymentAmount)
             .denomination(Denominations.XRP)
-            .senderAmountMode(SenderAmountMode.SENDER_AMOUNT)
             .sharedSecret(connectionDetails.sharedSecret())
             .paymentTracker(new FixedSenderAmountPaymentTracker(paymentAmount, new NoOpExchangeRateCalculator()))
             .timeout(Duration.ofMillis(100L))
@@ -599,7 +589,6 @@ public class SimpleStreamSenderIT {
             .destinationAddress(connectionDetails.destinationAddress())
             .amount(paymentAmount)
             .denomination(Denominations.XRP)
-            .senderAmountMode(SenderAmountMode.SENDER_AMOUNT)
             .sharedSecret(connectionDetails.sharedSecret())
             .paymentTracker(new FixedSenderAmountPaymentTracker(paymentAmount, new NoOpExchangeRateCalculator()))
             .build()
diff --git a/stream-parent/stream-receiver/src/test/java/org/interledger/stream/receiver/SenderReceiverTest.java b/stream-parent/stream-receiver/src/test/java/org/interledger/stream/receiver/SenderReceiverTest.java
index 2024f9a..757b5b6 100644
--- a/stream-parent/stream-receiver/src/test/java/org/interledger/stream/receiver/SenderReceiverTest.java
+++ b/stream-parent/stream-receiver/src/test/java/org/interledger/stream/receiver/SenderReceiverTest.java
@@ -1,8 +1,6 @@
 package org.interledger.stream.receiver;
 
 import static org.assertj.core.api.Assertions.assertThat;
-import static org.interledger.stream.SenderAmountMode.RECEIVER_AMOUNT;
-import static org.interledger.stream.SenderAmountMode.SENDER_AMOUNT;
 
 import org.interledger.codecs.stream.StreamCodecContextFactory;
 import org.interledger.core.Immutable;
@@ -141,7 +139,6 @@ public class SenderReceiverTest {
         SendMoneyRequest.builder()
             .sourceAddress(leftStreamNode.senderAddress())
             .amount(amountToDeliver)
-            .senderAmountMode(RECEIVER_AMOUNT)
             .denomination(leftStreamNode.denomination())
             .destinationAddress(connectionDetails.destinationAddress())
             .sharedSecret(connectionDetails.sharedSecret())
@@ -182,7 +179,6 @@ public class SenderReceiverTest {
         SendMoneyRequest.builder()
             .sharedSecret(connectionDetails.sharedSecret())
             .amount(paymentAmount)
-            .senderAmountMode(RECEIVER_AMOUNT)
             .denomination(leftStreamNode.denomination())
             .destinationAddress(connectionDetails.destinationAddress())
             .sourceAddress(leftStreamNode.senderAddress())
@@ -224,7 +220,6 @@ public class SenderReceiverTest {
         SendMoneyRequest.builder()
             .sourceAddress(leftStreamNode.senderAddress())
             .amount(paymentAmount)
-            .senderAmountMode(RECEIVER_AMOUNT)
             .denomination(leftStreamNode.denomination())
             .destinationAddress(connectionDetails.destinationAddress())
             .sharedSecret(connectionDetails.sharedSecret())
@@ -253,7 +248,6 @@ public class SenderReceiverTest {
         SendMoneyRequest.builder()
             .sourceAddress(rightStreamNode.senderAddress())
             .amount(paymentAmount)
-            .senderAmountMode(SENDER_AMOUNT)
             .denomination(rightStreamNode.denomination())
             .destinationAddress(connectionDetails.destinationAddress())
             .sharedSecret(connectionDetails.sharedSecret())
@@ -424,7 +418,6 @@ public class SenderReceiverTest {
         SendMoneyRequest.builder()
             .sourceAddress(fromNode.senderAddress())
             .amount(paymentAmount)
-            .senderAmountMode(SENDER_AMOUNT)
             .denomination(fromNode.denomination())
             .destinationAddress(connectionDetails.destinationAddress())
             .sharedSecret(connectionDetails.sharedSecret())