status-go/api/default_networks_test.go
Michal Iskierko 73a5189398 feat(BridgeMessage): Add new type of chat message content: BridgeMessage
BridgeMessage is a type of chat message content which will be sent from  Matterbridge.
It contains fields:
- bridge name - depends on the used bridge, eg. "discord", "slack", etc...
- user name - username the message was received from
- content - message content
- user avatar
- message id
- parent message id - used in case of replies

Message is saved to a separated table: bridge_messages, similarly to discord messages.
The user_messages table is untouched.
bridge_messages table contains user_messages_id in order to join with user_messages table.

Issue #13098
2024-01-30 12:14:54 +01:00

90 lines
2.8 KiB
Go

package api
import (
"strings"
"testing"
"github.com/stretchr/testify/require"
"github.com/status-im/status-go/protocol/requests"
)
func TestBuildDefaultNetworks(t *testing.T) {
poktToken := "grove-token"
infuraToken := "infura-token"
request := &requests.CreateAccount{
WalletSecretsConfig: requests.WalletSecretsConfig{
PoktToken: poktToken,
InfuraToken: infuraToken,
},
}
actualNetworks := BuildDefaultNetworks(request)
require.Len(t, actualNetworks, 6)
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))
require.Equal(t, goerliChainID, actualNetworks[1].ChainID)
require.True(t, strings.Contains(actualNetworks[1].RPCURL, poktToken))
require.True(t, strings.Contains(actualNetworks[1].FallbackURL, infuraToken))
require.Equal(t, optimismChainID, actualNetworks[2].ChainID)
require.True(t, strings.Contains(actualNetworks[2].RPCURL, poktToken))
require.True(t, strings.Contains(actualNetworks[2].FallbackURL, infuraToken))
require.Equal(t, optimismGoerliChainID, actualNetworks[3].ChainID)
require.True(t, strings.Contains(actualNetworks[3].RPCURL, infuraToken))
require.Equal(t, "", actualNetworks[3].FallbackURL)
require.Equal(t, arbitrumChainID, actualNetworks[4].ChainID)
require.True(t, strings.Contains(actualNetworks[4].RPCURL, poktToken))
require.True(t, strings.Contains(actualNetworks[4].FallbackURL, infuraToken))
require.Equal(t, arbitrumGoerliChainID, actualNetworks[5].ChainID)
require.True(t, strings.Contains(actualNetworks[5].RPCURL, infuraToken))
require.Equal(t, "", actualNetworks[5].FallbackURL)
}
func TestBuildDefaultNetworksGanache(t *testing.T) {
ganacheURL := "ganacheurl"
request := &requests.CreateAccount{
WalletSecretsConfig: requests.WalletSecretsConfig{
GanacheURL: ganacheURL,
},
}
actualNetworks := BuildDefaultNetworks(request)
require.Len(t, actualNetworks, 6)
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)
}