Skip to content

Commit 5ce5b0b

Browse files
committed
test: additional checks for sending amt over balance
1 parent 81eabd1 commit 5ce5b0b

2 files changed

Lines changed: 34 additions & 5 deletions

File tree

test/helpers/actions.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1389,7 +1389,7 @@ export async function typeAddressAndVerifyContinue({
13891389

13901390
export async function enterAddress(
13911391
address: string,
1392-
{ acceptCameraPermission = true, addressTimeout = 30_000 } = {},
1392+
{ acceptCameraPermission = true, addressTimeout = 30_000 } = {}
13931393
) {
13941394
await tap('Send');
13951395
await sleep(700);
@@ -1416,6 +1416,10 @@ export async function enterAddressViaScanPrompt(
14161416
await tap('DialogConfirm');
14171417
}
14181418

1419+
export async function verifyAmountToSend(amount: number) {
1420+
await expectTextWithin('SendNumberField', formatSats(amount));
1421+
}
1422+
14191423
export async function deleteAllDefaultWidgets() {
14201424
await swipeFullScreen('up');
14211425
await swipeFullScreen('up');

test/specs/send.e2e.ts

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ import {
2323
dismissBackgroundPaymentsTimedSheet,
2424
acknowledgeReceivedPayment,
2525
typeRecipientInput,
26+
enterAmount,
27+
verifyAmountToSend,
2628
} from '../helpers/actions';
2729
import { lndConfig } from '../helpers/constants';
2830
import { reinstallApp } from '../helpers/setup';
@@ -123,7 +125,8 @@ describe('@send - Send', () => {
123125

124126
// Receive funds and check validation w/ balance
125127
await swipeFullScreen('down');
126-
await receiveOnchainFunds();
128+
const amount = 15000;
129+
await receiveOnchainFunds({ sats: amount });
127130

128131
await tap('Send');
129132
await sleep(500);
@@ -138,7 +141,13 @@ describe('@send - Send', () => {
138141
await typeAddressAndVerifyContinue({ address: address2 });
139142
}
140143

141-
// check validation for unified invoice when balance is enough
144+
// type amount over balance and verify you cannot continue
145+
await tap('AddressContinue');
146+
await enterAmount(amount + 1);
147+
await elementById('ContinueAmount').waitForEnabled({ reverse: true });
148+
await tap('NavigationBack');
149+
150+
// check validation for unified invoice when balance is enough (10_000 sats)
142151
const unified1 = 'bitcoin:bcrt1q07x3wl76zdxvdsz3qzzkvxrjg3n6t4tz2vnsx8?amount=0.0001';
143152
try {
144153
await typeAddressAndVerifyContinue({ address: unified1 });
@@ -147,7 +156,13 @@ describe('@send - Send', () => {
147156
await typeAddressAndVerifyContinue({ address: unified1 });
148157
}
149158

150-
// check validation for unified invoice when balance is too low
159+
// verify amount is set correctly
160+
await tap('AddressContinue');
161+
await verifyAmountToSend(10_000);
162+
await elementById('ContinueAmount').waitForEnabled();
163+
await tap('NavigationBack');
164+
165+
// check validation for unified invoice when balance is too low (200_000 sats)
151166
const unified2 = 'bitcoin:bcrt1q07x3wl76zdxvdsz3qzzkvxrjg3n6t4tz2vnsx8?amount=0.002';
152167
try {
153168
await typeRecipientInput(unified2, { confirmKeyboard: false });
@@ -169,6 +184,7 @@ describe('@send - Send', () => {
169184
// - receive lightning funds
170185

171186
// Send
187+
// - try to send amount over balance
172188
// - send to onchain address
173189
// - send to lightning invoice
174190
// - send to unified invoice
@@ -239,11 +255,20 @@ describe('@send - Send', () => {
239255
await expect(totalBalance).toHaveText('110 000'); // 100k onchain + 10k lightning
240256
await expectTextWithin('ActivitySpending', '10 000');
241257

258+
// try to send amount over balance and verify you cannot continue
259+
console.info('Trying to send ln amount over balance...');
260+
const { paymentRequest: invoice0 } = await lnd.addInvoice({});
261+
console.info({ invoice0 });
262+
await enterAddress(invoice0);
263+
await enterAmount(10_000 + 1);
264+
await elementById('ContinueAmount').waitForEnabled({ reverse: true });
265+
await swipeFullScreen('down');
266+
242267
// send to onchain address
243268
console.info('Sending to onchain address...');
244269
const { address: onchainAddress } = await lnd.newAddress();
245270
console.info({ onchainAddress });
246-
await enterAddress(onchainAddress);
271+
await enterAddress(onchainAddress, { acceptCameraPermission: false });
247272
await elementById('AssetButton-savings').waitForDisplayed();
248273
await tap('N1');
249274
await multiTap('N0', 4);

0 commit comments

Comments
 (0)