Skip to content

Commit

Permalink
Revert "remove trailing slash in mercury credentials' URLs (#12149)" (#…
Browse files Browse the repository at this point in the history
…12599)

This reverts commit 6fb421d.
  • Loading branch information
shileiwill authored Mar 26, 2024
1 parent 1853cca commit 7292d46
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 56 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"fmt"
"math/big"
"net/http"
"strings"
"sync"
"time"

Expand Down Expand Up @@ -149,9 +148,6 @@ func NewMercuryConfig(credentials *types.MercuryCredentials, abi abi.ABI) *Mercu
}

func (c *MercuryConfig) Credentials() *types.MercuryCredentials {
// remove the trailing slash from the URL if it exists
c.cred.URL = strings.TrimRight(c.cred.URL, "/")
c.cred.LegacyURL = strings.TrimRight(c.cred.LegacyURL, "/")
return c.cred
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,14 @@ import (
"testing"
"time"

"github.com/patrickmn/go-cache"
types2 "github.com/smartcontractkit/chainlink-automation/pkg/v3/types"

"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common"
coreTypes "github.com/ethereum/go-ethereum/core/types"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"

types2 "github.com/smartcontractkit/chainlink-automation/pkg/v3/types"
"github.com/smartcontractkit/chainlink-common/pkg/types"

types3 "github.com/smartcontractkit/chainlink/v2/core/chains/evm/headtracker/types"
"github.com/smartcontractkit/chainlink/v2/core/chains/evm/logpoller"
"github.com/smartcontractkit/chainlink/v2/core/chains/evm/logpoller/mocks"
Expand All @@ -32,54 +29,6 @@ import (
"github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ocr2keeper/evmregistry/v21/logprovider"
)

func TestCredentials_RemoveTrailingSlash(t *testing.T) {
tests := []struct {
Name string
URL string
LegacyURL string
}{
{
Name: "Both have trailing slashes",
URL: "http://example.com/",
LegacyURL: "http://legacy.example.com/",
},
{
Name: "One has trailing slashes",
URL: "http://example.com",
LegacyURL: "http://legacy.example.com/",
},
{
Name: "Neither has trailing slashes",
URL: "http://example.com",
LegacyURL: "http://legacy.example.com",
},
}

for _, test := range tests {
t.Run(test.Name, func(t *testing.T) {
mockConfig := &MercuryConfig{
cred: &types.MercuryCredentials{
URL: test.URL,
LegacyURL: test.LegacyURL,
Username: "user",
Password: "pass",
},
Abi: core.StreamsCompatibleABI,
AllowListCache: cache.New(defaultPluginRetryExpiration, cleanupInterval),
pluginRetryCache: cache.New(defaultPluginRetryExpiration, cleanupInterval),
}

result := mockConfig.Credentials()

// Assert that trailing slashes are removed
assert.Equal(t, "http://example.com", result.URL)
assert.Equal(t, "http://legacy.example.com", result.LegacyURL)
assert.Equal(t, "user", result.Username)
assert.Equal(t, "pass", result.Password)
})
}
}

func TestPollLogs(t *testing.T) {
tests := []struct {
Name string
Expand Down

0 comments on commit 7292d46

Please sign in to comment.