forked from TrueCloudLab/frostfs-api-go
session: implement SignedDataSource on CreateRequest
This commit is contained in:
parent
1932658a7d
commit
6d71ea239b
2 changed files with 110 additions and 0 deletions
|
@ -27,3 +27,66 @@ func TestCreateRequestGettersSetters(t *testing.T) {
|
|||
require.Equal(t, e2, m.ExpirationEpoch())
|
||||
})
|
||||
}
|
||||
|
||||
func TestCreateRequest_SignedData(t *testing.T) {
|
||||
var (
|
||||
id = OwnerID{1, 2, 3}
|
||||
e1 = uint64(1)
|
||||
e2 = uint64(2)
|
||||
)
|
||||
|
||||
// create new message
|
||||
m := new(CreateRequest)
|
||||
|
||||
// fill the fields
|
||||
m.SetOwnerID(id)
|
||||
m.SetCreationEpoch(e1)
|
||||
m.SetExpirationEpoch(e2)
|
||||
|
||||
// calculate initial signed data
|
||||
d, err := m.SignedData()
|
||||
require.NoError(t, err)
|
||||
|
||||
items := []struct {
|
||||
change func()
|
||||
reset func()
|
||||
}{
|
||||
{ // OwnerID
|
||||
change: func() {
|
||||
id2 := id
|
||||
id2[0]++
|
||||
m.SetOwnerID(id2)
|
||||
},
|
||||
reset: func() {
|
||||
m.SetOwnerID(id)
|
||||
},
|
||||
},
|
||||
{ // CreationEpoch
|
||||
change: func() {
|
||||
m.SetCreationEpoch(e1 + 1)
|
||||
},
|
||||
reset: func() {
|
||||
m.SetCreationEpoch(e1)
|
||||
},
|
||||
},
|
||||
{ // ExpirationEpoch
|
||||
change: func() {
|
||||
m.SetExpirationEpoch(e2 + 1)
|
||||
},
|
||||
reset: func() {
|
||||
m.SetExpirationEpoch(e2)
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for _, item := range items {
|
||||
item.change()
|
||||
|
||||
d2, err := m.SignedData()
|
||||
require.NoError(t, err)
|
||||
|
||||
require.NotEqual(t, d, d2)
|
||||
|
||||
item.reset()
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue