transaction: fix wrong state descriptor serdes
Wrong field order.
This commit is contained in:
parent
cc9ace6426
commit
803fb39bb0
2 changed files with 4 additions and 4 deletions
|
@ -26,14 +26,14 @@ func (s *StateDescriptor) DecodeBinary(r *io.BinReader) {
|
|||
s.Type = DescStateType(r.ReadB())
|
||||
|
||||
s.Key = r.ReadVarBytes()
|
||||
s.Value = r.ReadVarBytes()
|
||||
s.Field = r.ReadString()
|
||||
s.Value = r.ReadVarBytes()
|
||||
}
|
||||
|
||||
// EncodeBinary implements Serializable interface.
|
||||
func (s *StateDescriptor) EncodeBinary(w *io.BinWriter) {
|
||||
w.WriteB(byte(s.Type))
|
||||
w.WriteVarBytes(s.Key)
|
||||
w.WriteVarBytes(s.Value)
|
||||
w.WriteString(s.Field)
|
||||
w.WriteVarBytes(s.Value)
|
||||
}
|
||||
|
|
|
@ -25,8 +25,8 @@ func TestEncodeDecodeState(t *testing.T) {
|
|||
assert.Equal(t, 1, len(s.Descriptors))
|
||||
descriptor := s.Descriptors[0]
|
||||
assert.Equal(t, "03c089d7122b840a4935234e82e26ae5efd0c2acb627239dc9f207311337b6f2c1", hex.EncodeToString(descriptor.Key))
|
||||
assert.Equal(t, "52656769737465726564", hex.EncodeToString(descriptor.Value))
|
||||
assert.Equal(t, "\x01", descriptor.Field)
|
||||
assert.Equal(t, "Registered", descriptor.Field)
|
||||
assert.Equal(t, []byte{0x01}, descriptor.Value)
|
||||
assert.Equal(t, Validator, descriptor.Type)
|
||||
|
||||
// Encode
|
||||
|
|
Loading…
Reference in a new issue