Skip to content

Commit

Permalink
test: add test case where changeIndex == 0 and outputs.length > 0
Browse files Browse the repository at this point in the history
  • Loading branch information
ShookLyngs committed Jun 14, 2024
1 parent d886b25 commit b8a99b6
Showing 1 changed file with 47 additions and 1 deletion.
48 changes: 47 additions & 1 deletion packages/btc/tests/Transaction.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -885,7 +885,7 @@ describe('Transaction', () => {
});
});

describe('sendRbf()', () => {
describe.skip('sendRbf()', () => {
it('Full RBF', async () => {
/**
* TX_1, feeRate=minimumFee/2
Expand Down Expand Up @@ -1029,6 +1029,52 @@ describe('Transaction', () => {
feeRate: expectFeeRate2,
});
}, 0);
it('Full RBF with changeIndex, outputs.length != changeIndex + 1', async () => {
/**
* TX_1, feeRate=1
*/
const feeRates = await service.getBtcRecommendedFeeRates();
const expectFeeRate = Math.max(Math.round(feeRates.minimumFee / 2), 1);
const psbt = await sendBtc({
from: accounts.charlie.p2wpkh.address,
tos: [
{
address: accounts.charlie.p2wpkh.address,
value: 3000,
},
],
feeRate: expectFeeRate,
source,
});
const { txHex } = await signAndBroadcastPsbt({
psbt,
account: accounts.charlie,
feeRate: expectFeeRate,
});

/**
* Wait for 2 seconds
*/
await waitFor(2000);
console.log('---');

/**
* TX_2, feeRate=fastestFee
*/
const expectFeeRate2 = Math.max(feeRates.fastestFee, expectFeeRate + 1);
const psbt2 = await sendRbf({
txHex: txHex,
from: accounts.charlie.p2wpkh.address,
feeRate: expectFeeRate2,
changeIndex: 0,
source,
});
await signAndBroadcastPsbt({
psbt: psbt2,
account: accounts.charlie,
feeRate: expectFeeRate2,
});
}, 0);
it('Try Full RBF with invalid change', async () => {
/**
* TX_1, feeRate=1
Expand Down

0 comments on commit b8a99b6

Please sign in to comment.