2024-01-04 04:37:42 +00:00
|
|
|
// These tests are for development only to be run manually
|
|
|
|
// There is more work needed to automate them not to depend on an existing account and internet connection
|
|
|
|
|
|
|
|
package wallet
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
"time"
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
|
|
|
|
"github.com/status-im/status-desktop/test/status-go/integration/helpers"
|
|
|
|
|
|
|
|
"github.com/status-im/status-go/eth-node/types"
|
2024-04-02 13:27:21 +00:00
|
|
|
"github.com/status-im/status-go/services/wallet/common"
|
2023-12-17 04:18:20 +00:00
|
|
|
"github.com/status-im/status-go/services/wallet/walletevent"
|
2024-01-04 04:37:42 +00:00
|
|
|
"github.com/status-im/status-go/transactions"
|
|
|
|
)
|
|
|
|
|
|
|
|
// TestPendingTx_NotificationStatus tests that a pending transaction is created, then updated and finally deleted.
|
|
|
|
func TestPendingTx_NotificationStatus(t *testing.T) {
|
2023-12-17 04:18:20 +00:00
|
|
|
td, close := setupAccountsAndTransactions(t)
|
|
|
|
defer close()
|
2024-01-04 04:37:42 +00:00
|
|
|
|
2024-04-02 13:27:21 +00:00
|
|
|
chainID := common.OptimismSepolia
|
|
|
|
sendTransaction(t, td, chainID)
|
2024-01-04 04:37:42 +00:00
|
|
|
|
2024-02-08 12:47:09 +00:00
|
|
|
// Wait for transaction to be included in block
|
|
|
|
confirmationPayloads, err := helpers.WaitForWalletEventsGetMap(
|
2023-12-17 04:18:20 +00:00
|
|
|
td.eventQueue, []walletevent.EventType{
|
|
|
|
transactions.EventPendingTransactionUpdate,
|
2024-02-08 12:47:09 +00:00
|
|
|
transactions.EventPendingTransactionStatusChanged,
|
2024-01-04 04:37:42 +00:00
|
|
|
},
|
2023-12-17 04:18:20 +00:00
|
|
|
60*time.Second,
|
|
|
|
)
|
2024-01-04 04:37:42 +00:00
|
|
|
require.NoError(t, err)
|
|
|
|
|
2024-02-08 12:47:09 +00:00
|
|
|
// Validate that we received update event
|
|
|
|
for _, payload := range confirmationPayloads {
|
|
|
|
if payload.EventName == transactions.EventPendingTransactionUpdate {
|
|
|
|
require.False(t, payload.JsonData["deleted"].(bool))
|
|
|
|
} else {
|
|
|
|
require.Equal(t, transactions.Success, payload.JsonData["status"].(transactions.TxStatus))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Start history download ...
|
2024-04-02 13:27:21 +00:00
|
|
|
_, err = helpers.CallPrivateMethod("wallet_checkRecentHistoryForChainIDs", []interface{}{[]uint64{chainID}, []types.Address{td.operableAccounts[0].Address, td.watchAccounts[0].Address}})
|
2024-02-08 12:47:09 +00:00
|
|
|
require.NoError(t, err)
|
|
|
|
|
2024-04-02 13:27:21 +00:00
|
|
|
// Wait for transaction to be included in block
|
|
|
|
pendingUpdated, err := helpers.WaitForWalletEventGetPayload[transactions.PendingTxUpdatePayload](
|
|
|
|
td.eventQueue, transactions.EventPendingTransactionUpdate, 60*time.Second)
|
2024-02-08 12:47:09 +00:00
|
|
|
require.NoError(t, err)
|
2024-04-02 13:27:21 +00:00
|
|
|
|
|
|
|
require.True(t, pendingUpdated.Deleted)
|
2024-01-04 04:37:42 +00:00
|
|
|
}
|