mirror of
https://github.com/aljazceru/lspd.git
synced 2026-01-05 23:24:21 +01:00
lsps2: implement lsps2.get_versions
This commit is contained in:
40
itest/lsps2_get_versions_test.go
Normal file
40
itest/lsps2_get_versions_test.go
Normal 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"])
|
||||
}
|
||||
Reference in New Issue
Block a user