Skip to content

Commit d551723

Browse files
committed
wip
1 parent c17202f commit d551723

File tree

2 files changed

+53
-40
lines changed

2 files changed

+53
-40
lines changed

tests/e2e/p/warp.go

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,16 @@ import (
1515
"github.com/stretchr/testify/require"
1616

1717
"github.com/ava-labs/avalanchego/config"
18+
"github.com/ava-labs/avalanchego/ids"
19+
"github.com/ava-labs/avalanchego/tests"
1820
"github.com/ava-labs/avalanchego/tests/e2e"
1921
"github.com/ava-labs/avalanchego/tests/fixture/testnet"
2022
"github.com/ava-labs/avalanchego/utils/units"
2123
"github.com/ava-labs/avalanchego/vms/example/xsvm/cmd/issue/export"
2224
"github.com/ava-labs/avalanchego/vms/example/xsvm/cmd/issue/importtx"
2325
"github.com/ava-labs/avalanchego/vms/example/xsvm/cmd/issue/transfer"
2426
"github.com/ava-labs/avalanchego/vms/example/xsvm/genesis"
27+
"github.com/ava-labs/avalanchego/wallet/chain/p"
2528
)
2629

2730
var _ = e2e.DescribePChain("[Warp]", func() {
@@ -52,13 +55,11 @@ var _ = e2e.DescribePChain("[Warp]", func() {
5255
},
5356
})
5457
require.NoError(err)
58+
blockchainSpec := testnet.BlockchainSpec{
59+
VMName: "xsvm",
60+
Genesis: genesisBytes,
61+
}
5562
subnetSpec := testnet.SubnetSpec{
56-
Blockchains: []testnet.BlockchainSpec{
57-
{
58-
VMName: "xsvm",
59-
Genesis: genesisBytes,
60-
},
61-
},
6263
Nodes: []testnet.NodeSpec{
6364
{
6465
Flags: testnet.FlagsMap{
@@ -78,18 +79,19 @@ var _ = e2e.DescribePChain("[Warp]", func() {
7879
pWallet,
7980
privateKey.Address(),
8081
network,
81-
e2e.RegisterNodeforCleanup,
82+
nil, //e2e.RegisterNodeforCleanup,
8283
subnetSpec,
8384
subnetSpec,
8485
)
8586
require.NoError(err)
8687

8788
sourceSubnet := subnets[0]
88-
sourceChainID := sourceSubnet.BlockchainIDs[0]
89+
sourceChainID := createBlockchain(pWallet, sourceSubnet.ID, blockchainSpec)
8990
destinationSubnet := subnets[1]
90-
destinationChainID := destinationSubnet.BlockchainIDs[0]
91+
destinationChainID := createBlockchain(pWallet, destinationSubnet.ID, blockchainSpec)
9192

9293
ginkgo.By(fmt.Sprintf("exporting from blockchain %s on subnet %s", sourceChainID, sourceSubnet.ID))
94+
tests.Outf(" export will be on node %s for URI %s", sourceSubnet.Nodes[0].GetID(), sourceSubnet.Nodes[0].GetProcessContext().URI)
9395
exportTxStatus, err := export.Export(
9496
e2e.DefaultContext(),
9597
&export.Config{
@@ -141,3 +143,21 @@ var _ = e2e.DescribePChain("[Warp]", func() {
141143
// TODO(marun) Verify the balances on both chains
142144
})
143145
})
146+
147+
func createBlockchain(pWallet p.Wallet, subnetID ids.ID, blockchainSpec testnet.BlockchainSpec) ids.ID {
148+
require := require.New(ginkgo.GinkgoT())
149+
150+
ginkgo.By(fmt.Sprintf("creating blockchain on subnet %s\n", subnetID))
151+
vmID, err := testnet.GetVMID(blockchainSpec.VMName)
152+
require.NoError(err)
153+
createChainTx, err := pWallet.IssueCreateChainTx(
154+
subnetID,
155+
blockchainSpec.Genesis,
156+
vmID,
157+
nil,
158+
blockchainSpec.VMName,
159+
e2e.WithDefaultContext(),
160+
)
161+
require.NoError(err)
162+
return createChainTx.ID()
163+
}

tests/fixture/testnet/subnets.go

Lines changed: 24 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
"github.com/ava-labs/avalanchego/config"
1414
"github.com/ava-labs/avalanchego/genesis"
1515
"github.com/ava-labs/avalanchego/ids"
16+
"github.com/ava-labs/avalanchego/tests/fixture/testnet/local"
1617
"github.com/ava-labs/avalanchego/utils/constants"
1718
"github.com/ava-labs/avalanchego/utils/crypto/bls"
1819
"github.com/ava-labs/avalanchego/utils/set"
@@ -62,9 +63,25 @@ type NodeSpec struct {
6263

6364
// Collects the result of subnet creation
6465
type CreatedSubnet struct {
65-
ID ids.ID
66+
ID ids.ID
67+
PrivateKey
6668
BlockchainIDs []ids.ID
67-
Nodes []Node
69+
NodePaths []string
70+
nodes []Node
71+
}
72+
73+
func (s *CreatedSubnet) GetNodes() ([]Nodes, error) {
74+
if s.nodes == nil {
75+
nodes = make([]Node, len(s.NodePaths))
76+
for i, path := range s.NodePaths {
77+
nodes[i], err = local.ReadNode(path)
78+
if err != nil {
79+
return nil, err
80+
}
81+
}
82+
s.nodes = nodes
83+
}
84+
return s.nodes, nil
6885
}
6986

7087
func GetVMID(vmName string) (ids.ID, error) {
@@ -195,31 +212,6 @@ func CreateSubnet(
195212
}
196213
subnetID := subnetTx.ID()
197214

198-
blockchainIDs := make([]ids.ID, len(spec.Blockchains))
199-
for i, blockchainSpec := range spec.Blockchains {
200-
if _, err := fmt.Fprintf(w, "creating blockchain on subnet %s\n", subnetID); err != nil {
201-
return nil, err
202-
}
203-
vmID, err := GetVMID(blockchainSpec.VMName)
204-
if err != nil {
205-
return nil, fmt.Errorf("failed to determine VM ID for blockchain: %w", err)
206-
}
207-
ctx, cancel := context.WithTimeout(rootContext, txTimeout)
208-
defer cancel()
209-
createChainTx, err := pWallet.IssueCreateChainTx(
210-
subnetID,
211-
blockchainSpec.Genesis,
212-
vmID,
213-
nil,
214-
blockchainSpec.VMName,
215-
common.WithContext(ctx),
216-
)
217-
if err != nil {
218-
return nil, fmt.Errorf("failed to create blockchain: %w", err)
219-
}
220-
blockchainIDs[i] = createChainTx.ID()
221-
}
222-
223215
if _, err := fmt.Fprintf(w, "creating nodes for subnet %s\n", subnetID); err != nil {
224216
return nil, err
225217
}
@@ -233,7 +225,9 @@ func CreateSubnet(
233225
if err != nil {
234226
return nil, err
235227
}
236-
nodeCleanupFunc(node)
228+
if nodeCleanupFunc != nil {
229+
nodeCleanupFunc(node)
230+
}
237231
allNodes = append(allNodes, node)
238232
}
239233
}
@@ -315,9 +309,8 @@ func CreateSubnet(
315309
}
316310

317311
return &CreatedSubnet{
318-
ID: subnetID,
319-
BlockchainIDs: blockchainIDs,
320-
Nodes: allNodes,
312+
ID: subnetID,
313+
Nodes: allNodes,
321314
}, nil
322315
}
323316

0 commit comments

Comments
 (0)