3
0
mirror of https://github.com/Qortal/altcoinj.git synced 2025-01-30 23:02:15 +00:00

Tests for completing transactions with non-standard fees.

This commit is contained in:
Andreas Schildbach 2014-11-13 00:52:08 +01:00
parent b7166d650d
commit 91f3d23165

View File

@ -2280,6 +2280,42 @@ public class WalletTest extends TestWithWallet {
assertEquals(Transaction.REFERENCE_DEFAULT_MIN_TX_FEE, request.tx.getFee());
}
@Test
public void lowerThanDefaultFee() throws InsufficientMoneyException {
Coin fee = Transaction.REFERENCE_DEFAULT_MIN_TX_FEE.divide(10);
receiveATransactionAmount(wallet, myAddress, Coin.COIN);
SendRequest req = SendRequest.to(myAddress, Coin.CENT);
req.feePerKb = fee;
wallet.completeTx(req);
assertEquals(fee, req.tx.getFee());
wallet.commitTx(req.tx);
SendRequest emptyReq = SendRequest.emptyWallet(myAddress);
emptyReq.feePerKb = fee;
emptyReq.emptyWallet = true;
emptyReq.coinSelector = AllowUnconfirmedCoinSelector.get();
wallet.completeTx(emptyReq);
assertEquals(fee, emptyReq.tx.getFee());
wallet.commitTx(emptyReq.tx);
}
@Test
public void higherThanDefaultFee() throws InsufficientMoneyException {
Coin fee = Transaction.REFERENCE_DEFAULT_MIN_TX_FEE.multiply(10);
receiveATransactionAmount(wallet, myAddress, Coin.COIN);
SendRequest req = SendRequest.to(myAddress, Coin.CENT);
req.feePerKb = fee;
wallet.completeTx(req);
assertEquals(fee, req.tx.getFee());
wallet.commitTx(req.tx);
SendRequest emptyReq = SendRequest.emptyWallet(myAddress);
emptyReq.feePerKb = fee;
emptyReq.emptyWallet = true;
emptyReq.coinSelector = AllowUnconfirmedCoinSelector.get();
wallet.completeTx(emptyReq);
assertEquals(fee, emptyReq.tx.getFee());
wallet.commitTx(emptyReq.tx);
}
@Test
public void feePerKbCategoryJumpTest() throws Exception {
// Simple test of boundary condition on fee per kb in category fee solver