Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

switch from workload generator to procedural test style for VM-defined workloads #1359

Closed
github-actions bot opened this issue Aug 20, 2024 · 1 comment · Fixed by #1667
Closed

switch from workload generator to procedural test style for VM-defined workloads #1359

github-actions bot opened this issue Aug 20, 2024 · 1 comment · Fixed by #1667

Comments

@github-actions
Copy link

Line: 21

type TxWorkloadFactory interface {
// NewWorkloads returns a set of TxWorkloadIterators from the VM. VM developers can use this function
// to define each sequence of transactions that should be tested.
// TODO: switch from workload generator to procedural test style for VM-defined workloads
NewWorkloads(uri string) ([]TxWorkloadIterator, error)
// Generates a new TxWorkloadIterator that generates a sequence of transactions of the given size.
NewSizedTxWorkload(uri string, size int) (TxWorkloadIterator, error)
}
type TxAssertion func(ctx context.Context, uri string) error

@aaronbuchwald
Copy link
Collaborator

We should support writing procedural style VM tests that assume only an injected dependency for how to issue and confirm txs and get the URIs of the HyperSDK server for each available node, so that we can send API requests and confirm the state of the chain as needed.

This should replace NewWorkloads(...) with a format that looks like:

type TestNetwork interface {
	ConfirmTxs([]*chain.Transaction)
	URIs() []string
}

And allows users to write their tests in a procedural format like:

func executeTest(vm TestNetwork) {
	uris := vm.URIs()
	// Step 1
	vm.ConfirmTxs([]*chain.Transaction{})
	client := indexer.NewClient(uris[0])
	_ = client // Perform some API calls to confirm the state of the chain
	// Step 2
	vm.ConfirmTxs([]*chain.Transaction{})
	// Step 3
	vm.ConfirmTxs([]*chain.Transaction{})
}
  1. Return a TestNetwork interface from the environment setup function and execute tests against it
  2. Create a TestRegistry that allows users to register each of their test functions and then executes the registry in the existing integration.go / e2e.go files

We'll need to implement TestNetwork in both e2e (issue via jsonrpc API and confirm with tx indexer) and integration (issue via vm.Submit and confirm either via indexer API or checking the block contents directly) environments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants