-
Notifications
You must be signed in to change notification settings - Fork 115
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
support procedural test style for VM-defined workloads (#1667)
Signed-off-by: Tsachi Herman <[email protected]>
- Loading branch information
1 parent
dbcc6c9
commit b2ad4d3
Showing
12 changed files
with
601 additions
and
77 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
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,49 @@ | ||
// Copyright (C) 2024, Ava Labs, Inc. All rights reserved. | ||
// See the file LICENSE for licensing terms. | ||
|
||
package tests | ||
|
||
import ( | ||
"context" | ||
"time" | ||
|
||
"github.com/stretchr/testify/require" | ||
|
||
"github.com/ava-labs/hypersdk/auth" | ||
"github.com/ava-labs/hypersdk/chain" | ||
"github.com/ava-labs/hypersdk/crypto/ed25519" | ||
"github.com/ava-labs/hypersdk/examples/morpheusvm/actions" | ||
"github.com/ava-labs/hypersdk/examples/morpheusvm/tests/workload" | ||
"github.com/ava-labs/hypersdk/tests/registry" | ||
|
||
tworkload "github.com/ava-labs/hypersdk/tests/workload" | ||
ginkgo "github.com/onsi/ginkgo/v2" | ||
) | ||
|
||
// TestsRegistry initialized during init to ensure tests are identical during ginkgo | ||
// suite construction and test execution | ||
// ref https://onsi.github.io/ginkgo/#mental-model-how-ginkgo-traverses-the-spec-hierarchy | ||
var TestsRegistry = ®istry.Registry{} | ||
|
||
var _ = registry.Register(TestsRegistry, "Transfer Transaction", func(t ginkgo.FullGinkgoTInterface, tn tworkload.TestNetwork) { | ||
require := require.New(t) | ||
other, err := ed25519.GeneratePrivateKey() | ||
require.NoError(err) | ||
toAddress := auth.NewED25519Address(other.PublicKey()) | ||
|
||
networkConfig := tn.Configuration().(*workload.NetworkConfiguration) | ||
spendingKey := networkConfig.Keys()[0] | ||
|
||
tx, err := tn.GenerateTx(context.Background(), []chain.Action{&actions.Transfer{ | ||
To: toAddress, | ||
Value: 1, | ||
}}, | ||
auth.NewED25519Factory(spendingKey), | ||
) | ||
require.NoError(err) | ||
|
||
timeoutCtx, timeoutCtxFnc := context.WithDeadline(context.Background(), time.Now().Add(2*time.Second)) | ||
defer timeoutCtxFnc() | ||
|
||
require.NoError(tn.ConfirmTxs(timeoutCtx, []*chain.Transaction{tx})) | ||
}) |
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.