adjust machine proto message and tests

Signed-off-by: Lorenz Herzberger <lorenzherzberger@gmail.com>
This commit is contained in:
Lorenz Herzberger 2023-07-19 16:09:15 +02:00
parent 7dd410703b
commit fbe1a475a7
No known key found for this signature in database
GPG Key ID: FA5EE906EB55316A
9 changed files with 48 additions and 50 deletions

2
go.mod
View File

@ -22,6 +22,7 @@ require (
google.golang.org/genproto v0.0.0-20230306155012-7f2fa6fef1f4 google.golang.org/genproto v0.0.0-20230306155012-7f2fa6fef1f4
google.golang.org/grpc v1.55.0 google.golang.org/grpc v1.55.0
gopkg.in/yaml.v2 v2.4.0 gopkg.in/yaml.v2 v2.4.0
sigs.k8s.io/yaml v1.3.0
) )
require ( require (
@ -162,7 +163,6 @@ require (
gopkg.in/yaml.v3 v3.0.1 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect
nhooyr.io/websocket v1.8.6 // indirect nhooyr.io/websocket v1.8.6 // indirect
pgregory.net/rapid v0.5.5 // indirect pgregory.net/rapid v0.5.5 // indirect
sigs.k8s.io/yaml v1.3.0 // indirect
) )
replace github.com/syndtr/goleveldb => github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 replace github.com/syndtr/goleveldb => github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7

View File

@ -7,7 +7,7 @@ message Machine {
string name = 1; string name = 1;
string ticker = 2; string ticker = 2;
uint64 issued = 3; bool reissue = 3;
uint64 amount = 4; uint64 amount = 4;
uint64 precision = 5; uint64 precision = 5;
string issuerPlanetmint = 6; string issuerPlanetmint = 6;

View File

@ -75,7 +75,7 @@ func (s *E2ETestSuite) SetupSuite() {
machine := machinetypes.Machine{ machine := machinetypes.Machine{
Name: "machine", Name: "machine",
Ticker: "machine_ticker", Ticker: "machine_ticker",
Issued: 1, Reissue: true,
Amount: 1000, Amount: 1000,
Precision: 8, Precision: 8,
IssuerPlanetmint: pkHex, IssuerPlanetmint: pkHex,

View File

@ -23,7 +23,7 @@ func (s *E2ETestSuite) TestAttestMachineREST() {
machine := machinetypes.Machine{ machine := machinetypes.Machine{
Name: "machine", Name: "machine",
Ticker: "machine_ticker", Ticker: "machine_ticker",
Issued: 1, Reissue: true,
Amount: 1000, Amount: 1000,
Precision: 8, Precision: 8,
IssuerPlanetmint: pubKey, IssuerPlanetmint: pubKey,

View File

@ -74,7 +74,7 @@ func (s *E2ETestSuite) TestAttestMachine() {
machine := machinetypes.Machine{ machine := machinetypes.Machine{
Name: "machine", Name: "machine",
Ticker: "machine_ticker", Ticker: "machine_ticker",
Issued: 1, Reissue: true,
Amount: 1000, Amount: 1000,
Precision: 8, Precision: 8,
IssuerPlanetmint: pubKey, IssuerPlanetmint: pubKey,

View File

@ -30,7 +30,7 @@ func Machine(machineId string, pkPM string, pkL string) machinetypes.Machine {
m := machinetypes.Machine{ m := machinetypes.Machine{
Name: "machine", Name: "machine",
Ticker: "PM", Ticker: "PM",
Issued: 1, Reissue: true,
Amount: 1000, Amount: 1000,
Precision: 8, Precision: 8,
IssuerPlanetmint: pkPM, IssuerPlanetmint: pkPM,

View File

@ -13,9 +13,7 @@ import (
"io" "io"
"net/http" "net/http"
//lint:ignore SA1019 file is generated
"github.com/golang/protobuf/descriptor" "github.com/golang/protobuf/descriptor"
//lint:ignore SA1019 file is generated
"github.com/golang/protobuf/proto" "github.com/golang/protobuf/proto"
"github.com/grpc-ecosystem/grpc-gateway/runtime" "github.com/grpc-ecosystem/grpc-gateway/runtime"
"github.com/grpc-ecosystem/grpc-gateway/utilities" "github.com/grpc-ecosystem/grpc-gateway/utilities"
@ -32,8 +30,6 @@ var _ io.Reader
var _ status.Status var _ status.Status
var _ = runtime.String var _ = runtime.String
var _ = utilities.NewDoubleArray var _ = utilities.NewDoubleArray
//lint:ignore SA1019 file is generated
var _ = descriptor.ForMessage var _ = descriptor.ForMessage
var _ = metadata.Join var _ = metadata.Join

View File

@ -25,7 +25,7 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package
type Machine struct { type Machine struct {
Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
Ticker string `protobuf:"bytes,2,opt,name=ticker,proto3" json:"ticker,omitempty"` Ticker string `protobuf:"bytes,2,opt,name=ticker,proto3" json:"ticker,omitempty"`
Issued uint64 `protobuf:"varint,3,opt,name=issued,proto3" json:"issued,omitempty"` Reissue bool `protobuf:"varint,3,opt,name=reissue,proto3" json:"reissue,omitempty"`
Amount uint64 `protobuf:"varint,4,opt,name=amount,proto3" json:"amount,omitempty"` Amount uint64 `protobuf:"varint,4,opt,name=amount,proto3" json:"amount,omitempty"`
Precision uint64 `protobuf:"varint,5,opt,name=precision,proto3" json:"precision,omitempty"` Precision uint64 `protobuf:"varint,5,opt,name=precision,proto3" json:"precision,omitempty"`
IssuerPlanetmint string `protobuf:"bytes,6,opt,name=issuerPlanetmint,proto3" json:"issuerPlanetmint,omitempty"` IssuerPlanetmint string `protobuf:"bytes,6,opt,name=issuerPlanetmint,proto3" json:"issuerPlanetmint,omitempty"`
@ -81,11 +81,11 @@ func (m *Machine) GetTicker() string {
return "" return ""
} }
func (m *Machine) GetIssued() uint64 { func (m *Machine) GetReissue() bool {
if m != nil { if m != nil {
return m.Issued return m.Reissue
} }
return 0 return false
} }
func (m *Machine) GetAmount() uint64 { func (m *Machine) GetAmount() uint64 {
@ -269,31 +269,31 @@ func init() {
} }
var fileDescriptor_1bb279745bef7c4b = []byte{ var fileDescriptor_1bb279745bef7c4b = []byte{
// 371 bytes of a gzipped FileDescriptorProto // 378 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x92, 0x41, 0x4f, 0xf2, 0x30, 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x92, 0xcf, 0x4a, 0xeb, 0x40,
0x18, 0xc7, 0x29, 0xe3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f8, 0x64, 0x7d, 0xcd, 0x47, 0x3d, 0xae, 0xf8, 0x45, 0xbf, 0xa7, 0x59, 0x5a, 0xc1, 0xf6, 0xc0, 0x7d, 0x86, 0x76,
0x71, 0xb0, 0xb9, 0xf8, 0x36, 0xcd, 0xd5, 0x3f, 0x6a, 0x76, 0xca, 0x9a, 0x2f, 0xcf, 0x3f, 0x67, 0xf9, 0x7e, 0x7d, 0x19, 0xe1, 0x64, 0x3d, 0x38, 0xd9, 0x0c, 0xbe, 0x0b, 0x73, 0xfd, 0x87, 0x98,
0x04, 0x4c, 0x67, 0x04, 0x7c, 0xcf, 0x08, 0x78, 0x9f, 0x93, 0xca, 0x74, 0x4e, 0x2a, 0x5f, 0x73, 0x8d, 0x6d, 0xcc, 0xe7, 0xa7, 0xef, 0x33, 0x9b, 0x4c, 0x67, 0x36, 0xf9, 0x9c, 0xd9, 0xe4, 0x75,
0x52, 0xb9, 0x3d, 0x5c, 0xf9, 0x3c, 0x19, 0x26, 0xdd, 0xc9, 0xf2, 0x4e, 0xea, 0x97, 0x94, 0xab, 0x6e, 0xd7, 0xa6, 0x73, 0xbb, 0xf6, 0x31, 0xb7, 0x6b, 0xd7, 0xfb, 0x2b, 0x9e, 0x47, 0xc3, 0xa4,
0xbb, 0xba, 0xb9, 0x92, 0x67, 0x3f, 0x01, 0x00, 0x00, 0xff, 0xff, 0xd5, 0x3f, 0x35, 0x20, 0xb8, 0x3b, 0x59, 0x6e, 0xa5, 0x7a, 0x4a, 0x31, 0xbf, 0x69, 0xea, 0xa5, 0x3c, 0xf9, 0x0a, 0x00, 0x00,
0x02, 0x00, 0x00, 0xff, 0xff, 0x35, 0x4e, 0xee, 0x2e, 0xba, 0x02, 0x00, 0x00,
} }
func (m *Machine) Marshal() (dAtA []byte, err error) { func (m *Machine) Marshal() (dAtA []byte, err error) {
@ -359,8 +359,13 @@ func (m *Machine) MarshalToSizedBuffer(dAtA []byte) (int, error) {
i-- i--
dAtA[i] = 0x20 dAtA[i] = 0x20
} }
if m.Issued != 0 { if m.Reissue {
i = encodeVarintMachine(dAtA, i, uint64(m.Issued)) i--
if m.Reissue {
dAtA[i] = 1
} else {
dAtA[i] = 0
}
i-- i--
dAtA[i] = 0x18 dAtA[i] = 0x18
} }
@ -501,8 +506,8 @@ func (m *Machine) Size() (n int) {
if l > 0 { if l > 0 {
n += 1 + l + sovMachine(uint64(l)) n += 1 + l + sovMachine(uint64(l))
} }
if m.Issued != 0 { if m.Reissue {
n += 1 + sovMachine(uint64(m.Issued)) n += 2
} }
if m.Amount != 0 { if m.Amount != 0 {
n += 1 + sovMachine(uint64(m.Amount)) n += 1 + sovMachine(uint64(m.Amount))
@ -676,9 +681,9 @@ func (m *Machine) Unmarshal(dAtA []byte) error {
iNdEx = postIndex iNdEx = postIndex
case 3: case 3:
if wireType != 0 { if wireType != 0 {
return fmt.Errorf("proto: wrong wireType = %d for field Issued", wireType) return fmt.Errorf("proto: wrong wireType = %d for field Reissue", wireType)
} }
m.Issued = 0 var v int
for shift := uint(0); ; shift += 7 { for shift := uint(0); ; shift += 7 {
if shift >= 64 { if shift >= 64 {
return ErrIntOverflowMachine return ErrIntOverflowMachine
@ -688,11 +693,12 @@ func (m *Machine) Unmarshal(dAtA []byte) error {
} }
b := dAtA[iNdEx] b := dAtA[iNdEx]
iNdEx++ iNdEx++
m.Issued |= uint64(b&0x7F) << shift v |= int(b&0x7F) << shift
if b < 0x80 { if b < 0x80 {
break break
} }
} }
m.Reissue = bool(v != 0)
case 4: case 4:
if wireType != 0 { if wireType != 0 {
return fmt.Errorf("proto: wrong wireType = %d for field Amount", wireType) return fmt.Errorf("proto: wrong wireType = %d for field Amount", wireType)

View File

@ -13,9 +13,7 @@ import (
"io" "io"
"net/http" "net/http"
//lint:ignore SA1019 file is generated
"github.com/golang/protobuf/descriptor" "github.com/golang/protobuf/descriptor"
//lint:ignore SA1019 file is generated
"github.com/golang/protobuf/proto" "github.com/golang/protobuf/proto"
"github.com/grpc-ecosystem/grpc-gateway/runtime" "github.com/grpc-ecosystem/grpc-gateway/runtime"
"github.com/grpc-ecosystem/grpc-gateway/utilities" "github.com/grpc-ecosystem/grpc-gateway/utilities"
@ -32,8 +30,6 @@ var _ io.Reader
var _ status.Status var _ status.Status
var _ = runtime.String var _ = runtime.String
var _ = utilities.NewDoubleArray var _ = utilities.NewDoubleArray
//lint:ignore SA1019 file is generated
var _ = descriptor.ForMessage var _ = descriptor.ForMessage
var _ = metadata.Join var _ = metadata.Join