Skip to content
Open
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
4 changes: 3 additions & 1 deletion tests/systemtests/chainupgrade/v4_v5.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
)

const (
upgradeHeight int64 = 12
upgradeHeight int64 = 15
upgradeName = "v0.5.0-to-v0.6.0" // must match UpgradeName in evmd/upgrades.go
)

Expand Down Expand Up @@ -92,6 +92,8 @@ func RunChainUpgrade(t *testing.T, base *suite.BaseTestSuite) {
sut.AwaitUpgradeInfo(t)
sut.StopChain()

suite.EnsureAppMempoolConfig(t, sut)

t.Log("Upgrade height was reached. Upgrading chain")
sut.SetExecBinary(currentBranchBinary)
sut.SetTestnetInitializer(currentInitializer)
Expand Down
46 changes: 45 additions & 1 deletion tests/systemtests/clients/cosmosclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ func (c *CosmosClient) WaitForCommit(
}
}

// CheckTxsPending checks if a transaction is either pending in the mempool or already committed.
// CheckTxsPending checks if a transaction is either pending in the mempool.
func (c *CosmosClient) CheckTxsPending(
nodeID string,
txHash string,
Expand Down Expand Up @@ -185,6 +185,50 @@ func (c *CosmosClient) CheckTxsPending(
}
}

// CheckTxsPendingOrCommitted checks if a transaction is either pending in the mempool or already committed.
func (c *CosmosClient) CheckTxsPendingOrCommitted(
nodeID string,
txHash string,
timeout time.Duration,
) error {
ctx, cancel := context.WithTimeout(context.Background(), timeout)
defer cancel()

ticker := time.NewTicker(500 * time.Millisecond)
defer ticker.Stop()

hashBytes, err := hex.DecodeString(txHash)
if err != nil {
return fmt.Errorf("invalid tx hash format: %v", err)
}

for {
select {
case <-ctx.Done():
return fmt.Errorf("timeout waiting for transaction %s", txHash)
case <-ticker.C:
result, err := c.UnconfirmedTxs(ctx, nodeID)
if err == nil {
pendingTxHashes := make([]string, 0, len(result.Txs))
for _, tx := range result.Txs {
pendingTxHashes = append(pendingTxHashes, string(tx.Hash()))
}

if slices.Contains(pendingTxHashes, txHash) {
return nil
}
}

_, err = c.ClientCtx.Client.Tx(ctx, hashBytes, false)
if err != nil {
continue
}

return nil
}
}
}

// UnconfirmedTxs retrieves the list of unconfirmed transactions from the node's mempool.
func (c *CosmosClient) UnconfirmedTxs(ctx context.Context, nodeID string) (*coretypes.ResultUnconfirmedTxs, error) {
return c.RpcClients[nodeID].UnconfirmedTxs(ctx, nil)
Expand Down
41 changes: 40 additions & 1 deletion tests/systemtests/clients/ethclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ func (ec *EthClient) WaitForCommit(
}
}

// CheckTxsPending checks if a transaction is either pending in the mempool or already committed.
// CheckTxsPending checks if a transaction is either pending in the mempool.
func (ec *EthClient) CheckTxsPending(
nodeID string,
txHash string,
Expand Down Expand Up @@ -144,6 +144,45 @@ func (ec *EthClient) CheckTxsPending(
}
}

// CheckTxsPendingOrCommitted checks if a transaction is either pending in the mempool or already committed.
func (ec *EthClient) CheckTxsPendingOrCommitted(
nodeID string,
txHash string,
timeout time.Duration,
) error {
ctx, cancel := context.WithTimeout(context.Background(), timeout)
defer cancel()

ticker := time.NewTicker(100 * time.Millisecond)
defer ticker.Stop()

for {
select {
case <-ctx.Done():
return fmt.Errorf("timeout waiting for transaction %s", txHash)
case <-ticker.C:
pendingTxs, _, err := ec.TxPoolContent(ctx, nodeID)
if err != nil {
fmt.Printf("DEBUG: failed to get txpool content: %v", err)
continue // Retry on error
}

pendingTxHashes := extractTxHashesSorted(pendingTxs)

if ok := slices.Contains(pendingTxHashes, txHash); ok {
return nil
}

_, err = ec.Clients[nodeID].TransactionReceipt(context.Background(), common.HexToHash(txHash))
if err != nil {
continue // Retry on error
}

return nil
}
}
}

// TxPoolContent returns the pending and queued tx hashes in the tx pool of the given node
func (ec *EthClient) TxPoolContent(ctx context.Context, nodeID string) (map[string]map[string]*EthRPCTransaction, map[string]map[string]*EthRPCTransaction, error) {
ethCli := ec.Clients[nodeID]
Expand Down
Loading
Loading