From 9e31a1164b0036b24d267ca21eca3a19dea18bb8 Mon Sep 17 00:00:00 2001 From: free will <2647778488@qq.com> Date: Fri, 29 Jul 2022 22:35:05 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=AF=B9Hello=E5=8D=8F?= =?UTF-8?q?=E8=AE=AE=E5=8F=91=E5=8C=85=E7=9A=84=E8=99=9A=E7=A9=BA=E6=B5=8B?= =?UTF-8?q?=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hello/HelloProtocol_test.go | 41 +++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/hello/HelloProtocol_test.go b/hello/HelloProtocol_test.go index 94d490d..5a33bfb 100644 --- a/hello/HelloProtocol_test.go +++ b/hello/HelloProtocol_test.go @@ -10,6 +10,7 @@ package hello import ( common2 "minlib/common" + "minlib/component" "minlib/logicface" "minlib/security" "mlsr/common" @@ -20,6 +21,11 @@ import ( const testConfigPath = "D:\\" + common.DefaultConfFileName +// +// TestHelloProtocol_Init +// @Description: 初始化 +// @param t +// func TestHelloProtocol_Init(t *testing.T) { // 1. 建立前置结构体(lsdb等) // 配置文件初始化 @@ -46,3 +52,38 @@ func TestHelloProtocol_Init(t *testing.T) { hp := new(HelloProtocol) hp.Init(face, sche, keychain, mlsrConfig, rt, mlsdb) } + +// +// TestHelloProtocol_SendHelloInterest +// @Description: todo 需要真机测试,看对端是否能接收到该探测包 +// @param t +// +func TestHelloProtocol_SendHelloInterest(t *testing.T) { + // 1. 建立前置结构体(lsdb等) + // 配置文件初始化 + mlsrConfig, err := common.ParseConfig(testConfigPath) + if err != nil { + common2.LogInfo("配置文件解析错误") + } + // 调度器初始化 + sche := new(lsdb.MlsrScheduler) + sche.Init() + // LogicFace初始化(假设初始化,暂时用不到) + face := new(logicface.LogicFaceICN) + keychain := new(security.KeyChain) + // LSDB初始化 + mlsdb := new(lsdb.Lsdb) + mlsdb.Init(mlsrConfig, sche, face) + rt := new(route.RoutingTable) + rt.Init(mlsrConfig, sche, mlsdb) + // 名称前缀表初始化 + npt := new(route.NamePrefixTable) + npt.Init(mlsrConfig.GetRouterPrefix(), rt, rt.AfterRoutingChange, mlsdb.OnLsdbModified) + + // 2. 初始化hello协议 + hp := new(HelloProtocol) + hp.Init(face, sche, keychain, mlsrConfig, rt, mlsdb) + + iden, _ := component.CreateIdentifierByString("/min/pku/testHello") + hp.SendHelloInterest(iden) +}