From abaab69b8a4c6d2a388917aba011ad97709f2154 Mon Sep 17 00:00:00 2001 From: free will <2647778488@qq.com> Date: Fri, 29 Jul 2022 21:26:38 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B5=8B=E8=AF=95hello=E5=8D=8F=E8=AE=AE?= =?UTF-8?q?=E5=88=9D=E5=A7=8B=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hello/HelloProtocol.go | 8 +------ hello/HelloProtocol_test.go | 48 +++++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+), 7 deletions(-) create mode 100644 hello/HelloProtocol_test.go diff --git a/hello/HelloProtocol.go b/hello/HelloProtocol.go index e466733..bf9da61 100644 --- a/hello/HelloProtocol.go +++ b/hello/HelloProtocol.go @@ -70,19 +70,13 @@ func (hp *HelloProtocol) Init(face *logicface.LogicFaceICN, hp.m_adjacencyList = mlsrConfig.GetAdjacencys() // logicface相关 - // 构造接收hello兴趣包的前缀 + // 构造接收hello兴趣包的监听前缀 name, err := component.CreateIdentifierByString( hp.mlsrConfig.GetRouterPrefix().ToUri() + "/" + MLSR_COMPONENT + "/" + INFO_COMPONENT) if err != nil { common2.LogFatal("HelloProtocol Setting interest filter for Hello interest error, interest generate wrong.", err) return } - // 设置监听前缀 - err = hp.m_face.RegisterPullIdentifier(name, 3000) - if err != nil { - common2.LogFatal("HelloProtocol Setting interest filter for Hello interest error, identifier register wrong.", err) - return - } // 协议状态 hp.state = true // 直接使用registerPrefix来进行前缀监听 diff --git a/hello/HelloProtocol_test.go b/hello/HelloProtocol_test.go new file mode 100644 index 0000000..94d490d --- /dev/null +++ b/hello/HelloProtocol_test.go @@ -0,0 +1,48 @@ +// Package hello +// @Author: Wang Feng +// @Description: +// @Version: 0.1.0 +// @Date: 2022/7/29 21:14 +// @Copyright: MIN-Group;国家重大科技基础设施——未来网络北大实验室;深圳市信息论与未来网络重点实验室 +// + +package hello + +import ( + common2 "minlib/common" + "minlib/logicface" + "minlib/security" + "mlsr/common" + "mlsr/lsdb" + "mlsr/route" + "testing" +) + +const testConfigPath = "D:\\" + common.DefaultConfFileName + +func TestHelloProtocol_Init(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) +}