2023-04-25 12:00:17 +00:00
|
|
|
package api
|
|
|
|
|
|
|
|
import (
|
|
|
|
"strings"
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
|
|
|
|
"github.com/status-im/status-go/protocol/requests"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestBuildDefaultNetworks(t *testing.T) {
|
2024-01-11 15:48:40 +00:00
|
|
|
poktToken := "grove-token"
|
2023-04-25 12:00:17 +00:00
|
|
|
infuraToken := "infura-token"
|
2024-08-14 15:35:48 +00:00
|
|
|
stageName := "fast-n-bulbous"
|
2023-04-25 12:00:17 +00:00
|
|
|
request := &requests.CreateAccount{
|
2023-05-24 15:02:53 +00:00
|
|
|
WalletSecretsConfig: requests.WalletSecretsConfig{
|
2024-08-14 15:35:48 +00:00
|
|
|
PoktToken: poktToken,
|
|
|
|
InfuraToken: infuraToken,
|
|
|
|
StatusProxyStageName: stageName,
|
2023-05-24 15:02:53 +00:00
|
|
|
},
|
2023-04-25 12:00:17 +00:00
|
|
|
}
|
|
|
|
|
2024-04-22 12:33:23 +00:00
|
|
|
actualNetworks := BuildDefaultNetworks(&request.WalletSecretsConfig)
|
2023-04-25 12:00:17 +00:00
|
|
|
|
2024-02-02 13:55:46 +00:00
|
|
|
require.Len(t, actualNetworks, 9)
|
2023-04-25 12:00:17 +00:00
|
|
|
|
|
|
|
require.Equal(t, mainnetChainID, actualNetworks[0].ChainID)
|
|
|
|
|
|
|
|
require.True(t, strings.Contains(actualNetworks[0].RPCURL, poktToken))
|
|
|
|
require.True(t, strings.Contains(actualNetworks[0].FallbackURL, infuraToken))
|
2024-08-14 15:35:48 +00:00
|
|
|
require.True(t, strings.Contains(actualNetworks[0].DefaultRPCURL, stageName))
|
|
|
|
require.True(t, strings.Contains(actualNetworks[0].DefaultFallbackURL, stageName))
|
2024-10-02 08:20:03 +00:00
|
|
|
require.True(t, strings.Contains(actualNetworks[0].DefaultFallbackURL2, stageName))
|
2023-04-25 12:00:17 +00:00
|
|
|
|
|
|
|
require.Equal(t, goerliChainID, actualNetworks[1].ChainID)
|
|
|
|
|
2024-03-06 09:53:32 +00:00
|
|
|
require.True(t, strings.Contains(actualNetworks[1].RPCURL, infuraToken))
|
2023-04-25 12:00:17 +00:00
|
|
|
|
2024-02-02 13:55:46 +00:00
|
|
|
require.Equal(t, sepoliaChainID, actualNetworks[2].ChainID)
|
2023-04-25 12:00:17 +00:00
|
|
|
|
2024-05-08 09:03:52 +00:00
|
|
|
require.True(t, strings.Contains(actualNetworks[2].RPCURL, poktToken))
|
|
|
|
require.True(t, strings.Contains(actualNetworks[2].FallbackURL, infuraToken))
|
2024-08-14 15:35:48 +00:00
|
|
|
require.True(t, strings.Contains(actualNetworks[2].DefaultRPCURL, stageName))
|
|
|
|
require.True(t, strings.Contains(actualNetworks[2].DefaultFallbackURL, stageName))
|
2024-10-02 08:20:03 +00:00
|
|
|
require.True(t, strings.Contains(actualNetworks[2].DefaultFallbackURL2, stageName))
|
2023-04-25 12:00:17 +00:00
|
|
|
|
2024-02-02 13:55:46 +00:00
|
|
|
require.Equal(t, optimismChainID, actualNetworks[3].ChainID)
|
2023-04-25 12:00:17 +00:00
|
|
|
|
2024-02-02 13:55:46 +00:00
|
|
|
require.True(t, strings.Contains(actualNetworks[3].RPCURL, poktToken))
|
|
|
|
require.True(t, strings.Contains(actualNetworks[3].FallbackURL, infuraToken))
|
2024-08-14 15:35:48 +00:00
|
|
|
require.True(t, strings.Contains(actualNetworks[3].DefaultRPCURL, stageName))
|
|
|
|
require.True(t, strings.Contains(actualNetworks[3].DefaultFallbackURL, stageName))
|
2024-10-02 08:20:03 +00:00
|
|
|
require.True(t, strings.Contains(actualNetworks[3].DefaultFallbackURL2, stageName))
|
2023-04-25 12:00:17 +00:00
|
|
|
|
2024-02-02 13:55:46 +00:00
|
|
|
require.Equal(t, optimismGoerliChainID, actualNetworks[4].ChainID)
|
2023-04-25 12:00:17 +00:00
|
|
|
|
2024-02-02 13:55:46 +00:00
|
|
|
require.True(t, strings.Contains(actualNetworks[4].RPCURL, infuraToken))
|
|
|
|
require.Equal(t, "", actualNetworks[4].FallbackURL)
|
2023-04-25 12:00:17 +00:00
|
|
|
|
2024-02-02 13:55:46 +00:00
|
|
|
require.Equal(t, optimismSepoliaChainID, actualNetworks[5].ChainID)
|
2023-04-25 12:00:17 +00:00
|
|
|
|
2024-05-07 11:57:36 +00:00
|
|
|
require.True(t, strings.Contains(actualNetworks[5].RPCURL, poktToken))
|
|
|
|
require.True(t, strings.Contains(actualNetworks[5].FallbackURL, infuraToken))
|
2024-08-14 15:35:48 +00:00
|
|
|
require.True(t, strings.Contains(actualNetworks[5].DefaultRPCURL, stageName))
|
|
|
|
require.True(t, strings.Contains(actualNetworks[5].DefaultFallbackURL, stageName))
|
2024-10-02 08:20:03 +00:00
|
|
|
require.True(t, strings.Contains(actualNetworks[5].DefaultFallbackURL2, stageName))
|
2024-02-02 13:55:46 +00:00
|
|
|
|
|
|
|
require.Equal(t, arbitrumChainID, actualNetworks[6].ChainID)
|
|
|
|
|
|
|
|
require.True(t, strings.Contains(actualNetworks[6].RPCURL, poktToken))
|
|
|
|
require.True(t, strings.Contains(actualNetworks[6].FallbackURL, infuraToken))
|
2024-08-14 15:35:48 +00:00
|
|
|
require.True(t, strings.Contains(actualNetworks[6].DefaultRPCURL, stageName))
|
|
|
|
require.True(t, strings.Contains(actualNetworks[6].DefaultFallbackURL, stageName))
|
2024-10-02 08:20:03 +00:00
|
|
|
require.True(t, strings.Contains(actualNetworks[6].DefaultFallbackURL2, stageName))
|
2024-02-02 13:55:46 +00:00
|
|
|
|
|
|
|
require.Equal(t, arbitrumGoerliChainID, actualNetworks[7].ChainID)
|
|
|
|
|
|
|
|
require.True(t, strings.Contains(actualNetworks[7].RPCURL, infuraToken))
|
|
|
|
require.Equal(t, "", actualNetworks[7].FallbackURL)
|
|
|
|
|
|
|
|
require.Equal(t, arbitrumSepoliaChainID, actualNetworks[8].ChainID)
|
|
|
|
|
2024-05-07 11:57:36 +00:00
|
|
|
require.True(t, strings.Contains(actualNetworks[8].RPCURL, poktToken))
|
|
|
|
require.True(t, strings.Contains(actualNetworks[8].FallbackURL, infuraToken))
|
2024-08-14 15:35:48 +00:00
|
|
|
require.True(t, strings.Contains(actualNetworks[8].DefaultRPCURL, stageName))
|
|
|
|
require.True(t, strings.Contains(actualNetworks[8].DefaultFallbackURL, stageName))
|
2024-10-02 08:20:03 +00:00
|
|
|
require.True(t, strings.Contains(actualNetworks[8].DefaultFallbackURL2, stageName))
|
2024-08-14 15:35:48 +00:00
|
|
|
|
2023-04-25 12:00:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestBuildDefaultNetworksGanache(t *testing.T) {
|
|
|
|
ganacheURL := "ganacheurl"
|
|
|
|
request := &requests.CreateAccount{
|
2023-05-24 15:02:53 +00:00
|
|
|
WalletSecretsConfig: requests.WalletSecretsConfig{
|
|
|
|
GanacheURL: ganacheURL,
|
|
|
|
},
|
2023-04-25 12:00:17 +00:00
|
|
|
}
|
|
|
|
|
2024-04-22 12:33:23 +00:00
|
|
|
actualNetworks := BuildDefaultNetworks(&request.WalletSecretsConfig)
|
2023-04-25 12:00:17 +00:00
|
|
|
|
2024-02-02 13:55:46 +00:00
|
|
|
require.Len(t, actualNetworks, 9)
|
2023-04-25 12:00:17 +00:00
|
|
|
|
|
|
|
for _, n := range actualNetworks {
|
|
|
|
require.True(t, strings.Contains(n.RPCURL, ganacheURL))
|
|
|
|
require.True(t, strings.Contains(n.FallbackURL, ganacheURL))
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
require.Equal(t, mainnetChainID, actualNetworks[0].ChainID)
|
|
|
|
|
|
|
|
require.NotNil(t, actualNetworks[0].TokenOverrides)
|
|
|
|
require.Len(t, actualNetworks[0].TokenOverrides, 1)
|
|
|
|
require.Equal(t, sntSymbol, actualNetworks[0].TokenOverrides[0].Symbol)
|
|
|
|
require.Equal(t, ganacheTokenAddress, actualNetworks[0].TokenOverrides[0].Address)
|
|
|
|
|
|
|
|
require.Equal(t, goerliChainID, actualNetworks[1].ChainID)
|
|
|
|
|
|
|
|
require.NotNil(t, actualNetworks[1].TokenOverrides)
|
|
|
|
require.Len(t, actualNetworks[1].TokenOverrides, 1)
|
|
|
|
require.Equal(t, sttSymbol, actualNetworks[1].TokenOverrides[0].Symbol)
|
|
|
|
require.Equal(t, ganacheTokenAddress, actualNetworks[1].TokenOverrides[0].Address)
|
|
|
|
|
|
|
|
}
|