Skip to content

e2e: Remove unnecessary transaction status checking #1786

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 5 additions & 38 deletions tests/e2e/p/permissionless_subnets.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,8 @@ import (
"github.com/ava-labs/avalanchego/vms/avm"
"github.com/ava-labs/avalanchego/vms/components/avax"
"github.com/ava-labs/avalanchego/vms/components/verify"
"github.com/ava-labs/avalanchego/vms/platformvm"
"github.com/ava-labs/avalanchego/vms/platformvm/reward"
"github.com/ava-labs/avalanchego/vms/platformvm/signer"
"github.com/ava-labs/avalanchego/vms/platformvm/status"
"github.com/ava-labs/avalanchego/vms/platformvm/txs"
"github.com/ava-labs/avalanchego/vms/secp256k1fx"
"github.com/ava-labs/avalanchego/wallet/subnet/primary"
Expand Down Expand Up @@ -65,7 +63,6 @@ var _ = e2e.DescribePChain("[Permissionless Subnets]", func() {
})

pWallet := baseWallet.P()
pChainClient := platformvm.NewClient(nodeURI)
xWallet := baseWallet.X()
xChainClient := avm.NewClient(nodeURI, xWallet.BlockchainID().String())
xChainID := xWallet.BlockchainID()
Expand All @@ -88,11 +85,6 @@ var _ = e2e.DescribePChain("[Permissionless Subnets]", func() {

subnetID = subnetTx.ID()
gomega.Expect(subnetID, err).Should(gomega.Not(gomega.Equal(constants.PrimaryNetworkID)))

ctx, cancel = context.WithTimeout(context.Background(), e2e.DefaultConfirmTxTimeout)
txStatus, err := pChainClient.GetTxStatus(ctx, subnetID)
cancel()
gomega.Expect(txStatus.Status, err).To(gomega.Equal(status.Committed))
})

var subnetAssetID ids.ID
Expand Down Expand Up @@ -124,7 +116,7 @@ var _ = e2e.DescribePChain("[Permissionless Subnets]", func() {

ginkgo.By(fmt.Sprintf("Send 100 MegaAvax of asset %s to the P-chain", subnetAssetID), func() {
ctx, cancel := context.WithTimeout(context.Background(), e2e.DefaultWalletCreationTimeout)
exportTx, err := xWallet.IssueExportTx(
_, err := xWallet.IssueExportTx(
constants.PlatformChainID,
[]*avax.TransferableOutput{
{
Expand All @@ -141,32 +133,22 @@ var _ = e2e.DescribePChain("[Permissionless Subnets]", func() {
)
cancel()
gomega.Expect(err).Should(gomega.BeNil())

ctx, cancel = context.WithTimeout(context.Background(), e2e.DefaultConfirmTxTimeout)
txStatus, err := xChainClient.GetTxStatus(ctx, exportTx.ID())
cancel()
gomega.Expect(txStatus, err).To(gomega.Equal(choices.Accepted))
})

ginkgo.By(fmt.Sprintf("Import the 100 MegaAvax of asset %s from the X-chain into the P-chain", subnetAssetID), func() {
ctx, cancel := context.WithTimeout(context.Background(), e2e.DefaultWalletCreationTimeout)
importTx, err := pWallet.IssueImportTx(
_, err := pWallet.IssueImportTx(
xChainID,
owner,
common.WithContext(ctx),
)
cancel()
gomega.Expect(err).Should(gomega.BeNil())

ctx, cancel = context.WithTimeout(context.Background(), e2e.DefaultConfirmTxTimeout)
txStatus, err := pChainClient.GetTxStatus(ctx, importTx.ID())
cancel()
gomega.Expect(txStatus.Status, err).To(gomega.Equal(status.Committed))
})

ginkgo.By("make subnet permissionless", func() {
ctx, cancel := context.WithTimeout(context.Background(), e2e.DefaultConfirmTxTimeout)
transformSubnetTx, err := pWallet.IssueTransformSubnetTx(
_, err := pWallet.IssueTransformSubnetTx(
subnetID,
subnetAssetID,
50*units.MegaAvax,
Expand All @@ -185,17 +167,12 @@ var _ = e2e.DescribePChain("[Permissionless Subnets]", func() {
)
cancel()
gomega.Expect(err).Should(gomega.BeNil())

ctx, cancel = context.WithTimeout(context.Background(), e2e.DefaultConfirmTxTimeout)
txStatus, err := pChainClient.GetTxStatus(ctx, transformSubnetTx.ID())
cancel()
gomega.Expect(txStatus.Status, err).To(gomega.Equal(status.Committed))
})

validatorStartTime := time.Now().Add(time.Minute)
ginkgo.By("add permissionless validator", func() {
ctx, cancel := context.WithTimeout(context.Background(), e2e.DefaultConfirmTxTimeout)
addSubnetValidatorTx, err := pWallet.IssueAddPermissionlessValidatorTx(
_, err := pWallet.IssueAddPermissionlessValidatorTx(
&txs.SubnetValidator{
Validator: txs.Validator{
NodeID: genesis.LocalConfig.InitialStakers[0].NodeID,
Expand All @@ -214,17 +191,12 @@ var _ = e2e.DescribePChain("[Permissionless Subnets]", func() {
)
cancel()
gomega.Expect(err).Should(gomega.BeNil())

ctx, cancel = context.WithTimeout(context.Background(), e2e.DefaultConfirmTxTimeout)
txStatus, err := pChainClient.GetTxStatus(ctx, addSubnetValidatorTx.ID())
cancel()
gomega.Expect(txStatus.Status, err).To(gomega.Equal(status.Committed))
})

delegatorStartTime := validatorStartTime
ginkgo.By("add permissionless delegator", func() {
ctx, cancel := context.WithTimeout(context.Background(), e2e.DefaultConfirmTxTimeout)
addSubnetDelegatorTx, err := pWallet.IssueAddPermissionlessDelegatorTx(
_, err := pWallet.IssueAddPermissionlessDelegatorTx(
&txs.SubnetValidator{
Validator: txs.Validator{
NodeID: genesis.LocalConfig.InitialStakers[0].NodeID,
Expand All @@ -240,11 +212,6 @@ var _ = e2e.DescribePChain("[Permissionless Subnets]", func() {
)
cancel()
gomega.Expect(err).Should(gomega.BeNil())

ctx, cancel = context.WithTimeout(context.Background(), e2e.DefaultConfirmTxTimeout)
txStatus, err := pChainClient.GetTxStatus(ctx, addSubnetDelegatorTx.ID())
cancel()
gomega.Expect(txStatus.Status, err).To(gomega.Equal(status.Committed))
})
})
})
32 changes: 4 additions & 28 deletions tests/e2e/p/workflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,12 @@ import (

"github.com/ava-labs/avalanchego/api/info"
"github.com/ava-labs/avalanchego/ids"
"github.com/ava-labs/avalanchego/snow/choices"
"github.com/ava-labs/avalanchego/tests"
"github.com/ava-labs/avalanchego/tests/e2e"
"github.com/ava-labs/avalanchego/utils/constants"
"github.com/ava-labs/avalanchego/utils/units"
"github.com/ava-labs/avalanchego/vms/avm"
"github.com/ava-labs/avalanchego/vms/components/avax"
"github.com/ava-labs/avalanchego/vms/platformvm"
"github.com/ava-labs/avalanchego/vms/platformvm/status"
"github.com/ava-labs/avalanchego/vms/platformvm/txs"
"github.com/ava-labs/avalanchego/vms/secp256k1fx"
"github.com/ava-labs/avalanchego/wallet/subnet/primary"
Expand Down Expand Up @@ -63,7 +60,6 @@ var _ = e2e.DescribePChain("[Workflow]", func() {
avaxAssetID := baseWallet.P().AVAXAssetID()
xWallet := baseWallet.X()
pChainClient := platformvm.NewClient(nodeURI)
xChainClient := avm.NewClient(nodeURI, xWallet.BlockchainID().String())

tests.Outf("{{blue}} fetching minimal stake amounts {{/}}\n")
ctx, cancel = context.WithTimeout(context.Background(), e2e.DefaultWalletCreationTimeout)
Expand Down Expand Up @@ -111,35 +107,25 @@ var _ = e2e.DescribePChain("[Workflow]", func() {

ginkgo.By("issue add validator tx", func() {
ctx, cancel := context.WithTimeout(context.Background(), e2e.DefaultConfirmTxTimeout)
addValidatorTx, err := pWallet.IssueAddValidatorTx(
_, err := pWallet.IssueAddValidatorTx(
vdr,
rewardOwner,
shares,
common.WithContext(ctx),
)
cancel()
gomega.Expect(err).Should(gomega.BeNil())

ctx, cancel = context.WithTimeout(context.Background(), e2e.DefaultConfirmTxTimeout)
txStatus, err := pChainClient.GetTxStatus(ctx, addValidatorTx.ID())
cancel()
gomega.Expect(txStatus.Status, err).To(gomega.Equal(status.Committed))
})

ginkgo.By("issue add delegator tx", func() {
ctx, cancel := context.WithTimeout(context.Background(), e2e.DefaultConfirmTxTimeout)
addDelegatorTx, err := pWallet.IssueAddDelegatorTx(
_, err := pWallet.IssueAddDelegatorTx(
vdr,
rewardOwner,
common.WithContext(ctx),
)
cancel()
gomega.Expect(err).Should(gomega.BeNil())

ctx, cancel = context.WithTimeout(context.Background(), e2e.DefaultConfirmTxTimeout)
txStatus, err := pChainClient.GetTxStatus(ctx, addDelegatorTx.ID())
cancel()
gomega.Expect(txStatus.Status, err).To(gomega.Equal(status.Committed))
})

// retrieve initial balances
Expand All @@ -166,7 +152,7 @@ var _ = e2e.DescribePChain("[Workflow]", func() {

ginkgo.By("export avax from P to X chain", func() {
ctx, cancel := context.WithTimeout(context.Background(), e2e.DefaultConfirmTxTimeout)
exportTx, err := pWallet.IssueExportTx(
_, err := pWallet.IssueExportTx(
xWallet.BlockchainID(),
[]*avax.TransferableOutput{
{
Expand All @@ -180,11 +166,6 @@ var _ = e2e.DescribePChain("[Workflow]", func() {
)
cancel()
gomega.Expect(err).Should(gomega.BeNil())

ctx, cancel = context.WithTimeout(context.Background(), e2e.DefaultConfirmTxTimeout)
txStatus, err := pChainClient.GetTxStatus(ctx, exportTx.ID())
cancel()
gomega.Expect(txStatus.Status, err).To(gomega.Equal(status.Committed))
})

// check balances post export
Expand All @@ -203,18 +184,13 @@ var _ = e2e.DescribePChain("[Workflow]", func() {

ginkgo.By("import avax from P into X chain", func() {
ctx, cancel := context.WithTimeout(context.Background(), e2e.DefaultConfirmTxTimeout)
importTx, err := xWallet.IssueImportTx(
_, err := xWallet.IssueImportTx(
constants.PlatformChainID,
&outputOwner,
common.WithContext(ctx),
)
cancel()
gomega.Expect(err).Should(gomega.BeNil(), "is context.DeadlineExceeded: %v", errors.Is(err, context.DeadlineExceeded))

ctx, cancel = context.WithTimeout(context.Background(), e2e.DefaultConfirmTxTimeout)
txStatus, err := xChainClient.GetTxStatus(ctx, importTx.ID())
cancel()
gomega.Expect(txStatus, err).To(gomega.Equal(choices.Accepted))
})

// check balances post import
Expand Down