utils

package
v0.0.22 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2026 License: MIT Imports: 43 Imported by: 0

Documentation

Index

Constants

View Source
const TestChainID uint64 = 14

TestChainID is the chain ID embedded in every integration instruction and configured on the TEE via SetChainIDOnTEE. The instruction's signed hash and the TEE's expectedChainID must agree.

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:  6000 * time.Millisecond,
	Interval: 50 * time.Millisecond,
}

Functions

func ActionResultSignHash added in v0.0.18

func ActionResultSignHash(t *testing.T, innerHash []byte) []byte

ActionResultSignHash recomputes the domain-separated preimage the TEE signs over an action result: signing.Payload{TEEActionResult, TestChainID, ActionResult.Hash()}.Hash(). The returned bytes are suitable for teeUtils.VerifySignature, which applies the EIP-191 text-hash prefix.

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 SetChainIDOnTEE added in v0.0.18

func SetChainIDOnTEE(t *testing.T, port uint, chainID uint64)

SetChainIDOnTEE configures the TEE node's chain ID. The node refuses to process instructions until this is set, and the value must match the chain ID the actions hash their messages with.

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/proxy/proxy.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