tests

package
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2023 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CreateProposal      = "CreateProposal"
	CreateVCBC          = "CreateVCBC"
	CreateFillGap       = "CreateFillGap"
	CreateFiller        = "CreateFiller"
	CreateABAInit       = "CreateABAInit"
	CreateABAAux        = "CreateABAAux"
	CreateABAConf       = "CreateABAConf"
	CreateABAFinish     = "CreateABAFinish"
	CreateVCBCBroadcast = "CreateVCBCBroadcast"
	CreateVCBCSend      = "CreateVCBCSend"
	CreateVCBCReady     = "CreateVCBCReady"
	CreateVCBCFinal     = "CreateVCBCFinal"
	CreateVCBCRequest   = "CreateVCBCRequest"
	CreateVCBCAnswer    = "CreateVCBCAnswer"
)
View Source
const ChangeProposerFuncInstanceHeight = 1

ChangeProposerFuncInstanceHeight tests with this height will return proposer operator ID 2

Variables

View Source
var AggregatedMsgBytes = func(author types.OperatorID, priority alea.Priority) []byte {

	readyMsgs := make([]*alea.SignedMessage, 0)
	for opID := 1; opID <= 3; opID++ {
		signedMessage := testingutils.SignAleaMsg(testingutils.Testing4SharesSet().Shares[types.OperatorID(opID)], types.OperatorID(opID), &alea.Message{
			MsgType:    alea.VCBCReadyMsgType,
			Height:     alea.FirstHeight,
			Round:      alea.FirstRound,
			Identifier: []byte{1, 2, 3, 4},
			Data:       testingutils.VCBCReadyDataBytes(Hash, priority, author),
		})
		readyMsgs = append(readyMsgs, signedMessage)
	}

	aggregatedReadyMessages, err := alea.AggregateMsgs(readyMsgs)
	if err != nil {
		errors.Wrap(err, "could not aggregate vcbcready messages in happy flow")
	}
	aggregatedMsgBytes, err := aggregatedReadyMessages.Encode()
	if err != nil {
		errors.Wrap(err, "could not encode aggregated msg")
	}
	return aggregatedMsgBytes
}
View Source
var AggregatedMsgBytes2 = func(author types.OperatorID, priority alea.Priority) []byte {

	readyMsgs := make([]*alea.SignedMessage, 0)
	for opID := 1; opID <= 3; opID++ {
		signedMessage := testingutils.SignAleaMsg(testingutils.Testing4SharesSet().Shares[types.OperatorID(opID)], types.OperatorID(opID), &alea.Message{
			MsgType:    alea.VCBCReadyMsgType,
			Height:     alea.FirstHeight,
			Round:      alea.FirstRound,
			Identifier: []byte{1, 2, 3, 4},
			Data:       testingutils.VCBCReadyDataBytes(Hash2, priority, author),
		})
		readyMsgs = append(readyMsgs, signedMessage)
	}

	aggregatedReadyMessages, err := alea.AggregateMsgs(readyMsgs)
	if err != nil {
		errors.Wrap(err, "could not aggregate vcbcready messages in happy flow")
	}
	aggregatedMsgBytes, err := aggregatedReadyMessages.Encode()
	if err != nil {
		errors.Wrap(err, "could not encode aggregated msg")
	}
	return aggregatedMsgBytes
}
View Source
var AggregatedMsgBytes3 = func(author types.OperatorID, priority alea.Priority) []byte {

	readyMsgs := make([]*alea.SignedMessage, 0)
	for opID := 1; opID <= 3; opID++ {
		signedMessage := testingutils.SignAleaMsg(testingutils.Testing4SharesSet().Shares[types.OperatorID(opID)], types.OperatorID(opID), &alea.Message{
			MsgType:    alea.VCBCReadyMsgType,
			Height:     alea.FirstHeight,
			Round:      alea.FirstRound,
			Identifier: []byte{1, 2, 3, 4},
			Data:       testingutils.VCBCReadyDataBytes(Hash3, priority, author),
		})
		readyMsgs = append(readyMsgs, signedMessage)
	}

	aggregatedReadyMessages, err := alea.AggregateMsgs(readyMsgs)
	if err != nil {
		errors.Wrap(err, "could not aggregate vcbcready messages in happy flow")
	}
	aggregatedMsgBytes, err := aggregatedReadyMessages.Encode()
	if err != nil {
		errors.Wrap(err, "could not encode aggregated msg")
	}
	return aggregatedMsgBytes
}
View Source
var AggregatedMsgBytesList = func(author types.OperatorID, priority alea.Priority) [][]byte {
	return [][]byte{AggregatedMsgBytes(author, priority), AggregatedMsgBytes2(author, priority+1)}
}
View Source
var ProposalData1, _ = SignedProposal1.Message.GetProposalData()
View Source
var ProposalData2, _ = SignedProposal2.Message.GetProposalData()
View Source
var ProposalData3, _ = SignedProposal3.Message.GetProposalData()
View Source
var ProposalData4, _ = SignedProposal4.Message.GetProposalData()
View Source
var ProposalData5, _ = SignedProposal5.Message.GetProposalData()
View Source
var ProposalData6, _ = SignedProposal6.Message.GetProposalData()
View Source
var SignedProposal1 = testingutils.SignAleaMsg(testingutils.Testing4SharesSet().Shares[1], types.OperatorID(1), &alea.Message{
	MsgType:    alea.ProposalMsgType,
	Height:     alea.FirstHeight,
	Round:      alea.FirstRound,
	Identifier: []byte{1, 2, 3, 4},
	Data:       testingutils.ProposalDataBytesAlea([]byte{1, 2, 3, 4}),
})
View Source
var SignedProposal2 = testingutils.SignAleaMsg(testingutils.Testing4SharesSet().Shares[1], types.OperatorID(1), &alea.Message{
	MsgType:    alea.ProposalMsgType,
	Height:     alea.FirstHeight,
	Round:      alea.FirstRound,
	Identifier: []byte{1, 2, 3, 4},
	Data:       testingutils.ProposalDataBytesAlea([]byte{5, 6, 7, 8}),
})
View Source
var SignedProposal3 = testingutils.SignAleaMsg(testingutils.Testing4SharesSet().Shares[1], types.OperatorID(1), &alea.Message{
	MsgType:    alea.ProposalMsgType,
	Height:     alea.FirstHeight,
	Round:      alea.FirstRound,
	Identifier: []byte{1, 2, 3, 4},
	Data:       testingutils.ProposalDataBytesAlea([]byte{1, 3, 5, 7}),
})
View Source
var SignedProposal4 = testingutils.SignAleaMsg(testingutils.Testing4SharesSet().Shares[1], types.OperatorID(1), &alea.Message{
	MsgType:    alea.ProposalMsgType,
	Height:     alea.FirstHeight,
	Round:      alea.FirstRound,
	Identifier: []byte{1, 2, 3, 4},
	Data:       testingutils.ProposalDataBytesAlea([]byte{2, 4, 6, 8}),
})
View Source
var SignedProposal5 = testingutils.SignAleaMsg(testingutils.Testing4SharesSet().Shares[1], types.OperatorID(1), &alea.Message{
	MsgType:    alea.ProposalMsgType,
	Height:     alea.FirstHeight,
	Round:      alea.FirstRound,
	Identifier: []byte{1, 2, 3, 4},
	Data:       testingutils.ProposalDataBytesAlea([]byte{1, 5, 2, 3}),
})
View Source
var SignedProposal6 = testingutils.SignAleaMsg(testingutils.Testing4SharesSet().Shares[1], types.OperatorID(1), &alea.Message{
	MsgType:    alea.ProposalMsgType,
	Height:     alea.FirstHeight,
	Round:      alea.FirstRound,
	Identifier: []byte{1, 2, 3, 4},
	Data:       testingutils.ProposalDataBytesAlea([]byte{1, 6, 2, 3}),
})

Functions

This section is empty.

Types

type ControllerSpecTest

type ControllerSpecTest struct {
	Name            string
	RunInstanceData []*RunInstanceData
	OutputMessages  []*alea.SignedMessage
	ExpectedError   string
}

func (*ControllerSpecTest) Run

func (test *ControllerSpecTest) Run(t *testing.T)

func (*ControllerSpecTest) TestName

func (test *ControllerSpecTest) TestName() string

type CreateMsgSpecTest

type CreateMsgSpecTest struct {
	Name           string
	Value          []byte
	Proposals      []*alea.ProposalData
	Priority       alea.Priority
	Vote           byte
	Votes          []byte
	Author         types.OperatorID
	Entries        [][]*alea.ProposalData
	Priorities     []alea.Priority
	Round          alea.Round
	ACRound        alea.ACRound
	Hash           []byte
	AggregatedMsg  []byte
	AggregatedMsgs [][]byte
	CreateType     string
	ExpectedRoot   string
	ExpectedError  string
}

func (*CreateMsgSpecTest) Run

func (test *CreateMsgSpecTest) Run(t *testing.T)

func (*CreateMsgSpecTest) TestName

func (test *CreateMsgSpecTest) TestName() string

type DecidedState

type DecidedState struct {
	DecidedVal               []byte
	DecidedCnt               uint
	BroadcastedDecided       *alea.SignedMessage
	CalledSyncDecidedByRange bool
	DecidedByRangeValues     [2]alea.Height
}

type MsgProcessingSpecTest

type MsgProcessingSpecTest struct {
	Name               string
	Pre                *alea.Instance
	PostRoot           string
	InputMessages      []*alea.SignedMessage
	OutputMessages     []*alea.SignedMessage
	ExpectedError      string
	ExpectedTimerState *testingutils.TimerStateAlea
	DontRunAC          bool
}

func HappyFlow

func HappyFlow() *MsgProcessingSpecTest

HappyFlow tests a simple full happy flow until decided

func SevenOperators

func SevenOperators() *MsgProcessingSpecTest

SevenOperators tests a simple full happy flow until decided

func TenOperators

func TenOperators() *MsgProcessingSpecTest

TenOperators tests a simple full happy flow until decided

func ThirteenOperators

func ThirteenOperators() *MsgProcessingSpecTest

ThirteenOperators tests a simple full happy flow until decided

func (*MsgProcessingSpecTest) Run

func (test *MsgProcessingSpecTest) Run(t *testing.T)

func (*MsgProcessingSpecTest) TestName

func (test *MsgProcessingSpecTest) TestName() string

type MsgSpecTest

type MsgSpecTest struct {
	Name            string
	Messages        []*alea.SignedMessage
	EncodedMessages [][]byte
	ExpectedRoots   [][]byte
	ExpectedError   string
}

MsgSpecTest tests encoding and decoding of a msg

func (*MsgSpecTest) Run

func (test *MsgSpecTest) Run(t *testing.T)

func (*MsgSpecTest) TestName

func (test *MsgSpecTest) TestName() string

type RoundRobinSpecTest

type RoundRobinSpecTest struct {
	Name      string
	Share     *types.Share
	Heights   []alea.Height
	Rounds    []alea.Round
	Proposers []types.OperatorID
}

func (*RoundRobinSpecTest) Run

func (test *RoundRobinSpecTest) Run(t *testing.T)

func (*RoundRobinSpecTest) TestName

func (test *RoundRobinSpecTest) TestName() string

type RunInstanceData

type RunInstanceData struct {
	InputValue           []byte
	InputMessages        []*alea.SignedMessage
	ControllerPostRoot   string
	ExpectedTimerState   *testingutils.TimerStateAlea
	ExpectedDecidedState DecidedState
}

Jump to

Keyboard shortcuts

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