testutils

package
v1.0.10-0...-7349ede Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 20, 2023 License: MIT Imports: 36 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateJetDrop

func CreateJetDrop(db *gorm.DB, jetDrop models.JetDrop) error

CreatePulse creates provided jet drop at db

func CreateJetDropCanonical

func CreateJetDropCanonical(records []types.Record) types.JetDrop

CreateJetDropCanonical returns generated jet drop with provided record and without prevHash

func CreateJetDrops

func CreateJetDrops(db *gorm.DB, jetDrops []models.JetDrop) error

CreateJetDrops creates provided jet drop list to db

func CreatePulse

func CreatePulse(db *gorm.DB, pulse models.Pulse) error

CreatePulse creates provided pulse at db

func CreatePulses

func CreatePulses(db *gorm.DB, pulses []models.Pulse) error

CreatePulses creates provided pulses to db

func CreateRecord

func CreateRecord(db *gorm.DB, record models.Record) error

CreateRecord creates provided record at db

func CreateRecordCanonical

func CreateRecordCanonical() types.Record

CreateRecordCanonical returns generated record

func GenerateJetDropsWithSomeJetID

func GenerateJetDropsWithSomeJetID(t *testing.T, jCount int) (string, []models.JetDrop, []models.Pulse)

GenerateJetDropsWithSomeJetID returns a list of JetDrops with some JetID and ascending pulseNumber

func GenerateJetDropsWithSplit

func GenerateJetDropsWithSplit(t *testing.T, pulseCount, jDCount int, depth int) ([]models.JetDrop, []models.Pulse)

GenerateJetDropsWithSplit returns a jetdrops with splited by depth in different pulse

func GenerateJetIDTree

func GenerateJetIDTree(pn insolar.PulseNumber, depth int) map[insolar.PulseNumber]map[insolar.JetID][][]byte

GenerateJetIDTree generates tree of splitted JetDrops with specified depth

func GenerateRandBytes

func GenerateRandBytes() []byte

GenerateRandBytes generates random bytes array

func GenerateRecordInNextPulse

func GenerateRecordInNextPulse(prevPulse insolar.PulseNumber) *exporter.Record

func GenerateRecords

func GenerateRecords(batchSize int) func() (record *exporter.Record, e error)

GenerateRecords returns a function for generating record with error

func GenerateRecordsFromOneJetSilence

func GenerateRecordsFromOneJetSilence(differentPulseSize, recordCount int) []*exporter.Record

GenerateRecordsFromOneJetSilence returns new generated records from one JetID

func GenerateRecordsSilence

func GenerateRecordsSilence(count int) []*exporter.Record

GenerateRecordsSilence returns new generated records without errors

func GenerateRecordsWIthSplitJetDrops

func GenerateRecordsWIthSplitJetDrops(pn insolar.PulseNumber, depth int, recordsInJetDrop int) (
	records []*exporter.Record, jetDropTree map[insolar.PulseNumber]map[insolar.JetID][][]byte)

generate records with split JetDrops

func GenerateRecordsWithDifferencePulses

func GenerateRecordsWithDifferencePulses(differentPulseSize, recordCount int, startpn int64) func() (record *exporter.Record, e error)

GenerateRecordsWithDifferencePulses generates records with recordCount for each pulse

func GenerateRecordsWithDifferencePulsesSilence

func GenerateRecordsWithDifferencePulsesSilence(differentPulseSize, recordCount int) []*exporter.Record

func GenerateRequestRecord

func GenerateRequestRecord(pulse insolar.PulseNumber, objectID insolar.ID) *exporter.Record

func GenerateUniqueJetID

func GenerateUniqueJetID() insolar.JetID

func GenerateVirtualActivateRecord

func GenerateVirtualActivateRecord(pulse insolar.PulseNumber, objectID, requestID insolar.ID) (record *exporter.Record)

func GenerateVirtualAmendRecord

func GenerateVirtualAmendRecord(pulse insolar.PulseNumber, objectID, prevStateID insolar.ID) *exporter.Record

func GenerateVirtualAmendRecordsLinkedArray

func GenerateVirtualAmendRecordsLinkedArray(pulse insolar.PulseNumber, jetID insolar.JetID, objectID, prevStateID insolar.ID, recordsCount int) []*exporter.Record

func GenerateVirtualDeactivateRecord

func GenerateVirtualDeactivateRecord(pulse insolar.PulseNumber, objectID, prevStateID insolar.ID) *exporter.Record

func GenerateVirtualRequestRecord

func GenerateVirtualRequestRecord(pulse insolar.PulseNumber, objectID insolar.ID) (record *exporter.Record)

func GenerateVirtualResultRecord

func GenerateVirtualResultRecord(pulse insolar.PulseNumber, objectID, requestID insolar.ID) (record *exporter.Record)

func InitJetDropDB

func InitJetDropDB(pulse models.Pulse) models.JetDrop

InitJetDropDB returns generated jet drop with provided pulse

func InitJetDropWithRecords

func InitJetDropWithRecords(t *testing.T, s interfaces.StorageSetter, recordAmount int, pulse models.Pulse) models.JetDrop

InitJetDropWithRecords create new JetDrop, generate random records, save SaveJetDropData

func InitNextPulseDB

func InitNextPulseDB(pn int64) (models.Pulse, error)

InitNextPulseDB returns generated pulse after pn

func InitPulseDB

func InitPulseDB() (models.Pulse, error)

InitPulseDB returns generated pulse

func InitRecordDB

func InitRecordDB(jetDrop models.JetDrop) models.Record

InitRecordDB returns generated record

func OrderedRecords

func OrderedRecords(t *testing.T, db *gorm.DB, jetDrop models.JetDrop, objRef insolar.ID, amount int) []models.Record

func RandNumberOverRange

func RandNumberOverRange(min int64, max int64) int64

RandNumberOverRange generates random number over a range

func RandomString

func RandomString(n int) string

Generate random string with specified length

func RunDBInDocker

func RunDBInDocker(dbName, dbPassword string) (*dockertest.Pool, *dockertest.Resource, func())

func RunDBInDockerWithPortBindings

func RunDBInDockerWithPortBindings(dbName, dbPassword string) (int, *dockertest.Pool, *dockertest.Resource, func())

RunDBInDockerWithPortBindings start a container with binding port to host machine

func SetupDB

func SetupDB() (*gorm.DB, func(), error)

func TruncateTables

func TruncateTables(t testing.TB, db *gorm.DB, models []interface{})

Types

type ObjectLifeline

type ObjectLifeline struct {
	StateRecords []RecordsByPulse
	SideRecords  []RecordsByPulse
	ObjID        insolar.ID
}

func GenerateObjectLifeline

func GenerateObjectLifeline(pulseCount, recordsInPulse int) ObjectLifeline

func (*ObjectLifeline) GetAllRecords

func (l *ObjectLifeline) GetAllRecords() []*exporter.Record

func (*ObjectLifeline) GetStateRecords

func (l *ObjectLifeline) GetStateRecords() []*exporter.Record

type RecordsByPulse

type RecordsByPulse struct {
	Pn      insolar.PulseNumber
	Records []*exporter.Record
}

type TestGRPCServer

type TestGRPCServer struct {
	Listener net.Listener
	Server   *grpc.Server
	Network  string
	Address  string
}

func CreateTestGRPCServer

func CreateTestGRPCServer(t testing.TB, config *TestGRPCServerConfig) *TestGRPCServer

func (*TestGRPCServer) Serve

func (s *TestGRPCServer) Serve(t testing.TB)

Serve starts to read gRPC requests

type TestGRPCServerConfig

type TestGRPCServerConfig struct {
	VersionChecker bool
	HeavyVersion   *int
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL