utils

package
v0.0.17 Latest Latest
Warning

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

Go to latest
Published: May 14, 2026 License: MIT Imports: 40 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var StorageTimeConfig = struct {
	CycleInternal          time.Duration
	CycleQueueResponseWait time.Duration
}{

	CycleInternal:          50 * time.Millisecond,
	CycleQueueResponseWait: 10 * time.Second,
}
View Source
var TestTimeConfig = struct {
	Timeout  time.Duration
	Interval time.Duration
}{
	Timeout:  2000 * time.Millisecond,
	Interval: 50 * time.Millisecond,
}

Functions

func BuildInstructionData

func BuildInstructionData(
	t *testing.T,
	opType op.Type,
	opCommand op.Command,
	originalMessage []byte,
	timestamp uint64,
	additionalFixedMessageRaw any,
	additionalVariableMessage any,
	cosigners []common.Address,
	cosignersThreshold uint64,
	teeID common.Address,
	rewardEpochID uint32,
) *instruction.Data

func BuildInstructionDataWithID

func BuildInstructionDataWithID(
	t *testing.T,
	instructionID common.Hash,
	opType op.Type,
	opCommand op.Command,
	originalMessage []byte,
	timestamp uint64,
	additionalFixedMessageRaw any,
	additionalVariableMessage any,
	cosigners []common.Address,
	cosignersThreshold uint64,
	teeID common.Address,
	rewardEpochID uint32,
) *instruction.Data

func FetchAndVerifyActionResponse

func FetchAndVerifyActionResponse(t *testing.T, port uint, actionID common.Hash, submissionTag types.SubmissionTag, opType op.Type, opCommand op.Command, teeID common.Address, expectedStatus uint8) *types.ActionResponse

FetchAndVerifyActionResponse Fetches ActionResponse and verifies the signature

func FetchAndVerifyRewardingData

func FetchAndVerifyRewardingData(t *testing.T, pc *ProxyConfig, instructionID common.Hash, opType op.Type, opCommand op.Command, receipts []*voting.SignedReceipt)

FetchAndVerifyRewardingData Fetches rewarding data and verifies the action response and vote sequence

func GetTeeInfo

func GetTeeInfo(t *testing.T, pc *ProxyConfig) *types.TeeInfoResponse

GetTeeInfo Fetches TeeInfoResponse until TestTimeConfig.Timeout every TestTimeConfig.Interval

func GetVotingStatuses

func GetVotingStatuses(t *testing.T, pc *ProxyConfig, rewardEpochID uint32, instructionID common.Hash) *voting.Statuses

GetVotingStatuses Fetches VoteStatus until TestTimeConfig.Timeout every TestTimeConfig.Interval

func GetWalletInfo

func GetWalletInfo(t *testing.T, pc *ProxyConfig, walletID [32]byte, keyID uint64) *pkgwallets.KeyData

GetWalletInfo Fetches KeyData until TestTimeConfig.Timeout every TestTimeConfig.Interval

func SetProxyURLOnTEE

func SetProxyURLOnTEE(t *testing.T, port uint, proxyURL string)

func SignAndSendInstruction

func SignAndSendInstruction(t *testing.T, iData *instruction.Data, privKey *ecdsa.PrivateKey, port uint) *voting.SignedReceipt

func SignAndSendInstructions

func SignAndSendInstructions(t *testing.T, iData *instruction.Data, privKeys []*ecdsa.PrivateKey, port uint) []*voting.SignedReceipt

func SignAndSendInstructionsWithAddVarMsgs

func SignAndSendInstructionsWithAddVarMsgs(t *testing.T, iData *instruction.Data, additionalVariableMessage []hexutil.Bytes, privKeys []*ecdsa.PrivateKey, port uint) ([]*voting.SignedReceipt, []instruction.Data)

func VerifyActionResponse

func VerifyActionResponse(t *testing.T, res *types.ActionResponse, submissionTag types.SubmissionTag, opType op.Type, opCommand op.Command, teeID common.Address)

VerifyActionResponse Verifies the action response against expected values and checks the signature

func VerifyReceipts

func VerifyReceipts(t *testing.T, receipts []*voting.SignedReceipt, iData *instruction.Data)

func VerifyReceiptsForMultipleInstructions

func VerifyReceiptsForMultipleInstructions(t *testing.T, receipts []*voting.SignedReceipt, insts []instruction.Data)

func VerifyVotingStatus

func VerifyVotingStatus(t *testing.T, statuses *voting.Statuses, nCosigners, cosignersThreshold, threshold uint16)

VerifyVotingStatus Verifies number of cosigners, cosigners threshold, finalized and weight of the VoteStatus

Types

type ProxyConfig

type ProxyConfig struct {
	ExtPort     uint
	IntPort     uint
	TeeID       common.Address
	TeePubKey   *ecdsa.PublicKey
	ProxyPubKey *ecdsa.PublicKey
	Aq          *queue.ActionQueues
	Rs          *result.ResultStorage
	Vc          *config.Voting
	Pc          chan policy.SigningPolicy
	Ws          *wallets.Service
	If          *info.Service
}

func RunProxy

func RunProxy(t *testing.T, internalPort, externalPort uint, proxyPk *ecdsa.PrivateKey, wg *sync.WaitGroup) (*ProxyConfig, func())

RunProxy simulates behavior of internal/initialize.go - Starts internal and external proxy servers, and fetches TEE ID from TEE

Jump to

Keyboard shortcuts

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