Skip to content

Commit

Permalink
make use of sig generator
Browse files Browse the repository at this point in the history
  • Loading branch information
illia-malachyn committed Oct 17, 2024
1 parent 9ca8aa4 commit e8d7248
Showing 1 changed file with 32 additions and 6 deletions.
38 changes: 32 additions & 6 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 @@ -228,7 +229,9 @@ type CollectionGuarantees struct {
}

type BlockSeals struct {
ids *Identifiers
ids *Identifiers
sigs *Signatures
bytes *BytesGenerator
}

func CollectionGuaranteeGenerator() *CollectionGuarantees {
Expand All @@ -245,22 +248,24 @@ func (g *CollectionGuarantees) New() *flow.CollectionGuarantee {

func BlockSealGenerator() *BlockSeals {
return &BlockSeals{
ids: IdentifierGenerator(),
ids: IdentifierGenerator(),
sigs: SignaturesGenerator(),
bytes: NewBytesGenerator(),
}
}

func (g *BlockSeals) New() *flow.BlockSeal {
sigs := []*flow.AggregatedSignature{{
VerifierSignatures: [][]byte{[]byte("dummy")},
VerifierSignatures: g.sigs.New(),
SignerIds: []flow.Identifier{g.ids.New()},
}}

return &flow.BlockSeal{
BlockID: g.ids.New(),
ExecutionReceiptID: g.ids.New(),
ExecutionReceiptSignatures: [][]byte{[]byte("dummy")},
ResultApprovalSignatures: [][]byte{[]byte("dummy")},
FinalState: []byte("dummy"),
ExecutionReceiptSignatures: g.sigs.New(),
ResultApprovalSignatures: g.sigs.New(),
FinalState: g.bytes.New(),
ResultId: g.ids.New(),
AggregatedApprovalSigs: sigs,
}
Expand Down Expand Up @@ -581,3 +586,24 @@ func (g *LightTransactionResults) New() *flow.LightTransactionResult {
ComputationUsed: uint64(42),
}
}

type Bytes []byte

type BytesGenerator struct {
count int
}

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

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

0 comments on commit e8d7248

Please sign in to comment.