Skip to content

Commit

Permalink
remove outdated field. use bytes and sig generator
Browse files Browse the repository at this point in the history
  • Loading branch information
illia-malachyn committed Oct 17, 2024
1 parent cf5e618 commit 276409c
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 8 deletions.
2 changes: 0 additions & 2 deletions access/grpc/convert/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,6 @@ func MessageToFullCollection(m []*entities.Transaction) (flow.FullCollection, er
func CollectionGuaranteeToMessage(g flow.CollectionGuarantee) *entities.CollectionGuarantee {
return &entities.CollectionGuarantee{
CollectionId: g.CollectionID.Bytes(),
Signatures: g.Signatures,
ReferenceBlockId: g.ReferenceBlockID.Bytes(),
Signature: g.Signature,
SignerIndices: g.SignerIndices,
Expand All @@ -403,7 +402,6 @@ func MessageToCollectionGuarantee(m *entities.CollectionGuarantee) (flow.Collect

return flow.CollectionGuarantee{
CollectionID: flow.HashToID(m.CollectionId),
Signatures: m.Signatures,
ReferenceBlockID: flow.HashToID(m.ReferenceBlockId),
Signature: m.Signature,
SignerIndices: m.SignerIndices,
Expand Down
1 change: 0 additions & 1 deletion collection.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ func (c Collection) Encode() []byte {
// A CollectionGuarantee is an attestation signed by the nodes that have guaranteed a collection.
type CollectionGuarantee struct {
CollectionID Identifier
Signatures [][]byte
ReferenceBlockID Identifier
Signature []byte
SignerIndices []byte
Expand Down
33 changes: 28 additions & 5 deletions test/entities.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
package test

import (
"crypto/rand"
"errors"
"fmt"
"strconv"
Expand Down Expand Up @@ -224,7 +225,9 @@ func (c *FullCollection) New() *flow.FullCollection {
}

type CollectionGuarantees struct {
ids *Identifiers
ids *Identifiers
bytes *Bytes
sigs *Signatures
}

type BlockSeals struct {
Expand All @@ -233,17 +236,18 @@ type BlockSeals struct {

func CollectionGuaranteeGenerator() *CollectionGuarantees {
return &CollectionGuarantees{
ids: IdentifierGenerator(),
ids: IdentifierGenerator(),
bytes: BytesGenerator(),
sigs: SignaturesGenerator(),
}
}

func (g *CollectionGuarantees) New() *flow.CollectionGuarantee {
return &flow.CollectionGuarantee{
CollectionID: g.ids.New(),
Signatures: [][]byte{[]byte("dummy")},
ReferenceBlockID: g.ids.New(),
Signature: []byte("dummy"),
SignerIndices: []byte("dummy"),
Signature: g.sigs.New()[0],
SignerIndices: g.bytes.New(),
}
}

Expand Down Expand Up @@ -575,3 +579,22 @@ func (g *LightTransactionResults) New() *flow.LightTransactionResult {
ComputationUsed: uint64(42),
}
}

type Bytes struct {
count int
}

func BytesGenerator() *Bytes {
return &Bytes{
count: 64,
}
}

func (b *Bytes) New() []byte {
randomBytes := make([]byte, b.count)
_, err := rand.Read(randomBytes)
if err != nil {
panic("failed to generate random bytes")
}
return randomBytes
}

0 comments on commit 276409c

Please sign in to comment.