Skip to content

Commit

Permalink
lsps2: get_info integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
JssDWt committed Aug 12, 2023
1 parent 3c431ce commit be192ee
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 1 deletion.
3 changes: 2 additions & 1 deletion .github/workflows/integration_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,8 @@ jobs:
matrix:
test: [
testLsps0GetProtocolVersions,
testLsps2GetVersions
testLsps2GetVersions,
testLsps2GetInfo
]
implementation: [
CLN
Expand Down
4 changes: 4 additions & 0 deletions itest/lspd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,4 +171,8 @@ var allTestCases = []*testCase{
name: "testLsps2GetVersions",
test: testLsps2GetVersions,
},
{
name: "testLsps2GetInfo",
test: testLsps2GetInfo,
},
}
59 changes: 59 additions & 0 deletions itest/lsps2_get_info_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package itest

import (
"encoding/hex"
"encoding/json"
"log"
"time"

"github.com/breez/lntest"
"github.com/breez/lspd/lsps0"
"github.com/breez/lspd/lsps2"
"github.com/stretchr/testify/assert"
)

func testLsps2GetInfo(p *testParams) {
SetFeeParams(p.Lsp(), []*FeeParamSetting{
{
Validity: time.Second * 3600,
MinMsat: 3000000,
Proportional: 1000,
},
{
Validity: time.Second * 2800,
MinMsat: 2000000,
Proportional: 800,
},
})
p.BreezClient().Node().ConnectPeer(p.Lsp().LightningNode())

rawMsg := `{
"method": "lsps2.get_info",
"jsonrpc": "2.0",
"id": "example#3cad6a54d302edba4c9ade2f7ffac098",
"params": {
"version": 1,
"token": "hello"
}
}`
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 := new(lsps2.GetInfoResponse)
err = json.Unmarshal(content["result"], &result)
lntest.CheckError(p.t, err)
assert.Len(p.t, result.OpeningFeeParamsMenu, 2)
assert.Equal(p.t, uint64(2000000), result.OpeningFeeParamsMenu[0].MinFeeMsat)
assert.Equal(p.t, uint64(3000000), result.OpeningFeeParamsMenu[1].MinFeeMsat)
}

0 comments on commit be192ee

Please sign in to comment.