Skip to content

Commit

Permalink
Add container version getter (#581)
Browse files Browse the repository at this point in the history
  • Loading branch information
roman-khimov authored Apr 23, 2024
2 parents d020899 + 611ba44 commit 3cdb540
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
7 changes: 7 additions & 0 deletions container/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -552,3 +552,10 @@ func (x Container) AssertID(id cid.ID) bool {

return id2.Equals(id)
}

// Version returns the NeoFS API version this container was created with.
func (x Container) Version() version.Version {
var v version.Version
_ = v.ReadFromV2(*x.v2.GetVersion()) // No, this can't fail for x.
return v
}
4 changes: 3 additions & 1 deletion container/container_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ func TestContainer_Init(t *testing.T) {

val.Init()

var ver = val.Version()
require.Equal(t, version.Current(), ver)

var msg v2container.Container
val.WriteToV2(&msg)

Expand All @@ -60,7 +63,6 @@ func TestContainer_Init(t *testing.T) {
verV2 := msg.GetVersion()
require.NotNil(t, verV2)

var ver version.Version
require.NoError(t, ver.ReadFromV2(*verV2))

require.Equal(t, version.Current(), ver)
Expand Down
2 changes: 1 addition & 1 deletion version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
// _ = Version(refs.Version{}) // not recommended
type Version refs.Version

const sdkMjr, sdkMnr = 2, 13
const sdkMjr, sdkMnr = 2, 16

// Current returns Version instance that initialized to the
// latest supported NeoFS API revision number in SDK.
Expand Down

0 comments on commit 3cdb540

Please sign in to comment.