[#302] pkg/netmap: Convert nil Filter to nil message

Make `Filter.ToV2` method return `nil`
when called on `nil`. Make `NewFilterFromV2`
function return `nil` when called on `nil`.
Write corresponding unit tests.

Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
This commit is contained in:
Pavel Karpy 2021-06-08 16:41:45 +03:00 committed by Alex Vanin
parent 0206bd9a5d
commit 9a7e120485
2 changed files with 16 additions and 0 deletions

View file

@ -153,11 +153,15 @@ func NewFilter() *Filter {
}
// NewFilterFromV2 converts v2 Filter to Filter.
//
// Nil netmap.Filter converts to nil.
func NewFilterFromV2(f *netmap.Filter) *Filter {
return (*Filter)(f)
}
// ToV2 converts Filter to v2 Filter.
//
// Nil Filter converts to nil.
func (f *Filter) ToV2() *netmap.Filter {
return (*netmap.Filter)(f)
}