From be192eef4dc9d46bf2bd079df45ae455111ff984 Mon Sep 17 00:00:00 2001 From: Jesse de Wit Date: Sat, 12 Aug 2023 21:13:03 +0200 Subject: [PATCH] lsps2: get_info integration test --- .github/workflows/integration_tests.yaml | 3 +- itest/lspd_test.go | 4 ++ itest/lsps2_get_info_test.go | 59 ++++++++++++++++++++++++ 3 files changed, 65 insertions(+), 1 deletion(-) create mode 100644 itest/lsps2_get_info_test.go diff --git a/.github/workflows/integration_tests.yaml b/.github/workflows/integration_tests.yaml index 4720d206..b5c0dada 100644 --- a/.github/workflows/integration_tests.yaml +++ b/.github/workflows/integration_tests.yaml @@ -138,7 +138,8 @@ jobs: matrix: test: [ testLsps0GetProtocolVersions, - testLsps2GetVersions + testLsps2GetVersions, + testLsps2GetInfo ] implementation: [ CLN diff --git a/itest/lspd_test.go b/itest/lspd_test.go index 3c25582c..820a9717 100644 --- a/itest/lspd_test.go +++ b/itest/lspd_test.go @@ -171,4 +171,8 @@ var allTestCases = []*testCase{ name: "testLsps2GetVersions", test: testLsps2GetVersions, }, + { + name: "testLsps2GetInfo", + test: testLsps2GetInfo, + }, } diff --git a/itest/lsps2_get_info_test.go b/itest/lsps2_get_info_test.go new file mode 100644 index 00000000..c0682078 --- /dev/null +++ b/itest/lsps2_get_info_test.go @@ -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) +}