diff --git a/database/execution_db.go b/database/execution_db.go index 46100bb85..bd1d02661 100644 --- a/database/execution_db.go +++ b/database/execution_db.go @@ -1,10 +1,10 @@ package database import ( - "encoding/json" "errors" "io" + "github.com/gogo/protobuf/proto" "github.com/mesg-foundation/engine/execution" "github.com/mesg-foundation/engine/hash" "github.com/syndtr/goleveldb/leveldb" @@ -100,7 +100,7 @@ func executionFind(db leveldbTxDB, executionHash hash.Hash) (*execution.Executio return nil, err } var execution execution.Execution - if err := json.Unmarshal(data, &execution); err != nil { + if err := proto.Unmarshal(data, &execution); err != nil { return nil, err } return &execution, nil @@ -112,7 +112,7 @@ func executionSave(db leveldbTxDB, execution *execution.Execution) error { if len(execution.Hash) == 0 { return errors.New("database: can't save execution without hash") } - data, err := json.Marshal(execution) + data, err := proto.Marshal(execution) if err != nil { return err } diff --git a/execution/execution.pb.go b/execution/execution.pb.go index 52ecdbaaa..9f3c358d5 100644 --- a/execution/execution.pb.go +++ b/execution/execution.pb.go @@ -4,6 +4,7 @@ package execution import ( + bytes "bytes" fmt "fmt" _ "github.com/gogo/protobuf/gogoproto" proto "github.com/gogo/protobuf/proto" @@ -130,37 +131,103 @@ func init() { func init() { proto.RegisterFile("execution.proto", fileDescriptor_776e2c5022e94aef) } var fileDescriptor_776e2c5022e94aef = []byte{ - // 504 bytes of a gzipped FileDescriptorProto + // 511 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x94, 0xcf, 0x6a, 0xdb, 0x40, - 0x10, 0xc6, 0xad, 0xd8, 0x96, 0xa3, 0xf1, 0x9f, 0xba, 0x7b, 0xa9, 0x08, 0xa5, 0x36, 0x7b, 0x28, - 0x26, 0x21, 0x72, 0x6d, 0xd3, 0x16, 0x72, 0x09, 0x28, 0x49, 0x69, 0x28, 0x85, 0x22, 0xd3, 0x4b, - 0x6f, 0x6b, 0x7b, 0xb2, 0x16, 0xb1, 0x77, 0xc5, 0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 0x8f, 0xe0, 0xe6, 0xcb, 0x41, 0x9a, 0xd0, 0xf8, 0x2c, 0x2e, 0x85, 0xfc, - 0x26, 0xba, 0x95, 0x2c, 0x38, 0x51, 0xc8, 0x0c, 0x2e, 0xba, 0x0e, 0xe9, 0x00, 0x9c, 0x8b, 0x4f, - 0x4a, 0x72, 0x85, 0x5a, 0x77, 0x77, 0x48, 0x1b, 0xbc, 0x13, 0xb9, 0x4e, 0x56, 0x98, 0xa5, 0xab, - 0x04, 0xc0, 0x7d, 0xc7, 0xe2, 0x15, 0x2e, 0xba, 0xb5, 0x70, 0x74, 0xfd, 0xeb, 0x45, 0xe5, 0xcb, - 0x7f, 0x3c, 0xe6, 0xcf, 0xff, 0x62, 0xe6, 0xda, 0x51, 0x4c, 0x7e, 0x07, 0x00, 0x00, 0xff, 0xff, - 0xf8, 0x72, 0x51, 0x0c, 0x43, 0x04, 0x00, 0x00, + 0x10, 0xc6, 0xa3, 0xd8, 0x96, 0xa3, 0xf1, 0x9f, 0xba, 0x7b, 0xa9, 0x08, 0x25, 0x36, 0x7b, 0x28, + 0x26, 0x21, 0x72, 0x63, 0x93, 0x16, 0x72, 0x09, 0x28, 0x49, 0x69, 0x28, 0x85, 0x22, 0xd3, 0x4b, + 0x6f, 0x6b, 0x7b, 0xb2, 0x16, 0xb1, 0x77, 0xc5, 0xee, 0xaa, 0x6d, 0xde, 0xa8, 0x8f, 0x92, 0x67, + 0x28, 0xc5, 0xd0, 0x3e, 0x42, 0x9e, 0xa0, 0x68, 0x15, 0x35, 0x56, 0x03, 0xa5, 0x84, 0xdc, 0x34, + 0x3b, 0xdf, 0xfc, 0xf6, 0xdb, 0x99, 0x41, 0xf0, 0x04, 0xbf, 0xe2, 0x34, 0x35, 0xb1, 0x14, 0x41, + 0xa2, 0xa4, 0x91, 0xa4, 0x66, 0xae, 0x12, 0xd4, 0xdb, 0xcf, 0xb9, 0x94, 0x7c, 0x81, 0x03, 0x7b, + 0x38, 0x49, 0x2f, 0x06,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, 0xdc, + 0xd9, 0xf8, 0xf6, 0x6b, 0xc7, 0xf9, 0xf4, 0x1f, 0x0f, 0xfa, 0xf3, 0xcf, 0x98, 0xb8, 0x76, 0x1c, + 0xa3, 0xdf, 0x01, 0x00, 0x00, 0xff, 0xff, 0x73, 0x1c, 0x6a, 0x6d, 0x47, 0x04, 0x00, 0x00, +} + +func (this *Execution) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*Execution) + if !ok { + that2, ok := that.(Execution) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if !this.Hash.Equal(that1.Hash) { + return false + } + if !this.ParentHash.Equal(that1.ParentHash) { + return false + } + if !this.EventHash.Equal(that1.EventHash) { + return false + } + if this.Status != that1.Status { + return false + } + if !this.InstanceHash.Equal(that1.InstanceHash) { + return false + } + if this.TaskKey != that1.TaskKey { + return false + } + if !this.Inputs.Equal(that1.Inputs) { + return false + } + if !this.Outputs.Equal(that1.Outputs) { + return false + } + if this.Error != that1.Error { + return false + } + if len(this.Tags) != len(that1.Tags) { + return false + } + for i := range this.Tags { + if this.Tags[i] != that1.Tags[i] { + return false + } + } + if !this.ProcessHash.Equal(that1.ProcessHash) { + return false + } + if this.StepID != that1.StepID { + return false + } + if !bytes.Equal(this.XXX_unrecognized, that1.XXX_unrecognized) { + return false + } + return true } diff --git a/protobuf/types/execution.proto b/protobuf/types/execution.proto index 27a9b0556..2633a496f 100644 --- a/protobuf/types/execution.proto +++ b/protobuf/types/execution.proto @@ -7,6 +7,7 @@ package types; option go_package = "github.com/mesg-foundation/engine/execution"; option (gogoproto.goproto_getters_all) = false; +option (gogoproto.equal_all) = true; // Status represents the status of a single execution. // Note that a valid execution must have only one status diff --git a/sdk/execution/execution_test.go b/sdk/execution/execution_test.go index 50be472bb..0390c79fe 100644 --- a/sdk/execution/execution_test.go +++ b/sdk/execution/execution_test.go @@ -100,7 +100,7 @@ func TestGet(t *testing.T) { require.NoError(t, sdk.execDB.Save(exec)) got, err := sdk.Get(exec.Hash) require.NoError(t, err) - require.Equal(t, exec, got) + require.True(t, exec.Equal(got)) } func TestGetStream(t *testing.T) { diff --git a/server/grpc/api/execution_test.go b/server/grpc/api/execution_test.go index 5a1e9c4f9..3e7c17cba 100644 --- a/server/grpc/api/execution_test.go +++ b/server/grpc/api/execution_test.go @@ -28,7 +28,7 @@ func TestGet(t *testing.T) { got, err := s.Get(context.Background(), &api.GetExecutionRequest{Hash: exec.Hash}) require.NoError(t, err) - require.Equal(t, got, exec) + require.True(t, got.Equal(exec)) } func TestUpdate(t *testing.T) {