Skip to content

Commit

Permalink
separate deposit stress tests
Browse files Browse the repository at this point in the history
  • Loading branch information
skosito committed Dec 11, 2024
1 parent d4cacb6 commit a5bf1c1
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 27 deletions.
6 changes: 3 additions & 3 deletions cmd/zetae2e/local/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -381,9 +381,9 @@ func localE2ETest(cmd *cobra.Command, _ []string) {
}

if testPerformance {
// eg.Go(ethereumDepositPerformanceRoutine(conf, deployerRunner, verbose, e2etests.TestStressEtherDepositName))
// eg.Go(ethereumWithdrawPerformanceRoutine(conf, deployerRunner, verbose, e2etests.TestStressEtherWithdrawName))
// eg.Go(solanaDepositPerformanceRoutine(conf, deployerRunner, verbose, e2etests.TestStressSolanaDepositName))
eg.Go(ethereumDepositPerformanceRoutine(conf, deployerRunner, verbose, e2etests.TestStressEtherDepositName))
eg.Go(ethereumWithdrawPerformanceRoutine(conf, deployerRunner, verbose, e2etests.TestStressEtherWithdrawName))
eg.Go(solanaDepositPerformanceRoutine(conf, deployerRunner, verbose, e2etests.TestStressSolanaDepositName, e2etests.TestStressSPLDepositName))
eg.Go(solanaWithdrawPerformanceRoutine(conf, deployerRunner, verbose, e2etests.TestStressSolanaWithdrawName, e2etests.TestStressSPLWithdrawName))
}

Expand Down
16 changes: 12 additions & 4 deletions e2e/e2etests/e2etests.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ const (
TestStressEtherDepositName = "stress_eth_deposit"
TestStressBTCDepositName = "stress_btc_deposit"
TestStressSolanaDepositName = "stress_solana_deposit"
TestStressSPLDepositName = "stress_spl_deposit"
TestStressSolanaWithdrawName = "stress_solana_withdraw"
TestStressSPLWithdrawName = "stress_spl_withdraw"

Expand Down Expand Up @@ -772,15 +773,22 @@ var AllE2ETests = []runner.E2ETest{
),
runner.NewE2ETest(
TestStressSolanaDepositName,
"stress test SOL/SPL deposit",
"stress test SOL deposit",
[]runner.ArgDefinition{
{Description: "amount in lamports", DefaultValue: "1200000"},
{Description: "count of SOL deposits", DefaultValue: "10"},
{Description: "amount in SPL tokens", DefaultValue: "1200000"},
{Description: "count of SPL deposits", DefaultValue: "10"},
{Description: "count of SOL deposits", DefaultValue: "50"},
},
TestStressSolanaDeposit,
),
runner.NewE2ETest(
TestStressSPLDepositName,
"stress test SPL deposit",
[]runner.ArgDefinition{
{Description: "amount in SPL tokens", DefaultValue: "1200000"},
{Description: "count of SPL deposits", DefaultValue: "50"},
},
TestStressSPLDeposit,
),
runner.NewE2ETest(
TestStressSolanaWithdrawName,
"stress test SOL withdrawals",
Expand Down
23 changes: 3 additions & 20 deletions e2e/e2etests/test_stress_solana_deposit.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,14 @@ import (
crosschaintypes "github.com/zeta-chain/node/x/crosschain/types"
)

// TestStressSolanaDeposit tests the stressing deposit of SOL/SPL
// TestStressSolanaDeposit tests the stressing deposit of SOL
func TestStressSolanaDeposit(r *runner.E2ERunner, args []string) {
require.Len(r, args, 4)
require.Len(r, args, 2)

depositSOLAmount := utils.ParseBigInt(r, args[0])
numDepositsSOL := utils.ParseInt(r, args[1])

depositSPLAmount := utils.ParseBigInt(r, args[2])
numDepositsSPL := utils.ParseInt(r, args[3])

// load deployer private key
privKey := r.GetSolanaPrivKey()

r.Logger.Print("starting stress test of %d SOL and %d SPL deposits", numDepositsSOL, numDepositsSPL)
r.Logger.Print("starting stress test of %d SOL deposits", numDepositsSOL)

// create a wait group to wait for all the deposits to complete
var eg errgroup.Group
Expand All @@ -42,17 +36,6 @@ func TestStressSolanaDeposit(r *runner.E2ERunner, args []string) {
eg.Go(func() error { return monitorDeposit(r, sig, i, time.Now()) })
}

// send the deposits SPL
for i := 0; i < numDepositsSPL; i++ {
i := i

// execute the deposit SPL transaction
sig := r.SPLDepositAndCall(&privKey, depositSPLAmount.Uint64(), r.SPLAddr, r.EVMAddress(), nil)
r.Logger.Print("index %d: starting SPL deposit, sig: %s", i, sig.String())

eg.Go(func() error { return monitorDeposit(r, sig, i, time.Now()) })
}

require.NoError(r, eg.Wait())

r.Logger.Print("all deposits completed")
Expand Down
41 changes: 41 additions & 0 deletions e2e/e2etests/test_stress_spl_deposit.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package e2etests

import (
"time"

"github.com/stretchr/testify/require"
"github.com/zeta-chain/node/e2e/runner"
"github.com/zeta-chain/node/e2e/utils"
"golang.org/x/sync/errgroup"
)

// TestStressSPLDeposit tests the stressing deposit of SPL
func TestStressSPLDeposit(r *runner.E2ERunner, args []string) {
require.Len(r, args, 2)

depositSPLAmount := utils.ParseBigInt(r, args[0])
numDepositsSPL := utils.ParseInt(r, args[1])

// load deployer private key
privKey := r.GetSolanaPrivKey()

r.Logger.Print("starting stress test of %d SPL deposits", numDepositsSPL)

// create a wait group to wait for all the deposits to complete
var eg errgroup.Group

// send the deposits SPL
for i := 0; i < numDepositsSPL; i++ {
i := i

// execute the deposit SPL transaction
sig := r.SPLDepositAndCall(&privKey, depositSPLAmount.Uint64(), r.SPLAddr, r.EVMAddress(), nil)
r.Logger.Print("index %d: starting SPL deposit, sig: %s", i, sig.String())

eg.Go(func() error { return monitorDeposit(r, sig, i, time.Now()) })
}

require.NoError(r, eg.Wait())

r.Logger.Print("all deposits completed")
}

0 comments on commit a5bf1c1

Please sign in to comment.