-
Notifications
You must be signed in to change notification settings - Fork 675
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[antithesis] Enable reuse of banff e2e test for antithesis testing
- Loading branch information
Showing
9 changed files
with
382 additions
and
158 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved. | ||
// See the file LICENSE for licensing terms. | ||
|
||
package antithesis | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"maps" | ||
|
||
"github.com/antithesishq/antithesis-sdk-go/assert" | ||
|
||
"github.com/ava-labs/avalanchego/tests" | ||
"github.com/ava-labs/avalanchego/utils/logging" | ||
) | ||
|
||
// NewInstrumentedTestContext returns a test context that makes antithesis SDK assertions. | ||
func NewInstrumentedTestContext(log logging.Logger) *tests.SimpleTestContext { | ||
return NewInstrumentedTestContextWithArgs(context.Background(), log, nil) | ||
} | ||
|
||
// NewInstrumentedTestContextWithArgs returns a test context that makes antithesis SDK assertions. | ||
func NewInstrumentedTestContextWithArgs( | ||
ctx context.Context, | ||
log logging.Logger, | ||
details map[string]any, | ||
) *tests.SimpleTestContext { | ||
return tests.NewTestContextWithArgs( | ||
ctx, | ||
log, | ||
func(format string, args ...any) { | ||
assert.Unreachable(fmt.Sprintf("Assertion failure: "+format, args...), details) | ||
}, | ||
func(r any) { | ||
detailsClone := maps.Clone(details) | ||
details["panic"] = r | ||
assert.Unreachable("unexpected panic", detailsClone) | ||
}, | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.