Skip to content

Commit

Permalink
Adjust
Browse files Browse the repository at this point in the history
  • Loading branch information
davidcauchi committed Nov 11, 2024
1 parent b94c390 commit 0bc53b6
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 15 deletions.
2 changes: 1 addition & 1 deletion lib/config/testconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ func (c *TestConfig) ReadFromEnvVar() error {
c.Network.RpcHttpUrls = rpcHttpUrls
}

if !c.Network.ForceHttp {
if !c.Network.ForceHttp || !c.Seth.ForceHTTP {
rpcWsUrls := ReadEnvVarGroupedMap(E2E_TEST_RPC_WS_URL_ENV, E2E_TEST_RPC_WS_URLS_ENV)
if len(rpcWsUrls) > 0 {
if c.Network == nil {
Expand Down
16 changes: 7 additions & 9 deletions lib/networks/known_networks.go
Original file line number Diff line number Diff line change
Expand Up @@ -1104,8 +1104,8 @@ func SetNetworks(networkCfg config.NetworkConfig) ([]blockchain.EVMNetwork, erro
// if network is not simulated or forked, use the rpc urls and wallet keys from config
if !strings.Contains(networkName, "SIMULATED") && !forked {
var ok bool

if !networkCfg.ForceHttp {
// If we are forcinf htto but also have WSs available add them in case we need them
if !networkCfg.ForceHttp || (networkCfg.RpcWsUrls[selectedNetworks[i]] != nil && len(networkCfg.RpcWsUrls[selectedNetworks[i]]) > 0) {
wsUrls, ok = networkCfg.RpcWsUrls[selectedNetworks[i]]
if !ok {
return nil, fmt.Errorf("no rpc ws urls found in config for '%s' network", selectedNetworks[i])
Expand All @@ -1125,7 +1125,7 @@ func SetNetworks(networkCfg config.NetworkConfig) ([]blockchain.EVMNetwork, erro
// if evm_network config is found, use it
if networkCfg.EVMNetworks != nil {
if network, ok := networkCfg.EVMNetworks[networkName]; ok && network != nil {
if err := NewEVMNetwork(network, walletKeys, httpUrls, wsUrls, networkCfg.ForceHttp); err != nil {
if err := NewEVMNetwork(network, walletKeys, httpUrls, wsUrls); err != nil {
return nil, err
}
networks = append(networks, *network)
Expand All @@ -1134,7 +1134,7 @@ func SetNetworks(networkCfg config.NetworkConfig) ([]blockchain.EVMNetwork, erro
}
// if there is no evm_network config, use the known networks to find the network config from the map
if knownNetwork, valid := MappedNetworks[networkName]; valid {
err := NewEVMNetwork(&knownNetwork, walletKeys, httpUrls, wsUrls, networkCfg.ForceHttp)
err := NewEVMNetwork(&knownNetwork, walletKeys, httpUrls, wsUrls)
if err != nil {
return nil, err
}
Expand All @@ -1152,14 +1152,12 @@ func SetNetworks(networkCfg config.NetworkConfig) ([]blockchain.EVMNetwork, erro
}

// NewEVMNetwork sets the network's private key(s) and rpc urls
func NewEVMNetwork(network *blockchain.EVMNetwork, walletKeys, httpUrls, wsUrls []string, forceHttp bool) error {
func NewEVMNetwork(network *blockchain.EVMNetwork, walletKeys, httpUrls, wsUrls []string) error {
if len(httpUrls) > 0 {
network.HTTPURLs = httpUrls
}
if !forceHttp {
if len(wsUrls) > 0 {
network.URLs = wsUrls
}
if len(wsUrls) > 0 {
network.URLs = wsUrls
}
if len(walletKeys) > 0 {
if err := setKeys(network, walletKeys); err != nil {
Expand Down
5 changes: 2 additions & 3 deletions lib/networks/known_networks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func TestNewEVMNetwork(t *testing.T) {

t.Run("valid networkKey", func(t *testing.T) {
network := MappedNetworks["VALID_KEY"]
err := NewEVMNetwork(&network, nil, nil, nil, false)
err := NewEVMNetwork(&network, nil, nil, nil)
require.NoError(t, err)
require.Equal(t, MappedNetworks["VALID_KEY"].HTTPURLs, network.HTTPURLs)
require.Equal(t, MappedNetworks["VALID_KEY"].URLs, network.URLs)
Expand All @@ -50,8 +50,7 @@ func TestNewEVMNetwork(t *testing.T) {
httpUrls := []string{"http://newurl.com"}
wsUrls := []string{"ws://newwsurl.com"}
network := MappedNetworks["VALID_KEY"]
forceHttp := true
err := NewEVMNetwork(&network, walletKeys, httpUrls, wsUrls, forceHttp)
err := NewEVMNetwork(&network, walletKeys, httpUrls, wsUrls)
require.NoError(t, err)
require.Equal(t, httpUrls, network.HTTPURLs)
require.Equal(t, wsUrls, network.URLs)
Expand Down
4 changes: 2 additions & 2 deletions lib/utils/seth/seth.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,10 +174,10 @@ func MergeSethAndEvmNetworkConfigs(evmNetwork blockchain.EVMNetwork, sethConfig
break
} else if isSameNetwork(conf, evmNetwork) {
conf.PrivateKeys = evmNetwork.PrivateKeys
// forceHttp should override urlssecret
if sethConfig.ForceHTTP {
conf.URLs = evmNetwork.HTTPURLs
} else if len(conf.URLs) == 0 {
}
if len(conf.URLs) == 0 {
conf.URLs = evmNetwork.URLs
}

Expand Down

0 comments on commit 0bc53b6

Please sign in to comment.