Skip to content

Commit e14ad47

Browse files
committed
cmd/loop: drop misleading static loop-in fee warning
1 parent 2f5e821 commit e14ad47

3 files changed

Lines changed: 73 additions & 12 deletions

File tree

cmd/loop/main.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -329,12 +329,6 @@ func displayInDetails(req *looprpc.QuoteRequest,
329329
"wallet.\n\n")
330330
}
331331

332-
if req.DepositOutpoints != nil {
333-
fmt.Printf("On-chain fees for static address loop-ins are not " +
334-
"included.\nThey were already paid when the deposits " +
335-
"were created.\n\n")
336-
}
337-
338332
printQuoteInResp(req, resp, verbose)
339333

340334
fmt.Printf("\nCONTINUE SWAP? (y/n): ")

cmd/loop/main_test.go

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
package main
2+
3+
import (
4+
"io"
5+
"os"
6+
"testing"
7+
8+
"github.com/lightninglabs/loop/looprpc"
9+
"github.com/stretchr/testify/require"
10+
)
11+
12+
func captureDisplayInDetailsOutput(t *testing.T, req *looprpc.QuoteRequest,
13+
resp *looprpc.InQuoteResponse, verbose bool) string {
14+
15+
t.Helper()
16+
17+
oldStdin := os.Stdin
18+
oldStdout := os.Stdout
19+
20+
inReader, inWriter, err := os.Pipe()
21+
require.NoError(t, err)
22+
23+
outReader, outWriter, err := os.Pipe()
24+
require.NoError(t, err)
25+
26+
os.Stdin = inReader
27+
os.Stdout = outWriter
28+
29+
t.Cleanup(func() {
30+
os.Stdin = oldStdin
31+
os.Stdout = oldStdout
32+
})
33+
t.Cleanup(func() {
34+
_ = inReader.Close()
35+
_ = outReader.Close()
36+
})
37+
38+
_, err = inWriter.Write([]byte("y\n"))
39+
require.NoError(t, err)
40+
require.NoError(t, inWriter.Close())
41+
42+
err = displayInDetails(req, resp, verbose)
43+
require.NoError(t, err)
44+
45+
require.NoError(t, outWriter.Close())
46+
47+
output, err := io.ReadAll(outReader)
48+
require.NoError(t, err)
49+
50+
return string(output)
51+
}
52+
53+
func TestDisplayInDetailsStaticLoopIn(t *testing.T) {
54+
req := &looprpc.QuoteRequest{
55+
Amt: 250_000,
56+
DepositOutpoints: []string{"test-outpoint"},
57+
}
58+
resp := &looprpc.InQuoteResponse{
59+
HtlcPublishFeeSat: 86,
60+
SwapFeeSat: 300,
61+
}
62+
63+
output := captureDisplayInDetailsOutput(t, req, resp, false)
64+
65+
require.NotContains(t, output,
66+
"On-chain fees for static address loop-ins are not included.")
67+
require.NotContains(t, output,
68+
"They were already paid when the deposits were created.")
69+
require.Contains(t, output,
70+
"Previously deposited on-chain: 250000 sat")
71+
require.Contains(t, output,
72+
"Estimated total fee: 386 sat")
73+
}

regtest/README.md

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -227,9 +227,6 @@ Let's list the deposits in the loop client:
227227
These deposits can now be instantly swapped. Let's use the first one:
228228
```shell
229229
./regtest.sh loop static in --utxo 5405e5cae38f9e4e193f7b5442dd005273e2e1fab8687c42a505c1a333e8884f:0
230-
On-chain fees for static address loop-ins are not included.
231-
They were already paid when the deposits were created.
232-
233230
Previously deposited on-chain: 250000 sat
234231
Receive off-chain: 249614 sat
235232
Estimated total fee: 386 sat
@@ -266,9 +263,6 @@ We can combine the remaining two deposits in another instant swap by specifying
266263
the `--all` flag:
267264
```shell
268265
./regtest.sh loop static in --all  ✔  12:07:28
269-
On-chain fees for static address loop-ins are not included.
270-
They were already paid when the deposits were created.
271-
272266
Previously deposited on-chain: 500000 sat
273267
Receive off-chain: 499302 sat
274268
Estimated total fee: 698 sat

0 commit comments

Comments
 (0)