Commit 86632e48 authored by Yann Hodique's avatar Yann Hodique Committed by GitHub

fix(kurtosis-devnet): try harder to avoid local dependency (#13727)

* fix(kurtosis-devnet): ensure tests pass without kurtosis running

* fix(kurtosis-devnet): forbid tests from using local kurtosis context
parent b9184c93
set shell := ["/bin/bash", "-c"] set shell := ["/bin/bash", "-c"]
test:
go test --tags=testonly ./...
_kurtosis-run PACKAGE_NAME ARG_FILE ENCLAVE: _kurtosis-run PACKAGE_NAME ARG_FILE ENCLAVE:
kurtosis run {{PACKAGE_NAME}} --args-file {{ARG_FILE}} --enclave {{ENCLAVE}} --show-enclave-inspect=false --image-download=missing kurtosis run {{PACKAGE_NAME}} --args-file {{ARG_FILE}} --enclave {{ENCLAVE}} --show-enclave-inspect=false --image-download=missing
......
...@@ -186,13 +186,3 @@ func (w *starlarkInfoWrapper) GetMessage() string { ...@@ -186,13 +186,3 @@ func (w *starlarkInfoWrapper) GetMessage() string {
func (w *starlarkInstructionResultWrapper) GetSerializedInstructionResult() string { func (w *starlarkInstructionResultWrapper) GetSerializedInstructionResult() string {
return w.StarlarkInstructionResult.SerializedInstructionResult return w.StarlarkInstructionResult.SerializedInstructionResult
} }
func GetDefaultKurtosisContext() (interfaces.KurtosisContextInterface, error) {
kCtx, err := kurtosis_context.NewKurtosisContextFromLocalEngine()
if err != nil {
return nil, fmt.Errorf("failed to create Kurtosis context: %w", err)
}
return KurtosisContextWrapper{
KurtosisContext: kCtx,
}, nil
}
//go:build !testonly
// +build !testonly
package wrappers
import (
"fmt"
"github.com/ethereum-optimism/optimism/kurtosis-devnet/pkg/kurtosis/api/interfaces"
"github.com/kurtosis-tech/kurtosis/api/golang/engine/lib/kurtosis_context"
)
func GetDefaultKurtosisContext() (interfaces.KurtosisContextInterface, error) {
kCtx, err := kurtosis_context.NewKurtosisContextFromLocalEngine()
if err != nil {
return nil, fmt.Errorf("failed to create Kurtosis context: %w", err)
}
return KurtosisContextWrapper{
KurtosisContext: kCtx,
}, nil
}
//go:build testonly
// +build testonly
package wrappers
import (
"errors"
"github.com/ethereum-optimism/optimism/kurtosis-devnet/pkg/kurtosis/api/interfaces"
)
func GetDefaultKurtosisContext() (interfaces.KurtosisContextInterface, error) {
return nil, errors.New("attempting to use local Kurtosis context in testonly mode")
}
...@@ -50,7 +50,21 @@ func TestKurtosisDeployer(t *testing.T) { ...@@ -50,7 +50,21 @@ func TestKurtosisDeployer(t *testing.T) {
for _, tt := range tests { for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) { t.Run(tt.name, func(t *testing.T) {
d, err := NewKurtosisDeployer(tt.opts...) // Create a fake Kurtosis context
fakeCtx := &fake.KurtosisContext{
EnclaveCtx: &fake.EnclaveContext{
Responses: []interfaces.StarlarkResponse{
&fake.StarlarkResponse{
IsSuccessful: true,
},
},
},
}
// Add the fake context to the options
opts := append(tt.opts, WithKurtosisKurtosisContext(fakeCtx))
d, err := NewKurtosisDeployer(opts...)
require.NoError(t, err) require.NoError(t, err)
assert.Equal(t, tt.wantBaseDir, d.baseDir) assert.Equal(t, tt.wantBaseDir, d.baseDir)
assert.Equal(t, tt.wantPkg, d.packageName) assert.Equal(t, tt.wantPkg, d.packageName)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment