-
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.
- Loading branch information
Showing
7 changed files
with
608 additions
and
30 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,6 +25,9 @@ go install -v github.com/onsi/ginkgo/v2/[email protected] | |
ACK_GINKGO_RC=true ginkgo build ./tests/e2e | ||
./tests/e2e/e2e.test --help | ||
|
||
# Enable subnet testing by building xsvm | ||
./scripts/build_xsvm.sh | ||
|
||
################################# | ||
E2E_USE_PERSISTENT_NETWORK="${E2E_USE_PERSISTENT_NETWORK:-}" | ||
TESTNETCTL_NETWORK_DIR="${TESTNETCTL_NETWORK_DIR:-}" | ||
|
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,143 @@ | ||
// Copyright (C) 2019-2023, Ava Labs, Inc. All rights reserved. | ||
// See the file LICENSE for licensing terms. | ||
|
||
package p | ||
|
||
import ( | ||
"errors" | ||
"fmt" | ||
"math" | ||
"os" | ||
"path/filepath" | ||
|
||
ginkgo "github.com/onsi/ginkgo/v2" | ||
|
||
"github.com/stretchr/testify/require" | ||
|
||
"github.com/ava-labs/avalanchego/config" | ||
"github.com/ava-labs/avalanchego/tests/e2e" | ||
"github.com/ava-labs/avalanchego/tests/fixture/testnet" | ||
"github.com/ava-labs/avalanchego/utils/units" | ||
"github.com/ava-labs/avalanchego/vms/example/xsvm/cmd/issue/export" | ||
"github.com/ava-labs/avalanchego/vms/example/xsvm/cmd/issue/importtx" | ||
"github.com/ava-labs/avalanchego/vms/example/xsvm/cmd/issue/transfer" | ||
"github.com/ava-labs/avalanchego/vms/example/xsvm/genesis" | ||
) | ||
|
||
var _ = e2e.DescribePChain("[Warp]", func() { | ||
require := require.New(ginkgo.GinkgoT()) | ||
|
||
ginkgo.It("should support transfers between subnets", func() { | ||
// TODO(marun) make the plugin path configurable | ||
pluginDir := filepath.Join(os.Getenv("GOPATH"), "src/github.com/ava-labs/avalanchego/build/plugins") | ||
if fileInfo, err := os.Stat(pluginDir); errors.Is(err, os.ErrNotExist) || !fileInfo.IsDir() { | ||
ginkgo.Skip(fmt.Sprintf("invalid plugin dir %s", pluginDir)) | ||
} | ||
|
||
ginkgo.By("creating wallet with a funded key to create subnets with") | ||
nodeURI := e2e.Env.GetRandomNodeURI() | ||
keychain := e2e.Env.NewKeychain(1) | ||
privateKey := keychain.Keys[0] | ||
baseWallet := e2e.Env.NewWallet(keychain, nodeURI) | ||
pWallet := baseWallet.P() | ||
|
||
ginkgo.By("Defining the configuration for an xsvm subnet") | ||
genesisBytes, err := genesis.Codec.Marshal(genesis.Version, &genesis.Genesis{ | ||
Timestamp: 0, | ||
Allocations: []genesis.Allocation{ | ||
{ | ||
Address: privateKey.Address(), | ||
Balance: math.MaxUint64, | ||
}, | ||
}, | ||
}) | ||
require.NoError(err) | ||
subnetSpec := testnet.SubnetSpec{ | ||
Blockchains: []testnet.BlockchainSpec{ | ||
{ | ||
VMName: "xsvm", | ||
Genesis: genesisBytes, | ||
}, | ||
}, | ||
Nodes: []testnet.NodeSpec{ | ||
{ | ||
Flags: testnet.FlagsMap{ | ||
config.PluginDirKey: pluginDir, | ||
}, | ||
Count: testnet.DefaultNodeCount, | ||
}, | ||
}, | ||
} | ||
|
||
// TODO(marun) Simplify this call for e2e | ||
ginkgo.By("creating 2 xsvm subnets") | ||
network := e2e.Env.GetNetwork() | ||
subnets, err := testnet.CreateSubnets( | ||
ginkgo.GinkgoWriter, | ||
e2e.DefaultTimeout, | ||
pWallet, | ||
privateKey.Address(), | ||
network, | ||
e2e.RegisterNodeforCleanup, | ||
subnetSpec, | ||
subnetSpec, | ||
) | ||
require.NoError(err) | ||
|
||
sourceSubnet := subnets[0] | ||
sourceChainID := sourceSubnet.BlockchainIDs[0] | ||
destinationSubnet := subnets[1] | ||
destinationChainID := destinationSubnet.BlockchainIDs[0] | ||
|
||
ginkgo.By(fmt.Sprintf("exporting from blockchain %s on subnet %s", sourceChainID, sourceSubnet.ID)) | ||
exportTxStatus, err := export.Export( | ||
e2e.DefaultContext(), | ||
&export.Config{ | ||
URI: sourceSubnet.Nodes[0].GetProcessContext().URI, | ||
SourceChainID: sourceChainID, | ||
DestinationChainID: destinationChainID, | ||
Amount: units.Schmeckle, | ||
To: privateKey.Address(), | ||
PrivateKey: privateKey, | ||
}, | ||
) | ||
require.NoError(err) | ||
|
||
ginkgo.By(fmt.Sprintf("issuing transactions on chain %s on subnet %s to activate snowman++ consensus", | ||
destinationChainID, destinationSubnet.ID)) | ||
for i := 0; i < 3; i++ { | ||
_, err = transfer.Transfer( | ||
e2e.DefaultContext(), | ||
&transfer.Config{ | ||
URI: destinationSubnet.Nodes[0].GetProcessContext().URI, | ||
ChainID: destinationChainID, | ||
AssetID: destinationChainID, | ||
Amount: units.Schmeckle, | ||
To: privateKey.Address(), | ||
PrivateKey: privateKey, | ||
}, | ||
) | ||
require.NoError(err) | ||
} | ||
|
||
ginkgo.By(fmt.Sprintf("importing to blockchain %s on subnet %s", sourceChainID, sourceSubnet.ID)) | ||
sourceURIs := make([]string, len(sourceSubnet.Nodes)) | ||
for i, node := range sourceSubnet.Nodes { | ||
sourceURIs[i] = node.GetProcessContext().URI | ||
} | ||
_, err = importtx.Import( | ||
e2e.DefaultContext(), | ||
&importtx.Config{ | ||
URI: destinationSubnet.Nodes[0].GetProcessContext().URI, | ||
SourceURIs: sourceURIs, | ||
SourceChainID: sourceChainID.String(), | ||
DestinationChainID: destinationChainID.String(), | ||
TxID: exportTxStatus.TxID, | ||
PrivateKey: privateKey, | ||
}, | ||
) | ||
require.NoError(err) | ||
|
||
// TODO(marun) Verify the balances on both chains | ||
}) | ||
}) |
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.