mirror of
https://github.com/Qortal/altcoinj.git
synced 2025-02-12 10:15:52 +00:00
Payment channels: fix unit test and add a log line.
This commit is contained in:
parent
24a5c05546
commit
11ab82c91e
@ -396,6 +396,7 @@ public class PaymentChannelServerState {
|
|||||||
if (!wallet.completeTx(req)) // Let wallet handle adding additional inputs/fee as necessary.
|
if (!wallet.completeTx(req)) // Let wallet handle adding additional inputs/fee as necessary.
|
||||||
throw new ValueOutOfRangeException("Unable to complete transaction - unable to pay required fee");
|
throw new ValueOutOfRangeException("Unable to complete transaction - unable to pay required fee");
|
||||||
feePaidForPayment = req.fee;
|
feePaidForPayment = req.fee;
|
||||||
|
log.info("Calculated fee is {}", feePaidForPayment);
|
||||||
if (feePaidForPayment.compareTo(bestValueToMe) >= 0)
|
if (feePaidForPayment.compareTo(bestValueToMe) >= 0)
|
||||||
throw new ValueOutOfRangeException(String.format("Had to pay more in fees (%s) than the channel was worth (%s)",
|
throw new ValueOutOfRangeException(String.format("Had to pay more in fees (%s) than the channel was worth (%s)",
|
||||||
feePaidForPayment, bestValueToMe));
|
feePaidForPayment, bestValueToMe));
|
||||||
|
@ -650,7 +650,12 @@ public class PaymentChannelStateTest extends TestWithWallet {
|
|||||||
serverState = new PaymentChannelServerState(mockBroadcaster, serverWallet, serverKey, EXPIRE_TIME);
|
serverState = new PaymentChannelServerState(mockBroadcaster, serverWallet, serverKey, EXPIRE_TIME);
|
||||||
assertEquals(PaymentChannelServerState.State.WAITING_FOR_REFUND_TRANSACTION, serverState.getState());
|
assertEquals(PaymentChannelServerState.State.WAITING_FOR_REFUND_TRANSACTION, serverState.getState());
|
||||||
|
|
||||||
clientState = new PaymentChannelClientState(wallet, myKey, new ECKey(null, serverKey.getPubKey()), Utils.CENT, EXPIRE_TIME);
|
clientState = new PaymentChannelClientState(wallet, myKey, new ECKey(null, serverKey.getPubKey()), Utils.CENT, EXPIRE_TIME) {
|
||||||
|
@Override
|
||||||
|
protected void editContractSendRequest(Wallet.SendRequest req) {
|
||||||
|
req.coinSelector = wallet.getCoinSelector();
|
||||||
|
}
|
||||||
|
};
|
||||||
assertEquals(PaymentChannelClientState.State.NEW, clientState.getState());
|
assertEquals(PaymentChannelClientState.State.NEW, clientState.getState());
|
||||||
clientState.initiate();
|
clientState.initiate();
|
||||||
assertEquals(PaymentChannelClientState.State.INITIATED, clientState.getState());
|
assertEquals(PaymentChannelClientState.State.INITIATED, clientState.getState());
|
||||||
@ -705,7 +710,7 @@ public class PaymentChannelStateTest extends TestWithWallet {
|
|||||||
serverState.close();
|
serverState.close();
|
||||||
fail();
|
fail();
|
||||||
} catch (ValueOutOfRangeException e) {
|
} catch (ValueOutOfRangeException e) {
|
||||||
assertTrue(e.getMessage().contains("more in fees than the channel was worth"));
|
assertTrue(e.getMessage().contains("more in fees"));
|
||||||
}
|
}
|
||||||
|
|
||||||
signature = clientState.incrementPaymentBy(BigInteger.ONE.shiftLeft(1));
|
signature = clientState.incrementPaymentBy(BigInteger.ONE.shiftLeft(1));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user