Skip to content

Commit 8023da4

Browse files
authored
ci: update to latest regtest (#272)
* ci: update to latest regtest * test: make sure to reset autoswap config * test: print backend logs after timeout * test: simplify autoswap lightning test * test: increase recovery timeouts electrum fee estimation times out sometimes
1 parent 34ac99c commit 8023da4

File tree

6 files changed

+69
-63
lines changed

6 files changed

+69
-63
lines changed

Makefile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,17 @@ ifeq ("$(wildcard regtest/start.sh)","")
6363
@$(call print, "Downloading regtest")
6464
make submodules
6565
cp regtest.override.yml regtest/docker-compose.override.yml
66+
cd regtest && git apply ../regtest.patch
6667
endif
6768

6869
start-regtest: download-regtest
6970
@$(call print, "Starting regtest")
7071
eval cd regtest && ./start.sh
7172

73+
restart-regtest: download-regtest
74+
@$(call print, "Restarting regtest")
75+
eval cd regtest && ./restart.sh
76+
7277
#
7378
# Building
7479
#

regtest.override.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
services:
22
boltz-client:
3-
profiles: !override ["none"]
3+
profiles: !override [ "none" ]
44

55
scripts:
66
depends_on: !override

regtest.patch

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
diff --git a/data/backend/boltz.conf b/data/backend/boltz.conf
2+
index 247da7e..38991ea 100755
3+
--- a/data/backend/boltz.conf
4+
+++ b/data/backend/boltz.conf
5+
@@ -112,14 +112,6 @@ maxZeroConfAmount = 0
6+
privateKeyPath = "/root/.lightning/regtest/hold/client-key.pem"
7+
certChainPath = "/root/.lightning/regtest/hold/client.pem"
8+
9+
- [currencies.cln.mpay]
10+
- host = "cln-2"
11+
- port = 9293
12+
-
13+
- rootCertPath = "/root/.lightning/regtest/mpay/ca.pem"
14+
- privateKeyPath = "/root/.lightning/regtest/mpay/client-key.pem"
15+
- certChainPath = "/root/.lightning/regtest/mpay/client.pem"
16+
-
17+
18+
[liquid]
19+
symbol = "L-BTC"
20+
diff --git a/docker-compose.yml b/docker-compose.yml
21+
index 3046287..990eeed 100644
22+
--- a/docker-compose.yml
23+
+++ b/docker-compose.yml
24+
@@ -61,7 +61,6 @@ x-services:
25+
- --dev-fast-gossip
26+
- --dev-fast-reconnect
27+
- --plugin=/root/hold
28+
- - --plugin=/root/mpay.sh
29+
expose:
30+
- 9735
31+
- 9736

rpcserver/rpcserver_test.go

Lines changed: 27 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,7 @@ func swapStream(t *testing.T, client client.Boltz, swapId string) (streamFunc, s
281281
require.Fail(t, fmt.Sprintf("update stream for swap %s stopped before state %s", swapId, state))
282282
}
283283
case <-time.After(15 * time.Second):
284+
test.PrintBackendLogs()
284285
require.Fail(t, fmt.Sprintf("timed out while waiting for swap %s to reach state %s", swapId, state))
285286
}
286287
}
@@ -703,8 +704,8 @@ func TestSwap(t *testing.T) {
703704
client, _, stop = setup(t, setupOptions{cfg: cfg})
704705
defer stop()
705706

706-
ticker := time.NewTicker(100 * time.Millisecond)
707-
timeout := time.After(1 * time.Second)
707+
ticker := time.NewTicker(200 * time.Millisecond)
708+
timeout := time.After(5 * time.Second)
708709
for {
709710
select {
710711
case <-ticker.C:
@@ -1091,8 +1092,8 @@ func TestReverseSwap(t *testing.T) {
10911092

10921093
client, _, stop = setup(t, setupOptions{cfg: cfg})
10931094

1094-
ticker := time.NewTicker(100 * time.Millisecond)
1095-
timeout := time.After(3 * time.Second)
1095+
ticker := time.NewTicker(200 * time.Millisecond)
1096+
timeout := time.After(5 * time.Second)
10961097
for info.GetReverseSwap().GetState() != boltzrpc.SwapState_SUCCESSFUL {
10971098
select {
10981099
case <-ticker.C:
@@ -1809,7 +1810,7 @@ func TestChainSwap(t *testing.T) {
18091810

18101811
func TestAutoSwap(t *testing.T) {
18111812
cfg := loadConfig(t)
1812-
cfg.Node = "LND"
1813+
cfg.Node = "CLN"
18131814

18141815
_, err := connectLightning(cfg.Cln)
18151816
require.NoError(t, err)
@@ -1819,13 +1820,15 @@ func TestAutoSwap(t *testing.T) {
18191820
admin, autoSwap, stop := setup(t, setupOptions{cfg: cfg})
18201821
defer stop()
18211822

1822-
_, err = autoSwap.ResetConfig(client.LnAutoSwap)
1823-
require.NoError(t, err)
1824-
1825-
_, err = autoSwap.ResetConfig(client.ChainAutoSwap)
1826-
require.NoError(t, err)
1823+
reset := func(t *testing.T) {
1824+
_, err = autoSwap.ResetConfig(client.LnAutoSwap)
1825+
require.NoError(t, err)
1826+
_, err = autoSwap.ResetConfig(client.ChainAutoSwap)
1827+
require.NoError(t, err)
1828+
}
18271829

18281830
t.Run("Chain", func(t *testing.T) {
1831+
reset(t)
18291832
cfg := &autoswaprpc.ChainConfig{
18301833
FromWallet: walletName,
18311834
ToWallet: cfg.Node,
@@ -1876,17 +1879,7 @@ func TestAutoSwap(t *testing.T) {
18761879
})
18771880

18781881
t.Run("Lightning", func(t *testing.T) {
1879-
_, err := autoSwap.ResetConfig(client.LnAutoSwap)
1880-
require.NoError(t, err)
1881-
1882-
var us, them lightning.LightningNode
1883-
if strings.EqualFold(cfg.Node, "lnd") {
1884-
us = cfg.LND
1885-
them = cfg.Cln
1886-
} else {
1887-
us = cfg.Cln
1888-
them = cfg.LND
1889-
}
1882+
reset(t)
18901883

18911884
t.Run("Setup", func(t *testing.T) {
18921885
running := func(value bool) *autoswaprpc.GetStatusResponse {
@@ -1928,41 +1921,9 @@ func TestAutoSwap(t *testing.T) {
19281921
})
19291922

19301923
t.Run("Start", func(t *testing.T) {
1931-
getChannel := func(from lightning.LightningNode, peer string) *lightning.LightningChannel {
1932-
channels, err := from.ListChannels()
1933-
require.NoError(t, err)
1934-
for _, channel := range channels {
1935-
if channel.PeerId == peer {
1936-
return channel
1937-
}
1938-
}
1939-
return nil
1940-
}
1941-
1942-
pay := func(from lightning.LightningNode, to lightning.LightningNode, amount uint64) {
1943-
info, err := to.GetInfo()
1944-
require.NoError(t, err)
1945-
1946-
channel := getChannel(from, info.Pubkey)
1947-
require.NotNil(t, channel)
1948-
1949-
if channel.InboundSat < channel.Capacity/2 {
1950-
amount = amount + (channel.Capacity/2-channel.InboundSat)/1000
1951-
}
1952-
if channel.OutboundSat < amount {
1953-
return
1954-
}
1955-
1956-
response, err := to.CreateInvoice(amount, nil, 100000, "Testt")
1957-
require.NoError(t, err)
1958-
_, err = from.PayInvoice(context.Background(), response.PaymentRequest, 10000, 30, []lightning.ChanId{channel.Id})
1959-
require.NoError(t, err)
1960-
1961-
time.Sleep(1000 * time.Millisecond)
1962-
}
1963-
19641924
swapCfg := autoswap.DefaultLightningConfig()
19651925
swapCfg.AcceptZeroConf = true
1926+
swapCfg.Budget = 1000000
19661927
swapCfg.MaxFeePercent = 10
19671928
swapCfg.Currency = boltzrpc.Currency_BTC
19681929
swapCfg.InboundBalance = 1
@@ -1976,7 +1937,9 @@ func TestAutoSwap(t *testing.T) {
19761937
require.NoError(t, err)
19771938
recommendation := recommendations.Lightning[0]
19781939
require.Nil(t, recommendation.Swap)
1979-
swapCfg.InboundBalance = recommendation.Channel.InboundSat + 100
1940+
offset := uint64(100000)
1941+
swapCfg.InboundBalance = recommendation.Channel.InboundSat + offset
1942+
swapCfg.OutboundBalance = recommendation.Channel.OutboundSat - offset
19801943

19811944
_, err = autoSwap.UpdateLightningConfig(&autoswaprpc.UpdateLightningConfigRequest{Config: swapCfg})
19821945
require.NoError(t, err)
@@ -1989,17 +1952,20 @@ func TestAutoSwap(t *testing.T) {
19891952
})
19901953

19911954
t.Run("Auto", func(t *testing.T) {
1992-
pay(them, us, 1_000_000)
19931955
_, err := autoSwap.Enable()
19941956
require.NoError(t, err)
19951957

1996-
time.Sleep(200 * time.Millisecond)
1958+
stream, _ := swapStream(t, admin, "")
1959+
test.MineBlock()
1960+
info := stream(boltzrpc.SwapState_PENDING)
1961+
require.NotNil(t, info.ReverseSwap)
1962+
require.True(t, info.ReverseSwap.IsAuto)
1963+
id := info.ReverseSwap.Id
1964+
19971965
swaps, err := admin.ListSwaps(&boltzrpc.ListSwapsRequest{Include: boltzrpc.IncludeSwaps_AUTO})
19981966
require.NoError(t, err)
1999-
2000-
require.NotEmpty(t, swaps.ReverseSwaps)
2001-
require.True(t, swaps.ReverseSwaps[0].IsAuto)
2002-
stream, _ := swapStream(t, admin, swaps.ReverseSwaps[0].Id)
1967+
require.Equal(t, id, swaps.ReverseSwaps[0].Id)
1968+
stream, _ = swapStream(t, admin, id)
20031969
stream(boltzrpc.SwapState_SUCCESSFUL)
20041970

20051971
status, err := autoSwap.GetStatus()

test/test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,3 +197,7 @@ func (f FakeSwaps) Create(t *testing.T, db *database.Database) {
197197
func PastDate(duration time.Duration) time.Time {
198198
return time.Now().Add(-duration)
199199
}
200+
201+
func PrintBackendLogs() {
202+
fmt.Println(bash("docker logs boltz-backend"))
203+
}

0 commit comments

Comments
 (0)