lsps2: implement lsps2.get_versions

This commit is contained in:
Jesse de Wit
2023-08-11 08:49:57 +02:00
parent e9a1e569f9
commit 25d205e05c
5 changed files with 103 additions and 1 deletions

View File

@@ -0,0 +1,40 @@
package itest
import (
"encoding/hex"
"encoding/json"
"log"
"github.com/breez/lntest"
"github.com/breez/lspd/lsps0"
"github.com/stretchr/testify/assert"
)
func testLsps2GetVersions(p *testParams) {
p.BreezClient().Node().ConnectPeer(p.Lsp().LightningNode())
rawMsg := `{
"method": "lsps2.get_versions",
"jsonrpc": "2.0",
"id": "example#3cad6a54d302edba4c9ade2f7ffac098",
"params": {}
}`
p.BreezClient().Node().SendCustomMessage(&lntest.CustomMsgRequest{
PeerId: hex.EncodeToString(p.Lsp().NodeId()),
Type: lsps0.Lsps0MessageType,
Data: []byte(rawMsg),
})
resp := p.BreezClient().ReceiveCustomMessage()
assert.Equal(p.t, uint32(37913), resp.Type)
content := make(map[string]json.RawMessage)
err := json.Unmarshal(resp.Data[:], &content)
lntest.CheckError(p.t, err)
log.Print(string(resp.Data))
result := make(map[string][]int)
err = json.Unmarshal(content["result"], &result)
lntest.CheckError(p.t, err)
assert.Equal(p.t, []int{1}, result["versions"])
}