Skip to content

Commit

Permalink
Fixing foundry export data logic and add test (#993)
Browse files Browse the repository at this point in the history
  • Loading branch information
AnieeG authored Jun 17, 2024
1 parent b7cb200 commit b5e0217
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 8 deletions.
11 changes: 11 additions & 0 deletions k8s/e2e/common/test_common.go
Original file line number Diff line number Diff line change
Expand Up @@ -462,3 +462,14 @@ func TestReallyLongLogs(t *testing.T) {
// this shouldn't hang
l.Info().Int("len", len(s)).Str("string", s).Msg("string")
}

func TestAnvil(t *testing.T) {
t.Parallel()
testEnvConfig := GetTestEnvConfig(t)
e := presets.FoundryNetwork(testEnvConfig)
err := e.Run()
require.NoError(t, err)
t.Cleanup(func() {
assert.NoError(t, e.Shutdown())
})
}
4 changes: 4 additions & 0 deletions k8s/e2e/local-runner/envs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,7 @@ func TestRunTimeout(t *testing.T) {
func TestReallyLongLogs(t *testing.T) {
common.TestReallyLongLogs(t)
}

func TestWithAnvil(t *testing.T) {
common.TestAnvil(t)
}
4 changes: 4 additions & 0 deletions k8s/e2e/remote-runner/remote_runner_envs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,3 +189,7 @@ func TestRunTimeout(t *testing.T) {
func TestReallyLongLogs(t *testing.T) {
common.TestReallyLongLogs(t)
}

func TestWithAnvil(t *testing.T) {
common.TestAnvil(t)
}
29 changes: 21 additions & 8 deletions k8s/pkg/helm/foundry/foundry.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ const (
)

type Props struct {
Values map[string]interface{}
NetworkName string
Values map[string]interface{}
}

type Chart struct {
Expand Down Expand Up @@ -74,6 +75,15 @@ func (m *Chart) ExportData(e *environment.Environment) error {
e.URLs[appInstance+"_forwarded_ws"] = []string{m.ForwardedWSURL}
e.URLs[appInstance+"_forwarded_http"] = []string{m.ForwardedHTTPURL}

// This is required for blockchain.EVMClient to work
if e.Cfg.InsideK8s {
e.URLs[m.Props.NetworkName] = []string{m.ClusterWSURL}
e.URLs[m.Props.NetworkName+"_http"] = []string{m.ClusterHTTPURL}
} else {
e.URLs[m.Props.NetworkName] = []string{m.ForwardedWSURL}
e.URLs[m.Props.NetworkName+"_http"] = []string{m.ForwardedHTTPURL}
}

for k, v := range e.URLs {
if strings.Contains(k, appInstance) {
log.Info().Str("Name", k).Strs("URLs", v).Msg("Anvil URLs")
Expand All @@ -87,14 +97,14 @@ func defaultProps() *Props {
return &Props{
Values: map[string]any{
"replicaCount": "1",
// default values for anvil
// these can be overridden by setting the values in the Props struct
// Try not to provide any fork config here, so that by default anvil can be used for non-forked chains as well
"anvil": map[string]any{
"host": "0.0.0.0",
"port": "8545",
"blockTime": 1,
"forkRetries": "5",
"forkTimeout": "45000",
"forkComputeUnitsPerSecond": "330",
"chainId": "1337",
"host": "0.0.0.0",
"port": "8545",
"blockTime": 1,
"chainId": "1337",
},
},
}
Expand All @@ -107,6 +117,9 @@ func New(props *Props) *Chart {
// NewVersioned enables choosing a specific helm chart version
func NewVersioned(helmVersion string, props *Props) *Chart {
dp := defaultProps()
if props == nil {
props = &Props{}
}
config.MustMerge(dp, props)
config.MustMerge(&dp.Values, props.Values)
var name string
Expand Down
10 changes: 10 additions & 0 deletions k8s/presets/presets.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"github.com/smartcontractkit/chainlink-testing-framework/k8s/pkg/cdk8s/blockscout"
"github.com/smartcontractkit/chainlink-testing-framework/k8s/pkg/helm/chainlink"
"github.com/smartcontractkit/chainlink-testing-framework/k8s/pkg/helm/ethereum"
"github.com/smartcontractkit/chainlink-testing-framework/k8s/pkg/helm/foundry"
"github.com/smartcontractkit/chainlink-testing-framework/k8s/pkg/helm/mockserver"
mockservercfg "github.com/smartcontractkit/chainlink-testing-framework/k8s/pkg/helm/mockserver-cfg"
"github.com/smartcontractkit/chainlink-testing-framework/k8s/pkg/helm/reorg"
Expand Down Expand Up @@ -225,3 +226,12 @@ func EVMSoak(config *environment.Config) *environment.Environment {
},
}))
}

func FoundryNetwork(config *environment.Config) *environment.Environment {
return environment.New(config).
AddHelm(foundry.New(&foundry.Props{
Values: map[string]interface{}{
"fullnameOverride": "foundry",
},
}))
}

0 comments on commit b5e0217

Please sign in to comment.