From 47997cf3b0b3cb09b42c2d8b55f0e48c516955fd Mon Sep 17 00:00:00 2001 From: Maru Newby Date: Tue, 5 Sep 2023 16:40:00 -0700 Subject: [PATCH] e2e: Switch assertion library from gomega to testify --- tests/e2e/banff/suites.go | 14 ++++--- tests/e2e/p/permissionless_subnets.go | 22 ++++++----- tests/e2e/p/workflow.go | 42 +++++++++++---------- tests/e2e/static-handlers/suites.go | 29 ++++++++------- tests/e2e/x/transfer/virtuous.go | 53 ++++++++++++++------------- 5 files changed, 85 insertions(+), 75 deletions(-) diff --git a/tests/e2e/banff/suites.go b/tests/e2e/banff/suites.go index a19d3c1eb511..c8e9796a3665 100644 --- a/tests/e2e/banff/suites.go +++ b/tests/e2e/banff/suites.go @@ -7,7 +7,7 @@ package banff import ( ginkgo "github.com/onsi/ginkgo/v2" - "github.com/onsi/gomega" + "github.com/stretchr/testify/require" "github.com/ava-labs/avalanchego/ids" "github.com/ava-labs/avalanchego/tests" @@ -20,6 +20,8 @@ import ( ) var _ = ginkgo.Describe("[Banff]", func() { + require := require.New(ginkgo.GinkgoT()) + ginkgo.It("can send custom assets X->P and P->X", // use this for filtering tests by labels // ref. https://onsi.github.io/ginkgo/#spec-labels @@ -59,7 +61,7 @@ var _ = ginkgo.Describe("[Banff]", func() { }, }, ) - gomega.Expect(err).Should(gomega.BeNil()) + require.NoError(err) assetID = assetTx.ID() tests.Outf("{{green}}created new X-chain asset{{/}}: %s\n", assetID) @@ -80,14 +82,14 @@ var _ = ginkgo.Describe("[Banff]", func() { }, }, ) - gomega.Expect(err).Should(gomega.BeNil()) + require.NoError(err) tests.Outf("{{green}}issued X-chain export{{/}}: %s\n", tx.ID()) }) ginkgo.By("import new asset from X-chain on the P-chain", func() { tx, err := pWallet.IssueImportTx(xChainID, owner) - gomega.Expect(err).Should(gomega.BeNil()) + require.NoError(err) tests.Outf("{{green}}issued P-chain import{{/}}: %s\n", tx.ID()) }) @@ -107,14 +109,14 @@ var _ = ginkgo.Describe("[Banff]", func() { }, }, ) - gomega.Expect(err).Should(gomega.BeNil()) + require.NoError(err) tests.Outf("{{green}}issued P-chain export{{/}}: %s\n", tx.ID()) }) ginkgo.By("import asset from P-chain on the X-chain", func() { tx, err := xWallet.IssueImportTx(constants.PlatformChainID, owner) - gomega.Expect(err).Should(gomega.BeNil()) + require.NoError(err) tests.Outf("{{green}}issued X-chain import{{/}}: %s\n", tx.ID()) }) diff --git a/tests/e2e/p/permissionless_subnets.go b/tests/e2e/p/permissionless_subnets.go index 3074d1a55ac6..e28b8f09ed1b 100644 --- a/tests/e2e/p/permissionless_subnets.go +++ b/tests/e2e/p/permissionless_subnets.go @@ -10,7 +10,7 @@ import ( ginkgo "github.com/onsi/ginkgo/v2" - "github.com/onsi/gomega" + "github.com/stretchr/testify/require" "github.com/ava-labs/avalanchego/ids" "github.com/ava-labs/avalanchego/tests/e2e" @@ -27,6 +27,8 @@ import ( ) var _ = e2e.DescribePChain("[Permissionless Subnets]", func() { + require := require.New(ginkgo.GinkgoT()) + ginkgo.It("subnets operations", // use this for filtering tests by labels // ref. https://onsi.github.io/ginkgo/#spec-labels @@ -49,8 +51,7 @@ var _ = e2e.DescribePChain("[Permissionless Subnets]", func() { ctx, cancel := context.WithTimeout(context.Background(), e2e.DefaultTimeout) validatorIDs, err := pChainClient.SampleValidators(ctx, constants.PrimaryNetworkID, 1) cancel() - gomega.Expect(err).Should(gomega.BeNil()) - gomega.Expect(validatorIDs).Should(gomega.HaveLen(1)) + require.NoError(err) validatorID = validatorIDs[0] }) @@ -71,7 +72,8 @@ var _ = e2e.DescribePChain("[Permissionless Subnets]", func() { cancel() subnetID = subnetTx.ID() - gomega.Expect(subnetID, err).Should(gomega.Not(gomega.Equal(constants.PrimaryNetworkID))) + require.NoError(err) + require.NotEqual(subnetID, constants.PrimaryNetworkID) }) var subnetAssetID ids.ID @@ -92,7 +94,7 @@ var _ = e2e.DescribePChain("[Permissionless Subnets]", func() { common.WithContext(ctx), ) cancel() - gomega.Expect(err).Should(gomega.BeNil()) + require.NoError(err) subnetAssetID = subnetAssetTx.ID() }) @@ -114,7 +116,7 @@ var _ = e2e.DescribePChain("[Permissionless Subnets]", func() { common.WithContext(ctx), ) cancel() - gomega.Expect(err).Should(gomega.BeNil()) + require.NoError(err) }) ginkgo.By(fmt.Sprintf("Import the 100 MegaAvax of asset %s from the X-chain into the P-chain", subnetAssetID), func() { @@ -125,7 +127,7 @@ var _ = e2e.DescribePChain("[Permissionless Subnets]", func() { common.WithContext(ctx), ) cancel() - gomega.Expect(err).Should(gomega.BeNil()) + require.NoError(err) }) ginkgo.By("make subnet permissionless", func() { @@ -148,7 +150,7 @@ var _ = e2e.DescribePChain("[Permissionless Subnets]", func() { common.WithContext(ctx), ) cancel() - gomega.Expect(err).Should(gomega.BeNil()) + require.NoError(err) }) validatorStartTime := time.Now().Add(time.Minute) @@ -172,7 +174,7 @@ var _ = e2e.DescribePChain("[Permissionless Subnets]", func() { common.WithContext(ctx), ) cancel() - gomega.Expect(err).Should(gomega.BeNil()) + require.NoError(err) }) delegatorStartTime := validatorStartTime @@ -193,7 +195,7 @@ var _ = e2e.DescribePChain("[Permissionless Subnets]", func() { common.WithContext(ctx), ) cancel() - gomega.Expect(err).Should(gomega.BeNil()) + require.NoError(err) }) }) }) diff --git a/tests/e2e/p/workflow.go b/tests/e2e/p/workflow.go index 422428dfe5ec..004f4c7df3bf 100644 --- a/tests/e2e/p/workflow.go +++ b/tests/e2e/p/workflow.go @@ -5,12 +5,11 @@ package p import ( "context" - "errors" "time" ginkgo "github.com/onsi/ginkgo/v2" - "github.com/onsi/gomega" + "github.com/stretchr/testify/require" "github.com/ava-labs/avalanchego/api/info" "github.com/ava-labs/avalanchego/ids" @@ -33,6 +32,8 @@ import ( // - Checks the expected value of the funding address var _ = e2e.DescribePChain("[Workflow]", func() { + require := require.New(ginkgo.GinkgoT()) + ginkgo.It("P-chain main operations", // use this for filtering tests by labels // ref. https://onsi.github.io/ginkgo/#spec-labels @@ -55,7 +56,7 @@ var _ = e2e.DescribePChain("[Workflow]", func() { ctx, cancel := context.WithTimeout(context.Background(), e2e.DefaultWalletCreationTimeout) minValStake, minDelStake, err := pChainClient.GetMinStake(ctx, constants.PlatformChainID) cancel() - gomega.Expect(err).Should(gomega.BeNil()) + require.NoError(err) tests.Outf("{{green}} minimal validator stake: %d {{/}}\n", minValStake) tests.Outf("{{green}} minimal delegator stake: %d {{/}}\n", minDelStake) @@ -64,7 +65,7 @@ var _ = e2e.DescribePChain("[Workflow]", func() { ctx, cancel = context.WithTimeout(context.Background(), e2e.DefaultWalletCreationTimeout) fees, err := infoClient.GetTxFee(ctx) cancel() - gomega.Expect(err).Should(gomega.BeNil()) + require.NoError(err) txFees := uint64(fees.TxFee) tests.Outf("{{green}} txFee: %d {{/}}\n", txFees) @@ -77,7 +78,8 @@ var _ = e2e.DescribePChain("[Workflow]", func() { pBalances, err := pWallet.Builder().GetBalance() pBalance := pBalances[avaxAssetID] minBalance := minValStake + txFees + minDelStake + txFees + toTransfer + txFees - gomega.Expect(pBalance, err).To(gomega.BeNumerically(">=", minBalance)) + require.NoError(err) + require.GreaterOrEqual(pBalance, minBalance) }) // create validator data validatorStartTimeDiff := 30 * time.Second @@ -86,7 +88,7 @@ var _ = e2e.DescribePChain("[Workflow]", func() { // Use a random node ID to ensure that repeated test runs // will succeed against a persistent network. validatorID, err := ids.ToNodeID(utils.RandomBytes(ids.NodeIDLen)) - gomega.Expect(err).Should(gomega.BeNil()) + require.NoError(err) vdr := &txs.Validator{ NodeID: validatorID, @@ -109,7 +111,7 @@ var _ = e2e.DescribePChain("[Workflow]", func() { common.WithContext(ctx), ) cancel() - gomega.Expect(err).Should(gomega.BeNil()) + require.NoError(err) }) ginkgo.By("issue add delegator tx", func() { @@ -120,17 +122,17 @@ var _ = e2e.DescribePChain("[Workflow]", func() { common.WithContext(ctx), ) cancel() - gomega.Expect(err).Should(gomega.BeNil()) + require.NoError(err) }) // retrieve initial balances pBalances, err := pWallet.Builder().GetBalance() - gomega.Expect(err).Should(gomega.BeNil()) + require.NoError(err) pStartBalance := pBalances[avaxAssetID] tests.Outf("{{blue}} P-chain balance before P->X export: %d {{/}}\n", pStartBalance) xBalances, err := xWallet.Builder().GetFTBalance() - gomega.Expect(err).Should(gomega.BeNil()) + require.NoError(err) xStartBalance := xBalances[avaxAssetID] tests.Outf("{{blue}} X-chain balance before P->X export: %d {{/}}\n", xStartBalance) @@ -160,22 +162,22 @@ var _ = e2e.DescribePChain("[Workflow]", func() { common.WithContext(ctx), ) cancel() - gomega.Expect(err).Should(gomega.BeNil()) + require.NoError(err) }) // check balances post export pBalances, err = pWallet.Builder().GetBalance() - gomega.Expect(err).Should(gomega.BeNil()) + require.NoError(err) pPreImportBalance := pBalances[avaxAssetID] tests.Outf("{{blue}} P-chain balance after P->X export: %d {{/}}\n", pPreImportBalance) xBalances, err = xWallet.Builder().GetFTBalance() - gomega.Expect(err).Should(gomega.BeNil()) + require.NoError(err) xPreImportBalance := xBalances[avaxAssetID] tests.Outf("{{blue}} X-chain balance after P->X export: %d {{/}}\n", xPreImportBalance) - gomega.Expect(xPreImportBalance).To(gomega.Equal(xStartBalance)) // import not performed yet - gomega.Expect(pPreImportBalance).To(gomega.Equal(pStartBalance - toTransfer - txFees)) + require.Equal(xPreImportBalance, xStartBalance) // import not performed yet + require.Equal(pPreImportBalance, pStartBalance-toTransfer-txFees) ginkgo.By("import avax from P into X chain", func() { ctx, cancel := context.WithTimeout(context.Background(), e2e.DefaultConfirmTxTimeout) @@ -185,21 +187,21 @@ var _ = e2e.DescribePChain("[Workflow]", func() { common.WithContext(ctx), ) cancel() - gomega.Expect(err).Should(gomega.BeNil(), "is context.DeadlineExceeded: %v", errors.Is(err, context.DeadlineExceeded)) + require.NoError(err) }) // check balances post import pBalances, err = pWallet.Builder().GetBalance() - gomega.Expect(err).Should(gomega.BeNil()) + require.NoError(err) pFinalBalance := pBalances[avaxAssetID] tests.Outf("{{blue}} P-chain balance after P->X import: %d {{/}}\n", pFinalBalance) xBalances, err = xWallet.Builder().GetFTBalance() - gomega.Expect(err).Should(gomega.BeNil()) + require.NoError(err) xFinalBalance := xBalances[avaxAssetID] tests.Outf("{{blue}} X-chain balance after P->X import: %d {{/}}\n", xFinalBalance) - gomega.Expect(xFinalBalance).To(gomega.Equal(xPreImportBalance + toTransfer - txFees)) // import not performed yet - gomega.Expect(pFinalBalance).To(gomega.Equal(pPreImportBalance)) + require.Equal(xFinalBalance, xPreImportBalance+toTransfer-txFees) // import not performed yet + require.Equal(pFinalBalance, pPreImportBalance) }) }) diff --git a/tests/e2e/static-handlers/suites.go b/tests/e2e/static-handlers/suites.go index 2d7e75c02531..742d99e9c276 100644 --- a/tests/e2e/static-handlers/suites.go +++ b/tests/e2e/static-handlers/suites.go @@ -8,6 +8,10 @@ import ( "context" "time" + ginkgo "github.com/onsi/ginkgo/v2" + + "github.com/stretchr/testify/require" + "github.com/ava-labs/avalanchego/ids" "github.com/ava-labs/avalanchego/tests/e2e" "github.com/ava-labs/avalanchego/utils/cb58" @@ -20,12 +24,11 @@ import ( "github.com/ava-labs/avalanchego/vms/avm" "github.com/ava-labs/avalanchego/vms/platformvm/api" "github.com/ava-labs/avalanchego/vms/platformvm/reward" - - ginkgo "github.com/onsi/ginkgo/v2" - "github.com/onsi/gomega" ) var _ = ginkgo.Describe("[StaticHandlers]", func() { + require := require.New(ginkgo.GinkgoT()) + ginkgo.It("can make calls to avm static api", // use this for filtering tests by labels // ref. https://onsi.github.io/ginkgo/#spec-labels @@ -41,9 +44,9 @@ var _ = ginkgo.Describe("[StaticHandlers]", func() { "Jz9ayEDt7dx9hDx45aXALujWmL9ZUuqe7", } { addr, err := ids.ShortFromString(addrStr) - gomega.Expect(err).Should(gomega.BeNil()) + require.NoError(err) addrMap[addrStr], err = address.FormatBech32(constants.NetworkIDToHRP[constants.LocalID], addr[:]) - gomega.Expect(err).Should(gomega.BeNil()) + require.NoError(err) } avmArgs := avm.BuildGenesisArgs{ Encoding: formatting.Hex, @@ -114,8 +117,8 @@ var _ = ginkgo.Describe("[StaticHandlers]", func() { ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second) resp, err := staticClient.BuildGenesis(ctx, &avmArgs) cancel() - gomega.Expect(err).Should(gomega.BeNil()) - gomega.Expect(resp.Bytes).Should(gomega.Equal("0x0000000000030006617373657431000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000f6d794669786564436170417373657400044d4643410800000001000000000000000400000007000000000000c350000000000000000000000001000000013f78e510df62bc48b0829ec06d6a6b98062d695300000007000000000000c35000000000000000000000000100000001c54903de5177a16f7811771ef2f4659d9e8646710000000700000000000186a0000000000000000000000001000000013f58fda2e9ea8d9e4b181832a07b26dae286f2cb0000000700000000000186a000000000000000000000000100000001645938bb7ae2193270e6ffef009e3664d11e07c10006617373657432000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000d6d79566172436170417373657400044d5643410000000001000000000000000200000006000000000000000000000001000000023f58fda2e9ea8d9e4b181832a07b26dae286f2cb645938bb7ae2193270e6ffef009e3664d11e07c100000006000000000000000000000001000000023f78e510df62bc48b0829ec06d6a6b98062d6953c54903de5177a16f7811771ef2f4659d9e864671000661737365743300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000126d794f7468657256617243617041737365740000000000000100000000000000010000000600000000000000000000000100000001645938bb7ae2193270e6ffef009e3664d11e07c1279fa028")) + require.NoError(err) + require.Equal(resp.Bytes, "0x0000000000030006617373657431000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000f6d794669786564436170417373657400044d4643410800000001000000000000000400000007000000000000c350000000000000000000000001000000013f78e510df62bc48b0829ec06d6a6b98062d695300000007000000000000c35000000000000000000000000100000001c54903de5177a16f7811771ef2f4659d9e8646710000000700000000000186a0000000000000000000000001000000013f58fda2e9ea8d9e4b181832a07b26dae286f2cb0000000700000000000186a000000000000000000000000100000001645938bb7ae2193270e6ffef009e3664d11e07c10006617373657432000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000d6d79566172436170417373657400044d5643410000000001000000000000000200000006000000000000000000000001000000023f58fda2e9ea8d9e4b181832a07b26dae286f2cb645938bb7ae2193270e6ffef009e3664d11e07c100000006000000000000000000000001000000023f78e510df62bc48b0829ec06d6a6b98062d6953c54903de5177a16f7811771ef2f4659d9e864671000661737365743300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000126d794f7468657256617243617041737365740000000000000100000000000000010000000600000000000000000000000100000001645938bb7ae2193270e6ffef009e3664d11e07c1279fa028") }) ginkgo.It("can make calls to platformvm static api", func() { @@ -129,9 +132,9 @@ var _ = ginkgo.Describe("[StaticHandlers]", func() { "2RWLv6YVEXDiWLpaCbXhhqxtLbnFaKQsWPSSMSPhpWo47uJAeV", } { privKeyBytes, err := cb58.Decode(key) - gomega.Expect(err).Should(gomega.BeNil()) + require.NoError(err) pk, err := factory.ToPrivateKey(privKeyBytes) - gomega.Expect(err).Should(gomega.BeNil()) + require.NoError(err) keys = append(keys, pk) } @@ -140,7 +143,7 @@ var _ = ginkgo.Describe("[StaticHandlers]", func() { for i, key := range keys { id := key.PublicKey().Address() addr, err := address.FormatBech32(hrp, id.Bytes()) - gomega.Expect(err).Should(gomega.BeNil()) + require.NoError(err) genesisUTXOs[i] = api.UTXO{ Amount: json.Uint64(50000 * units.MilliAvax), Address: addr, @@ -151,7 +154,7 @@ var _ = ginkgo.Describe("[StaticHandlers]", func() { for i, key := range keys { id := key.PublicKey().Address() addr, err := address.FormatBech32(hrp, id.Bytes()) - gomega.Expect(err).Should(gomega.BeNil()) + require.NoError(err) genesisValidators[i] = api.PermissionlessValidator{ Staker: api.Staker{ StartTime: json.Uint64(time.Date(1997, 1, 1, 0, 0, 0, 0, time.UTC).Unix()), @@ -185,7 +188,7 @@ var _ = ginkgo.Describe("[StaticHandlers]", func() { ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second) resp, err := staticClient.BuildGenesis(ctx, &buildGenesisArgs) cancel() - gomega.Expect(err).Should(gomega.BeNil()) - gomega.Expect(resp.Bytes).Should(gomega.Equal("0x0000000000050000000000000000000000000000000000000000000000000000000000000000000000006176617800000000000000000000000000000000000000000000000000000000000000070000000ba43b740000000000000000000000000100000001fceda8f90fcb5d30614b99d79fc4baa293077626000000000000000000000000000000000000000000000000000000000000000000000000000000016176617800000000000000000000000000000000000000000000000000000000000000070000000ba43b7400000000000000000000000001000000016ead693c17abb1be422bb50b30b9711ff98d667e000000000000000000000000000000000000000000000000000000000000000000000000000000026176617800000000000000000000000000000000000000000000000000000000000000070000000ba43b740000000000000000000000000100000001f2420846876e69f473dda256172967e992f0ee31000000000000000000000000000000000000000000000000000000000000000000000000000000036176617800000000000000000000000000000000000000000000000000000000000000070000000ba43b7400000000000000000000000001000000013cb7d3842e8cee6a0ebd09f1fe884f6861e1b29c000000000000000000000000000000000000000000000000000000000000000000000000000000046176617800000000000000000000000000000000000000000000000000000000000000070000000ba43b74000000000000000000000000010000000187c4ec0736fdad03fd9ec8c3ba609de958601a7b00000000000000050000000c0000000a0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000fceda8f90fcb5d30614b99d79fc4baa2930776260000000032c9a9000000000032efe480000000000000271000000001617661780000000000000000000000000000000000000000000000000000000000000007000000000000271000000000000000000000000100000001fceda8f90fcb5d30614b99d79fc4baa2930776260000000b00000000000000000000000100000001fceda8f90fcb5d30614b99d79fc4baa29307762600000000000000000000000c0000000a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000006ead693c17abb1be422bb50b30b9711ff98d667e0000000032c9a9000000000032efe4800000000000002710000000016176617800000000000000000000000000000000000000000000000000000000000000070000000000002710000000000000000000000001000000016ead693c17abb1be422bb50b30b9711ff98d667e0000000b000000000000000000000001000000016ead693c17abb1be422bb50b30b9711ff98d667e00000000000000000000000c0000000a0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000f2420846876e69f473dda256172967e992f0ee310000000032c9a9000000000032efe480000000000000271000000001617661780000000000000000000000000000000000000000000000000000000000000007000000000000271000000000000000000000000100000001f2420846876e69f473dda256172967e992f0ee310000000b00000000000000000000000100000001f2420846876e69f473dda256172967e992f0ee3100000000000000000000000c0000000a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000003cb7d3842e8cee6a0ebd09f1fe884f6861e1b29c0000000032c9a9000000000032efe4800000000000002710000000016176617800000000000000000000000000000000000000000000000000000000000000070000000000002710000000000000000000000001000000013cb7d3842e8cee6a0ebd09f1fe884f6861e1b29c0000000b000000000000000000000001000000013cb7d3842e8cee6a0ebd09f1fe884f6861e1b29c00000000000000000000000c0000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000087c4ec0736fdad03fd9ec8c3ba609de958601a7b0000000032c9a9000000000032efe48000000000000027100000000161766178000000000000000000000000000000000000000000000000000000000000000700000000000027100000000000000000000000010000000187c4ec0736fdad03fd9ec8c3ba609de958601a7b0000000b0000000000000000000000010000000187c4ec0736fdad03fd9ec8c3ba609de958601a7b0000000000000000000000000000000032c9a90004fefa17b724000000008e96cbef")) + require.NoError(err) + require.Equal(resp.Bytes, "0x0000000000050000000000000000000000000000000000000000000000000000000000000000000000006176617800000000000000000000000000000000000000000000000000000000000000070000000ba43b740000000000000000000000000100000001fceda8f90fcb5d30614b99d79fc4baa293077626000000000000000000000000000000000000000000000000000000000000000000000000000000016176617800000000000000000000000000000000000000000000000000000000000000070000000ba43b7400000000000000000000000001000000016ead693c17abb1be422bb50b30b9711ff98d667e000000000000000000000000000000000000000000000000000000000000000000000000000000026176617800000000000000000000000000000000000000000000000000000000000000070000000ba43b740000000000000000000000000100000001f2420846876e69f473dda256172967e992f0ee31000000000000000000000000000000000000000000000000000000000000000000000000000000036176617800000000000000000000000000000000000000000000000000000000000000070000000ba43b7400000000000000000000000001000000013cb7d3842e8cee6a0ebd09f1fe884f6861e1b29c000000000000000000000000000000000000000000000000000000000000000000000000000000046176617800000000000000000000000000000000000000000000000000000000000000070000000ba43b74000000000000000000000000010000000187c4ec0736fdad03fd9ec8c3ba609de958601a7b00000000000000050000000c0000000a0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000fceda8f90fcb5d30614b99d79fc4baa2930776260000000032c9a9000000000032efe480000000000000271000000001617661780000000000000000000000000000000000000000000000000000000000000007000000000000271000000000000000000000000100000001fceda8f90fcb5d30614b99d79fc4baa2930776260000000b00000000000000000000000100000001fceda8f90fcb5d30614b99d79fc4baa29307762600000000000000000000000c0000000a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000006ead693c17abb1be422bb50b30b9711ff98d667e0000000032c9a9000000000032efe4800000000000002710000000016176617800000000000000000000000000000000000000000000000000000000000000070000000000002710000000000000000000000001000000016ead693c17abb1be422bb50b30b9711ff98d667e0000000b000000000000000000000001000000016ead693c17abb1be422bb50b30b9711ff98d667e00000000000000000000000c0000000a0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000f2420846876e69f473dda256172967e992f0ee310000000032c9a9000000000032efe480000000000000271000000001617661780000000000000000000000000000000000000000000000000000000000000007000000000000271000000000000000000000000100000001f2420846876e69f473dda256172967e992f0ee310000000b00000000000000000000000100000001f2420846876e69f473dda256172967e992f0ee3100000000000000000000000c0000000a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000003cb7d3842e8cee6a0ebd09f1fe884f6861e1b29c0000000032c9a9000000000032efe4800000000000002710000000016176617800000000000000000000000000000000000000000000000000000000000000070000000000002710000000000000000000000001000000013cb7d3842e8cee6a0ebd09f1fe884f6861e1b29c0000000b000000000000000000000001000000013cb7d3842e8cee6a0ebd09f1fe884f6861e1b29c00000000000000000000000c0000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000087c4ec0736fdad03fd9ec8c3ba609de958601a7b0000000032c9a9000000000032efe48000000000000027100000000161766178000000000000000000000000000000000000000000000000000000000000000700000000000027100000000000000000000000010000000187c4ec0736fdad03fd9ec8c3ba609de958601a7b0000000b0000000000000000000000010000000187c4ec0736fdad03fd9ec8c3ba609de958601a7b0000000000000000000000000000000032c9a90004fefa17b724000000008e96cbef") }) }) diff --git a/tests/e2e/x/transfer/virtuous.go b/tests/e2e/x/transfer/virtuous.go index 38ceb858bcbd..d4e180be1a7a 100644 --- a/tests/e2e/x/transfer/virtuous.go +++ b/tests/e2e/x/transfer/virtuous.go @@ -10,10 +10,10 @@ import ( "math/rand" "time" - "github.com/onsi/gomega" - ginkgo "github.com/onsi/ginkgo/v2" + "github.com/stretchr/testify/require" + "github.com/ava-labs/avalanchego/ids" "github.com/ava-labs/avalanchego/snow/choices" "github.com/ava-labs/avalanchego/tests" @@ -36,6 +36,8 @@ const ( // This test requires that the network not have ongoing blocks and // cannot reliably be run in parallel. var _ = e2e.DescribeXChainSerial("[Virtuous Transfer Tx AVAX]", func() { + require := require.New(ginkgo.GinkgoT()) + ginkgo.It("can issue a virtuous transfer tx for AVAX asset", // use this for filtering tests by labels // ref. https://onsi.github.io/ginkgo/#spec-labels @@ -49,19 +51,20 @@ var _ = e2e.DescribeXChainSerial("[Virtuous Transfer Tx AVAX]", func() { // Waiting for ongoing blocks to have completed before starting this // test avoids the case of a previous test having initiated block // processing but not having completed it. - gomega.Eventually(func() bool { + e2e.Eventually(func() bool { allNodeMetrics, err := tests.GetNodesMetrics(rpcEps, metricBlksProcessing) - gomega.Expect(err).Should(gomega.BeNil()) + require.NoError(err) for _, metrics := range allNodeMetrics { if metrics[metricBlksProcessing] > 0 { return false } } return true - }). - WithTimeout(e2e.DefaultTimeout). - WithPolling(e2e.DefaultPollingInterval). - Should(gomega.BeTrue(), "The cluster is generating ongoing blocks. Is this test being run in parallel?") + }, + e2e.DefaultTimeout, + e2e.DefaultPollingInterval, + "The cluster is generating ongoing blocks. Is this test being run in parallel?", + ) allMetrics := []string{ metricBlksProcessing, @@ -101,7 +104,7 @@ var _ = e2e.DescribeXChainSerial("[Virtuous Transfer Tx AVAX]", func() { } metricsBeforeTx, err := tests.GetNodesMetrics(rpcEps, allMetrics...) - gomega.Expect(err).Should(gomega.BeNil()) + require.NoError(err) for _, uri := range rpcEps { tests.Outf("{{green}}metrics at %q:{{/}} %v\n", uri, metricsBeforeTx[uri]) } @@ -109,7 +112,7 @@ var _ = e2e.DescribeXChainSerial("[Virtuous Transfer Tx AVAX]", func() { testBalances := make([]uint64, 0) for i, w := range wallets { balances, err := w.X().Builder().GetFTBalance() - gomega.Expect(err).Should(gomega.BeNil()) + require.NoError(err) bal := balances[avaxAssetID] testBalances = append(testBalances, bal) @@ -127,9 +130,7 @@ var _ = e2e.DescribeXChainSerial("[Virtuous Transfer Tx AVAX]", func() { break } } - if fromIdx < 0 { - gomega.Expect(fromIdx).Should(gomega.BeNumerically(">", 0), "no address found with non-zero balance") - } + require.Positive(fromIdx, "no address found with non-zero balance") toIdx := -1 for i := range testBalances { @@ -170,7 +171,7 @@ var _ = e2e.DescribeXChainSerial("[Virtuous Transfer Tx AVAX]", func() { common.WithContext(ctx), ) cancel() - gomega.Expect(err.Error()).Should(gomega.ContainSubstring("insufficient funds")) + require.Contains(err.Error(), "insufficient funds") }) fmt.Printf(`=== @@ -213,20 +214,20 @@ RECEIVER NEW BALANCE (AFTER) : %21d AVAX common.WithContext(ctx), ) cancel() - gomega.Expect(err).Should(gomega.BeNil()) + require.NoError(err) balances, err := wallets[fromIdx].X().Builder().GetFTBalance() - gomega.Expect(err).Should(gomega.BeNil()) + require.NoError(err) senderCurBalX := balances[avaxAssetID] tests.Outf("{{green}}first wallet balance:{{/}} %d\n", senderCurBalX) balances, err = wallets[toIdx].X().Builder().GetFTBalance() - gomega.Expect(err).Should(gomega.BeNil()) + require.NoError(err) receiverCurBalX := balances[avaxAssetID] tests.Outf("{{green}}second wallet balance:{{/}} %d\n", receiverCurBalX) - gomega.Expect(senderCurBalX).Should(gomega.Equal(senderNewBal)) - gomega.Expect(receiverCurBalX).Should(gomega.Equal(receiverNewBal)) + require.Equal(senderCurBalX, senderNewBal) + require.Equal(receiverCurBalX, receiverNewBal) txID := tx.ID() for _, u := range rpcEps { @@ -234,8 +235,8 @@ RECEIVER NEW BALANCE (AFTER) : %21d AVAX ctx, cancel := context.WithTimeout(context.Background(), e2e.DefaultConfirmTxTimeout) status, err := xc.ConfirmTx(ctx, txID, 2*time.Second) cancel() - gomega.Expect(err).Should(gomega.BeNil()) - gomega.Expect(status).Should(gomega.Equal(choices.Accepted)) + require.NoError(err) + require.Equal(status, choices.Accepted) } for _, u := range rpcEps { @@ -243,20 +244,20 @@ RECEIVER NEW BALANCE (AFTER) : %21d AVAX ctx, cancel := context.WithTimeout(context.Background(), e2e.DefaultConfirmTxTimeout) status, err := xc.ConfirmTx(ctx, txID, 2*time.Second) cancel() - gomega.Expect(err).Should(gomega.BeNil()) - gomega.Expect(status).Should(gomega.Equal(choices.Accepted)) + require.NoError(err) + require.Equal(status, choices.Accepted) mm, err := tests.GetNodeMetrics(u, allMetrics...) - gomega.Expect(err).Should(gomega.BeNil()) + require.NoError(err) prev := metricsBeforeTx[u] // +0 since X-chain tx must have been processed and accepted // by now - gomega.Expect(mm[metricBlksProcessing]).Should(gomega.Equal(prev[metricBlksProcessing])) + require.Equal(mm[metricBlksProcessing], prev[metricBlksProcessing]) // +1 since X-chain tx must have been accepted by now - gomega.Expect(mm[metricBlksAccepted]).Should(gomega.Equal(prev[metricBlksAccepted] + 1)) + require.Equal(mm[metricBlksAccepted], prev[metricBlksAccepted]+1) metricsBeforeTx[u] = mm }