test(wallet) add dev integration tests for ERC1155 route estimator
Used for debugging ERC1155 route estimation issues Updates: #14212
This commit is contained in:
parent
ad0a7d3ba4
commit
7e146d662d
|
@ -7,33 +7,94 @@ import (
|
||||||
"math/big"
|
"math/big"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/common"
|
eth "github.com/ethereum/go-ethereum/common"
|
||||||
"github.com/ethereum/go-ethereum/common/hexutil"
|
"github.com/ethereum/go-ethereum/common/hexutil"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
"github.com/status-im/status-desktop/test/status-go/integration/helpers"
|
"github.com/status-im/status-desktop/test/status-go/integration/helpers"
|
||||||
|
|
||||||
"github.com/status-im/status-go/services/wallet"
|
"github.com/status-im/status-go/services/wallet"
|
||||||
|
"github.com/status-im/status-go/services/wallet/common"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestSendTransaction_Collectible(t *testing.T) {
|
type dataPayload struct {
|
||||||
_, close := setupAccountsAndTransactions(t)
|
transferType wallet.SendType
|
||||||
defer close()
|
accountFrom eth.Address
|
||||||
|
accountTo eth.Address
|
||||||
payload := []interface{}{
|
amount *hexutil.Big
|
||||||
wallet.ERC721Transfer,
|
tokenIdentity string // Format: "<HexTokenAddress>:<TokenID>"
|
||||||
common.HexToAddress("0xe2d622c817878da5143bbe06866ca8e35273ba8a"), /*accountFrom*/
|
disabledFromChainIDs []uint64
|
||||||
common.HexToAddress("0xbd54a96c0ae19a220c8e1234f54c940dfab34639"), /*accountTo*/
|
disabledToChainIDs []uint64
|
||||||
(*hexutil.Big)(big.NewInt(1)), /*amount*/
|
preferredChainIDs []uint64
|
||||||
"0x9f64932be34d5d897c4253d17707b50921f372b6:28", /*tokenID*/
|
gasFeeMode wallet.GasFeeMode
|
||||||
[]uint64{11155420, 421614}, /*disabledFromChainIDs*/
|
fromLockedAmount map[uint64]*hexutil.Big
|
||||||
[]uint64{11155420, 421614}, /*disabledToChainIDs*/
|
}
|
||||||
[]uint64{11155111}, /*preferredChainIDs*/
|
|
||||||
wallet.GasFeeMedium,
|
func dataToCallingPayload(data dataPayload) []interface{} {
|
||||||
map[uint64]*hexutil.Big{}, /*fromLockedAmount*/
|
return []interface{}{
|
||||||
}
|
data.transferType,
|
||||||
//res, err := helpers.CallPrivateMethodAndGetTWithTimeout[wallet.SuggestedRoutes]("wallet_getSuggestedRoutes", payload¸, 10000*time.Minute)
|
data.accountFrom,
|
||||||
res, err := helpers.CallPrivateMethodAndGetT[wallet.SuggestedRoutes]("wallet_getSuggestedRoutes", payload)
|
data.accountTo,
|
||||||
require.NoError(t, err)
|
data.amount,
|
||||||
require.Greater(t, len(res.Candidates), 0)
|
data.tokenIdentity,
|
||||||
|
data.disabledFromChainIDs,
|
||||||
|
data.disabledToChainIDs,
|
||||||
|
data.preferredChainIDs,
|
||||||
|
data.gasFeeMode,
|
||||||
|
data.fromLockedAmount,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func basicPayload() dataPayload {
|
||||||
|
defaultDisabled := []uint64{common.OptimismSepolia, common.ArbitrumSepolia}
|
||||||
|
return dataPayload{
|
||||||
|
transferType: wallet.Transfer,
|
||||||
|
tokenIdentity: "",
|
||||||
|
accountFrom: eth.HexToAddress("0xe2d622c817878da5143bbe06866ca8e35273ba8a"),
|
||||||
|
accountTo: eth.HexToAddress("0xbd54a96c0ae19a220c8e1234f54c940dfab34639"),
|
||||||
|
amount: (*hexutil.Big)(big.NewInt(1)),
|
||||||
|
disabledFromChainIDs: defaultDisabled,
|
||||||
|
disabledToChainIDs: defaultDisabled,
|
||||||
|
preferredChainIDs: []uint64{common.EthereumSepolia},
|
||||||
|
gasFeeMode: wallet.GasFeeMedium,
|
||||||
|
fromLockedAmount: map[uint64]*hexutil.Big{},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func customBasicPayload(transType wallet.SendType, tokenIdentity string) dataPayload {
|
||||||
|
payload := basicPayload()
|
||||||
|
payload.transferType = transType
|
||||||
|
payload.tokenIdentity = tokenIdentity
|
||||||
|
return payload
|
||||||
|
}
|
||||||
|
|
||||||
|
func erc721Payload(tokenIdentity string) dataPayload {
|
||||||
|
return customBasicPayload(wallet.ERC721Transfer, tokenIdentity)
|
||||||
|
}
|
||||||
|
|
||||||
|
func erc1155Payload(tokenIdentity string) dataPayload {
|
||||||
|
return customBasicPayload(wallet.ERC1155Transfer, tokenIdentity)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestSendTransaction_Collectible(t *testing.T) {
|
||||||
|
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
data dataPayload
|
||||||
|
}{
|
||||||
|
{"ERC721", erc721Payload("0x9f64932be34d5d897c4253d17707b50921f372b6:37")},
|
||||||
|
{"ERC1155", erc1155Payload("0x1ed60fedff775d500dde21a974cd4e92e0047cc8:32")},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
_, close := setupAccountsAndTransactions(t)
|
||||||
|
defer close()
|
||||||
|
|
||||||
|
payload := dataToCallingPayload(tt.data)
|
||||||
|
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