3
0
mirror of https://github.com/Qortal/altcoinj.git synced 2025-02-07 14:54:15 +00:00

Payment channels: fix unit test and add a log line.

This commit is contained in:
Mike Hearn 2013-09-05 15:17:15 +02:00
parent 24a5c05546
commit 11ab82c91e
2 changed files with 8 additions and 2 deletions

View File

@ -396,6 +396,7 @@ public class PaymentChannelServerState {
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");
feePaidForPayment = req.fee;
log.info("Calculated fee is {}", feePaidForPayment);
if (feePaidForPayment.compareTo(bestValueToMe) >= 0)
throw new ValueOutOfRangeException(String.format("Had to pay more in fees (%s) than the channel was worth (%s)",
feePaidForPayment, bestValueToMe));

View File

@ -650,7 +650,12 @@ public class PaymentChannelStateTest extends TestWithWallet {
serverState = new PaymentChannelServerState(mockBroadcaster, serverWallet, serverKey, EXPIRE_TIME);
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());
clientState.initiate();
assertEquals(PaymentChannelClientState.State.INITIATED, clientState.getState());
@ -705,7 +710,7 @@ public class PaymentChannelStateTest extends TestWithWallet {
serverState.close();
fail();
} 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));