test(wallet) add dev integration tests for ERC721 route estimator
Used for debugging ERC721 route estimation issues Updates: #14212
This commit is contained in:
parent
ee23cce575
commit
ad0a7d3ba4
|
@ -21,7 +21,7 @@ replace github.com/mutecomm/go-sqlcipher/v4 v4.4.2 => github.com/status-im/go-sq
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/ethereum/go-ethereum v1.10.26
|
github.com/ethereum/go-ethereum v1.10.26
|
||||||
github.com/status-im/status-go v0.171.7
|
github.com/status-im/status-go v0.177.1
|
||||||
github.com/stretchr/testify v1.8.4
|
github.com/stretchr/testify v1.8.4
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -241,7 +241,7 @@ require (
|
||||||
github.com/urfave/cli/v2 v2.24.4 // indirect
|
github.com/urfave/cli/v2 v2.24.4 // indirect
|
||||||
github.com/waku-org/go-discover v0.0.0-20240129014929-85f2c00b96a3 // indirect
|
github.com/waku-org/go-discover v0.0.0-20240129014929-85f2c00b96a3 // indirect
|
||||||
github.com/waku-org/go-libp2p-rendezvous v0.0.0-20230628220917-7b4e5ae4c0e7 // indirect
|
github.com/waku-org/go-libp2p-rendezvous v0.0.0-20230628220917-7b4e5ae4c0e7 // indirect
|
||||||
github.com/waku-org/go-waku v0.8.1-0.20240130093642-77ea359ef873 // indirect
|
github.com/waku-org/go-waku v0.8.1-0.20240322182925-dd81e1d46971 // indirect
|
||||||
github.com/waku-org/go-zerokit-rln v0.1.14-0.20240102145250-fa738c0bdf59 // indirect
|
github.com/waku-org/go-zerokit-rln v0.1.14-0.20240102145250-fa738c0bdf59 // indirect
|
||||||
github.com/waku-org/go-zerokit-rln-apple v0.0.0-20230916172309-ee0ee61dde2b // indirect
|
github.com/waku-org/go-zerokit-rln-apple v0.0.0-20230916172309-ee0ee61dde2b // indirect
|
||||||
github.com/waku-org/go-zerokit-rln-arm v0.0.0-20230916171929-1dd9494ff065 // indirect
|
github.com/waku-org/go-zerokit-rln-arm v0.0.0-20230916171929-1dd9494ff065 // indirect
|
||||||
|
|
|
@ -2096,8 +2096,8 @@ github.com/waku-org/go-discover v0.0.0-20240129014929-85f2c00b96a3 h1:Kk0KYXZE/u
|
||||||
github.com/waku-org/go-discover v0.0.0-20240129014929-85f2c00b96a3/go.mod h1:eBHgM6T4EG0RZzxpxKy+rGz/6Dw2Nd8DWxS0lm9ESDw=
|
github.com/waku-org/go-discover v0.0.0-20240129014929-85f2c00b96a3/go.mod h1:eBHgM6T4EG0RZzxpxKy+rGz/6Dw2Nd8DWxS0lm9ESDw=
|
||||||
github.com/waku-org/go-libp2p-rendezvous v0.0.0-20230628220917-7b4e5ae4c0e7 h1:0e1h+p84yBp0IN7AqgbZlV7lgFBjm214lgSOE7CeJmE=
|
github.com/waku-org/go-libp2p-rendezvous v0.0.0-20230628220917-7b4e5ae4c0e7 h1:0e1h+p84yBp0IN7AqgbZlV7lgFBjm214lgSOE7CeJmE=
|
||||||
github.com/waku-org/go-libp2p-rendezvous v0.0.0-20230628220917-7b4e5ae4c0e7/go.mod h1:pFvOZ9YTFsW0o5zJW7a0B5tr1owAijRWJctXJ2toL04=
|
github.com/waku-org/go-libp2p-rendezvous v0.0.0-20230628220917-7b4e5ae4c0e7/go.mod h1:pFvOZ9YTFsW0o5zJW7a0B5tr1owAijRWJctXJ2toL04=
|
||||||
github.com/waku-org/go-waku v0.8.1-0.20240130093642-77ea359ef873 h1:pnUvFENjM/h7HVF8VsNWTmOXx/rYs62P7H2EFjAnwVw=
|
github.com/waku-org/go-waku v0.8.1-0.20240322182925-dd81e1d46971 h1:HSR8JmscSmCtpIAzFO5sNZRyYZbO8nw7rGM3QcC9bak=
|
||||||
github.com/waku-org/go-waku v0.8.1-0.20240130093642-77ea359ef873/go.mod h1:RjTvkTrIwpoT1cM9HeQqwa2Q7t7WOkb3hpuB/zuZ6SM=
|
github.com/waku-org/go-waku v0.8.1-0.20240322182925-dd81e1d46971/go.mod h1:RjTvkTrIwpoT1cM9HeQqwa2Q7t7WOkb3hpuB/zuZ6SM=
|
||||||
github.com/waku-org/go-zerokit-rln v0.1.14-0.20240102145250-fa738c0bdf59 h1:jisj+OCI6QydLtFq3Pyhu49wl9ytPN7oAHjMfepHDrA=
|
github.com/waku-org/go-zerokit-rln v0.1.14-0.20240102145250-fa738c0bdf59 h1:jisj+OCI6QydLtFq3Pyhu49wl9ytPN7oAHjMfepHDrA=
|
||||||
github.com/waku-org/go-zerokit-rln v0.1.14-0.20240102145250-fa738c0bdf59/go.mod h1:1PdBdPzyTaKt3VnpAHk3zj+r9dXPFOr3IHZP9nFle6E=
|
github.com/waku-org/go-zerokit-rln v0.1.14-0.20240102145250-fa738c0bdf59/go.mod h1:1PdBdPzyTaKt3VnpAHk3zj+r9dXPFOr3IHZP9nFle6E=
|
||||||
github.com/waku-org/go-zerokit-rln-apple v0.0.0-20230916172309-ee0ee61dde2b h1:KgZVhsLkxsj5gb/FfndSCQu6VYwALrCOgYI3poR95yE=
|
github.com/waku-org/go-zerokit-rln-apple v0.0.0-20230916172309-ee0ee61dde2b h1:KgZVhsLkxsj5gb/FfndSCQu6VYwALrCOgYI3poR95yE=
|
||||||
|
|
|
@ -366,7 +366,11 @@ func CallPrivateMethod(method string, params []interface{}) (string, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func CallPrivateMethodAndGetT[T any](method string, params []interface{}) (*T, error) {
|
func CallPrivateMethodAndGetT[T any](method string, params []interface{}) (*T, error) {
|
||||||
resJson, err := CallPrivateMethodWithTimeout(method, params, 60*time.Second)
|
return CallPrivateMethodAndGetTWithTimeout[T](method, params, 60*time.Second)
|
||||||
|
}
|
||||||
|
|
||||||
|
func CallPrivateMethodAndGetTWithTimeout[T any](method string, params []interface{}, timeout time.Duration) (*T, error) {
|
||||||
|
resJson, err := CallPrivateMethodWithTimeout(method, params, timeout)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,7 @@ func TestActivityIncrementalUpdates_NoFilterNewPendingTransactions(t *testing.T)
|
||||||
td, close := setupAccountsAndTransactions(t)
|
td, close := setupAccountsAndTransactions(t)
|
||||||
defer close()
|
defer close()
|
||||||
|
|
||||||
rawSessionID, err := helpers.CallPrivateMethodAndGetT[int32]("wallet_startActivityFilterSession", []interface{}{[]types.Address{td.sender.Address}, false, []common.ChainID{5}, activity.Filter{}, 3})
|
rawSessionID, err := helpers.CallPrivateMethodAndGetT[int32]("wallet_startActivityFilterSession", []interface{}{[]types.Address{td.operableAccounts[0].Address}, false, []common.ChainID{5}, activity.Filter{}, 3})
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.NotNil(t, rawSessionID)
|
require.NotNil(t, rawSessionID)
|
||||||
sessionID := activity.SessionID(*rawSessionID)
|
sessionID := activity.SessionID(*rawSessionID)
|
||||||
|
@ -51,10 +51,10 @@ func TestActivityIncrementalUpdates_NoFilterNewPendingTransactions(t *testing.T)
|
||||||
// require.True(t, *update.HasNewOnTop)
|
// require.True(t, *update.HasNewOnTop)
|
||||||
|
|
||||||
// Start history download to cleanup pending transactions
|
// Start history download to cleanup pending transactions
|
||||||
_, err = helpers.CallPrivateMethod("wallet_checkRecentHistoryForChainIDs", []interface{}{[]uint64{5}, []types.Address{td.sender.Address, td.recipient.Address}})
|
_, err = helpers.CallPrivateMethod("wallet_checkRecentHistoryForChainIDs", []interface{}{[]uint64{5}, []types.Address{td.operableAccounts[0].Address, td.watchAccounts[0].Address}})
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
downloadDoneFn := helpers.WaitForTxDownloaderToFinishForAccountsCondition(t, []eth.Address{eth.Address(td.sender.Address), eth.Address(td.recipient.Address)})
|
downloadDoneFn := helpers.WaitForTxDownloaderToFinishForAccountsCondition(t, []eth.Address{eth.Address(td.operableAccounts[0].Address), eth.Address(td.watchAccounts[0].Address)})
|
||||||
|
|
||||||
update = nil
|
update = nil
|
||||||
// Wait for EventRecentHistoryReady.
|
// Wait for EventRecentHistoryReady.
|
||||||
|
|
|
@ -16,16 +16,20 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
type testUserData struct {
|
type testUserData struct {
|
||||||
sender accounts.Account
|
operableAccounts []accounts.Account
|
||||||
recipient accounts.Account
|
watchAccounts []accounts.Account
|
||||||
hashedPassword string
|
hashedPassword string
|
||||||
eventQueue chan helpers.GoEvent
|
eventQueue chan helpers.GoEvent
|
||||||
}
|
}
|
||||||
|
|
||||||
func setupAccountsAndTransactions(t *testing.T) (td testUserData, close func()) {
|
func setupAccountsAndTransactions(t *testing.T) (td testUserData, close func()) {
|
||||||
|
return setupAccountsAndTransactionsWithTimeout(t, 60*time.Second)
|
||||||
|
}
|
||||||
|
|
||||||
|
func setupAccountsAndTransactionsWithTimeout(t *testing.T, timeout time.Duration) (td testUserData, close func()) {
|
||||||
eventQueue, conf, _ := helpers.LoginToTestAccount(t)
|
eventQueue, conf, _ := helpers.LoginToTestAccount(t)
|
||||||
|
|
||||||
_, err := helpers.WaitForEvent(eventQueue, helpers.NodeReadyEvent, 60*time.Second)
|
_, err := helpers.WaitForEvent(eventQueue, helpers.NodeReadyEvent, timeout)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
opAccounts, err := helpers.GetWalletOperableAccounts()
|
opAccounts, err := helpers.GetWalletOperableAccounts()
|
||||||
|
@ -37,8 +41,8 @@ func setupAccountsAndTransactions(t *testing.T) (td testUserData, close func())
|
||||||
require.Greater(t, len(watchAccounts), 0)
|
require.Greater(t, len(watchAccounts), 0)
|
||||||
|
|
||||||
return testUserData{
|
return testUserData{
|
||||||
opAccounts[0],
|
opAccounts,
|
||||||
watchAccounts[0],
|
watchAccounts,
|
||||||
conf.HashedPassword,
|
conf.HashedPassword,
|
||||||
eventQueue,
|
eventQueue,
|
||||||
}, func() {
|
}, func() {
|
||||||
|
@ -49,8 +53,8 @@ func setupAccountsAndTransactions(t *testing.T) (td testUserData, close func())
|
||||||
// sendTransaction generates multi_transactions and pending entries then it creates and publishes a transaction
|
// sendTransaction generates multi_transactions and pending entries then it creates and publishes a transaction
|
||||||
func sendTransaction(t *testing.T, td testUserData) {
|
func sendTransaction(t *testing.T, td testUserData) {
|
||||||
mTCommand := transfer.MultiTransactionCommand{
|
mTCommand := transfer.MultiTransactionCommand{
|
||||||
FromAddress: common.Address(td.sender.Address),
|
FromAddress: common.Address(td.operableAccounts[0].Address),
|
||||||
ToAddress: common.Address(td.recipient.Address),
|
ToAddress: common.Address(td.watchAccounts[0].Address),
|
||||||
FromAsset: "ETH",
|
FromAsset: "ETH",
|
||||||
ToAsset: "ETH",
|
ToAsset: "ETH",
|
||||||
FromAmount: (*hexutil.Big)(new(big.Int).SetUint64(100000)),
|
FromAmount: (*hexutil.Big)(new(big.Int).SetUint64(100000)),
|
||||||
|
@ -61,8 +65,8 @@ func sendTransaction(t *testing.T, td testUserData) {
|
||||||
BridgeName: "Transfer",
|
BridgeName: "Transfer",
|
||||||
ChainID: 5,
|
ChainID: 5,
|
||||||
TransferTx: &transactions.SendTxArgs{
|
TransferTx: &transactions.SendTxArgs{
|
||||||
From: td.sender.Address,
|
From: td.operableAccounts[0].Address,
|
||||||
To: &td.recipient.Address,
|
To: &td.watchAccounts[0].Address,
|
||||||
Value: (*hexutil.Big)(new(big.Int).Set(mTCommand.FromAmount.ToInt())),
|
Value: (*hexutil.Big)(new(big.Int).Set(mTCommand.FromAmount.ToInt())),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
@ -45,10 +45,10 @@ func TestPendingTx_NotificationStatus(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Start history download ...
|
// Start history download ...
|
||||||
_, err = helpers.CallPrivateMethod("wallet_checkRecentHistoryForChainIDs", []interface{}{[]uint64{5}, []types.Address{td.sender.Address, td.recipient.Address}})
|
_, err = helpers.CallPrivateMethod("wallet_checkRecentHistoryForChainIDs", []interface{}{[]uint64{5}, []types.Address{td.operableAccounts[0].Address, td.watchAccounts[0].Address}})
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
downloadDoneFn := helpers.WaitForTxDownloaderToFinishForAccountsCondition(t, []eth.Address{eth.Address(td.sender.Address), eth.Address(td.recipient.Address)})
|
downloadDoneFn := helpers.WaitForTxDownloaderToFinishForAccountsCondition(t, []eth.Address{eth.Address(td.operableAccounts[0].Address), eth.Address(td.watchAccounts[0].Address)})
|
||||||
|
|
||||||
// ... and wait for the new transaction download to trigger deletion from pending_transactions
|
// ... and wait for the new transaction download to trigger deletion from pending_transactions
|
||||||
_, err = helpers.WaitForWalletEventsWithOptionals(
|
_, err = helpers.WaitForWalletEventsWithOptionals(
|
||||||
|
|
|
@ -0,0 +1,39 @@
|
||||||
|
// 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 (
|
||||||
|
"math/big"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/ethereum/go-ethereum/common"
|
||||||
|
"github.com/ethereum/go-ethereum/common/hexutil"
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
|
"github.com/status-im/status-desktop/test/status-go/integration/helpers"
|
||||||
|
|
||||||
|
"github.com/status-im/status-go/services/wallet"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestSendTransaction_Collectible(t *testing.T) {
|
||||||
|
_, close := setupAccountsAndTransactions(t)
|
||||||
|
defer close()
|
||||||
|
|
||||||
|
payload := []interface{}{
|
||||||
|
wallet.ERC721Transfer,
|
||||||
|
common.HexToAddress("0xe2d622c817878da5143bbe06866ca8e35273ba8a"), /*accountFrom*/
|
||||||
|
common.HexToAddress("0xbd54a96c0ae19a220c8e1234f54c940dfab34639"), /*accountTo*/
|
||||||
|
(*hexutil.Big)(big.NewInt(1)), /*amount*/
|
||||||
|
"0x9f64932be34d5d897c4253d17707b50921f372b6:28", /*tokenID*/
|
||||||
|
[]uint64{11155420, 421614}, /*disabledFromChainIDs*/
|
||||||
|
[]uint64{11155420, 421614}, /*disabledToChainIDs*/
|
||||||
|
[]uint64{11155111}, /*preferredChainIDs*/
|
||||||
|
wallet.GasFeeMedium,
|
||||||
|
map[uint64]*hexutil.Big{}, /*fromLockedAmount*/
|
||||||
|
}
|
||||||
|
//res, err := helpers.CallPrivateMethodAndGetTWithTimeout[wallet.SuggestedRoutes]("wallet_getSuggestedRoutes", payload¸, 10000*time.Minute)
|
||||||
|
res, err := helpers.CallPrivateMethodAndGetT[wallet.SuggestedRoutes]("wallet_getSuggestedRoutes", payload)
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.Greater(t, len(res.Candidates), 0)
|
||||||
|
}
|
Loading…
Reference in New Issue