From c88d07087f27bf8667f71d625074fd08dae7125e Mon Sep 17 00:00:00 2001 From: Vincenzo Palazzo Date: Mon, 21 Jun 2021 14:52:55 +0200 Subject: [PATCH 1/3] Adding test to call listfunds. Signed-off-by: Vincenzo Palazzo --- glightning/tests/interop_test.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/glightning/tests/interop_test.go b/glightning/tests/interop_test.go index 152f5ae..e7fcf80 100644 --- a/glightning/tests/interop_test.go +++ b/glightning/tests/interop_test.go @@ -396,6 +396,22 @@ func TestListTransactions(t *testing.T) { assert.Equal(t, len(trans), 2) } +func TestListFunds(t *testing.T) { + short(t) + + testDir, dataDir, btcPid, btc := Init(t) + defer CleanUp(testDir) + l1 := LnNode(t, testDir, dataDir, btcPid, "one", nil) + + fundNode(t, "1.0", l1, btc) + fundNode(t, "1.0", l1, btc) + waitToSync(l1) + funds, err := l1.rpc.ListFunds() + check(t, err) + assert.Equal(t, len(funds.Channels), 0) +} + + func fundNode(t *testing.T, amount string, n *Node, b *gbitcoin.Bitcoin) { addr, err := n.rpc.NewAddr() check(t, err) From e37208b1cce0efa322f93f3b813cbee1e36deeb0 Mon Sep 17 00:00:00 2001 From: Vincenzo Palazzo Date: Sat, 31 Jul 2021 17:00:09 +0200 Subject: [PATCH 2/3] Moved from array of struct to array of pointers. The list forwards grows quickly, and in terms of performance it is better have a list of pointer instead of a list of struct. Signed-off-by: Vincenzo Palazzo --- glightning/lightning.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/glightning/lightning.go b/glightning/lightning.go index eeacaa7..857f2c2 100644 --- a/glightning/lightning.go +++ b/glightning/lightning.go @@ -2141,9 +2141,9 @@ type Forwarding struct { } // List all forwarded payments and their information -func (l *Lightning) ListForwards() ([]Forwarding, error) { +func (l *Lightning) ListForwards() ([]*Forwarding, error) { var result struct { - Forwards []Forwarding `json:"forwards"` + Forwards []*Forwarding `json:"forwards"` } err := l.client.Request(&ListForwardsRequest{}, &result) return result.Forwards, err From 0be74ee27f344ce03f4e3245863d55f9bc5af741 Mon Sep 17 00:00:00 2001 From: Vincenzo Palazzo Date: Sat, 31 Jul 2021 17:13:58 +0200 Subject: [PATCH 3/3] Fixed jrpc2 string conversion. Signed-off-by: Vincenzo Palazzo --- jrpc2/client_test.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/jrpc2/client_test.go b/jrpc2/client_test.go index fafc3c5..04f64ef 100644 --- a/jrpc2/client_test.go +++ b/jrpc2/client_test.go @@ -7,6 +7,7 @@ import ( "io" "log" "os" + "fmt" "sync" "testing" "time" @@ -110,7 +111,7 @@ func (s *ServerSubtractString) New() interface{} { } func (s *ServerSubtractString) Call() (jrpc2.Result, error) { - return string(s.Minuend - s.Subtrahend), nil + return fmt.Sprintf("%d", (s.Minuend - s.Subtrahend)), nil } // send a response with a result of a different type than