-
Notifications
You must be signed in to change notification settings - Fork 681
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: marun <[email protected]>
- Loading branch information
1 parent
cb59182
commit b51d94b
Showing
2 changed files
with
146 additions
and
102 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 |
---|---|---|
@@ -0,0 +1,146 @@ | ||
// Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved. | ||
// See the file LICENSE for licensing terms. | ||
|
||
package p | ||
|
||
import ( | ||
"math" | ||
"time" | ||
|
||
"github.com/onsi/ginkgo/v2" | ||
"github.com/stretchr/testify/require" | ||
|
||
"github.com/ava-labs/avalanchego/api/info" | ||
"github.com/ava-labs/avalanchego/ids" | ||
"github.com/ava-labs/avalanchego/tests/fixture/e2e" | ||
"github.com/ava-labs/avalanchego/utils/constants" | ||
"github.com/ava-labs/avalanchego/utils/crypto/secp256k1" | ||
"github.com/ava-labs/avalanchego/vms/example/xsvm/genesis" | ||
"github.com/ava-labs/avalanchego/vms/platformvm" | ||
"github.com/ava-labs/avalanchego/vms/secp256k1fx" | ||
) | ||
|
||
var _ = e2e.DescribePChain("[L1]", func() { | ||
tc := e2e.NewTestContext() | ||
require := require.New(tc) | ||
|
||
ginkgo.It("creates and updates L1 validators", func() { | ||
env := e2e.GetEnv(tc) | ||
nodeURI := env.GetRandomNodeURI() | ||
|
||
tc.By("verifying Etna is activated", func() { | ||
infoClient := info.NewClient(nodeURI.URI) | ||
upgrades, err := infoClient.Upgrades(tc.DefaultContext()) | ||
require.NoError(err) | ||
|
||
now := time.Now() | ||
if !upgrades.IsEtnaActivated(now) { | ||
ginkgo.Skip("Etna is not activated. L1s are enabled post-Etna, skipping test.") | ||
} | ||
}) | ||
|
||
tc.By("loading the wallet") | ||
var ( | ||
keychain = env.NewKeychain() | ||
baseWallet = e2e.NewWallet(tc, keychain, nodeURI) | ||
pWallet = baseWallet.P() | ||
pClient = platformvm.NewClient(nodeURI.URI) | ||
owner = &secp256k1fx.OutputOwners{ | ||
Threshold: 1, | ||
Addrs: []ids.ShortID{ | ||
keychain.Keys[0].Address(), | ||
}, | ||
} | ||
) | ||
|
||
tc.By("creating the chain genesis") | ||
genesisKey, err := secp256k1.NewPrivateKey() | ||
require.NoError(err) | ||
|
||
genesisBytes, err := genesis.Codec.Marshal(genesis.CodecVersion, &genesis.Genesis{ | ||
Timestamp: time.Now().Unix(), | ||
Allocations: []genesis.Allocation{ | ||
{ | ||
Address: genesisKey.Address(), | ||
Balance: math.MaxUint64, | ||
}, | ||
}, | ||
}) | ||
require.NoError(err) | ||
|
||
var subnetID ids.ID | ||
tc.By("issuing a CreateSubnetTx", func() { | ||
subnetTx, err := pWallet.IssueCreateSubnetTx( | ||
owner, | ||
tc.WithDefaultContext(), | ||
) | ||
require.NoError(err) | ||
|
||
subnetID = subnetTx.ID() | ||
}) | ||
|
||
tc.By("verifying a Permissioned Subnet was successfully created", func() { | ||
require.NotEqual(constants.PrimaryNetworkID, subnetID) | ||
|
||
subnet, err := pClient.GetSubnet(tc.DefaultContext(), subnetID) | ||
require.NoError(err) | ||
require.Equal( | ||
platformvm.GetSubnetClientResponse{ | ||
IsPermissioned: true, | ||
ControlKeys: []ids.ShortID{ | ||
keychain.Keys[0].Address(), | ||
}, | ||
Threshold: 1, | ||
}, | ||
subnet, | ||
) | ||
}) | ||
|
||
var chainID ids.ID | ||
tc.By("issuing a CreateChainTx", func() { | ||
chainTx, err := pWallet.IssueCreateChainTx( | ||
subnetID, | ||
genesisBytes, | ||
constants.XSVMID, | ||
nil, | ||
"No Permissions", | ||
tc.WithDefaultContext(), | ||
) | ||
require.NoError(err) | ||
|
||
chainID = chainTx.ID() | ||
}) | ||
|
||
address := []byte{} | ||
tc.By("issuing a ConvertSubnetTx", func() { | ||
_, err := pWallet.IssueConvertSubnetTx( | ||
subnetID, | ||
chainID, | ||
address, | ||
tc.WithDefaultContext(), | ||
) | ||
require.NoError(err) | ||
}) | ||
|
||
tc.By("verifying the Permissioned Subnet was converted to an L1", func() { | ||
tc.By("verifying the subnet reports as being converted", func() { | ||
subnet, err := pClient.GetSubnet(tc.DefaultContext(), subnetID) | ||
require.NoError(err) | ||
require.Equal( | ||
platformvm.GetSubnetClientResponse{ | ||
IsPermissioned: false, | ||
ControlKeys: []ids.ShortID{ | ||
keychain.Keys[0].Address(), | ||
}, | ||
Threshold: 1, | ||
ManagerChainID: chainID, | ||
ManagerAddress: address, | ||
}, | ||
subnet, | ||
) | ||
}) | ||
}) | ||
|
||
_ = e2e.CheckBootstrapIsPossible(tc, env.GetNetwork()) | ||
}) | ||
}) |
This file was deleted.
Oops, something went wrong.