Skip to content

Second branch #1663

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 20 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion cmd/firefly.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ func init() {
}

func resetConfig() {
coreconfig.Reset()
namespace.InitConfig()
apiserver.InitConfig()
}
Expand Down
1 change: 0 additions & 1 deletion doc-site/config_docs_generate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ import (

func TestGenerateConfigDocs(t *testing.T) {
// Initialize config of all plugins
coreconfig.Reset()
namespace.InitConfig()
apiserver.InitConfig()
f, err := os.Create(filepath.Join("docs", "reference", "config.md"))
Expand Down
1 change: 0 additions & 1 deletion doc-site/config_docs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ import (

func TestConfigDocsUpToDate(t *testing.T) {
// Initialize config of all plugins
coreconfig.Reset()
namespace.InitConfig()
apiserver.InitConfig()
generatedConfig, err := config.GenerateConfigMarkdown(context.Background(), configDocHeader, config.GetKnownKeys())
Expand Down
4 changes: 4 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ require (
github.com/golang-migrate/migrate/v4 v4.17.0
github.com/gorilla/mux v1.8.1
github.com/gorilla/websocket v1.5.1
<<<<<<< HEAD
github.com/hyperledger/firefly-common v1.4.14
=======
github.com/hyperledger/firefly-common v1.4.15
>>>>>>> b4d7987111328448ef17752c2785b42fb31c8478
github.com/hyperledger/firefly-signer v1.1.19
github.com/jarcoal/httpmock v1.2.0
github.com/lib/pq v1.10.9
Expand Down
7 changes: 0 additions & 7 deletions internal/apiserver/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ import (
const configDir = "../../test/data/config"

func newTestServer() (*namespacemocks.Manager, *orchestratormocks.Orchestrator, *apiServer) {
coreconfig.Reset()
InitConfig()
mgr := &namespacemocks.Manager{}
o := &orchestratormocks.Orchestrator{}
Expand Down Expand Up @@ -81,7 +80,6 @@ func newTestSPIServer() (*orchestratormocks.Orchestrator, *mux.Router) {
}

func TestStartStopServer(t *testing.T) {
coreconfig.Reset()
metrics.Clear()
InitConfig()
apiConfig.Set(httpserver.HTTPConfPort, 0)
Expand All @@ -100,7 +98,6 @@ func TestStartStopServer(t *testing.T) {
}

func TestStartLegacyAdminConfig(t *testing.T) {
coreconfig.Reset()
metrics.Clear()
InitConfig()
apiConfig.Set(httpserver.HTTPConfPort, 0)
Expand All @@ -119,7 +116,6 @@ func TestStartLegacyAdminConfig(t *testing.T) {
}

func TestStartAPIFail(t *testing.T) {
coreconfig.Reset()
metrics.Clear()
InitConfig()
apiConfig.Set(httpserver.HTTPConfAddress, "...://")
Expand All @@ -132,7 +128,6 @@ func TestStartAPIFail(t *testing.T) {
}

func TestStartAdminFail(t *testing.T) {
coreconfig.Reset()
metrics.Clear()
InitConfig()
spiConfig.Set(httpserver.HTTPConfAddress, "...://")
Expand All @@ -148,7 +143,6 @@ func TestStartAdminFail(t *testing.T) {
}

func TestStartAdminWSHandler(t *testing.T) {
coreconfig.Reset()
metrics.Clear()
InitConfig()
spiConfig.Set(httpserver.HTTPConfAddress, "...://")
Expand All @@ -167,7 +161,6 @@ func TestStartAdminWSHandler(t *testing.T) {
}

func TestStartMetricsFail(t *testing.T) {
coreconfig.Reset()
metrics.Clear()
InitConfig()
monitoringConfig.Set(httpserver.HTTPConfAddress, "...://")
Expand Down
1 change: 0 additions & 1 deletion internal/apiserver/swagger_check_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ import (
)

func TestDiffSwaggerYAML(t *testing.T) {
coreconfig.Reset()
config.Set(coreconfig.APIOASPanicOnMissingDescription, true)
as := &apiServer{}
hf := as.handlerFactory()
Expand Down
1 change: 0 additions & 1 deletion internal/apiserver/swagger_generate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ import (
)

func TestDownloadSwaggerYAML(t *testing.T) {
coreconfig.Reset()
config.Set(coreconfig.APIOASPanicOnMissingDescription, true)
as := &apiServer{}
hf := as.handlerFactory()
Expand Down
5 changes: 0 additions & 5 deletions internal/assets/manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ func newTestAssetsWithMetrics(t *testing.T) (*assetManager, func()) {
}

func newTestAssetsCommon(t *testing.T, metrics bool) (*assetManager, func()) {
coreconfig.Reset()
mdi := &databasemocks.Plugin{}
mim := &identitymanagermocks.Manager{}
mdm := &datamocks.Manager{}
Expand Down Expand Up @@ -91,7 +90,6 @@ func TestInitFail(t *testing.T) {

func TestCacheInitFail(t *testing.T) {
cacheInitError := errors.New("Initialization error.")
coreconfig.Reset()
mdi := &databasemocks.Plugin{}
mdm := &datamocks.Manager{}
mim := &identitymanagermocks.Manager{}
Expand Down Expand Up @@ -163,7 +161,6 @@ func TestGetTokenConnectors(t *testing.T) {
}

func TestStart(t *testing.T) {
coreconfig.Reset()
mdi := &databasemocks.Plugin{}
mdm := &datamocks.Manager{}
mim := &identitymanagermocks.Manager{}
Expand Down Expand Up @@ -193,7 +190,6 @@ func TestStart(t *testing.T) {
}

func TestStartDBError(t *testing.T) {
coreconfig.Reset()
mdi := &databasemocks.Plugin{}
mdm := &datamocks.Manager{}
mim := &identitymanagermocks.Manager{}
Expand All @@ -216,7 +212,6 @@ func TestStartDBError(t *testing.T) {
}

func TestStartError(t *testing.T) {
coreconfig.Reset()
mdi := &databasemocks.Plugin{}
mdm := &datamocks.Manager{}
mim := &identitymanagermocks.Manager{}
Expand Down
1 change: 0 additions & 1 deletion internal/batch/batch_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ import (
)

func testConfigReset() {
coreconfig.Reset()
config.Set(coreconfig.BatchManagerMinimumPollDelay, "0")
log.SetLevel("debug")
}
Expand Down
7 changes: 0 additions & 7 deletions internal/batch/batch_processor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ func (tce *testConflictError) IsConflictError() bool {

func TestUnfilledBatch(t *testing.T) {
log.SetLevel("debug")
coreconfig.Reset()

dispatched := make(chan *DispatchPayload)
cancel, mdi, bp := newTestBatchProcessor(t, func(c context.Context, state *DispatchPayload) error {
Expand Down Expand Up @@ -154,7 +153,6 @@ func TestHandleDispatchConflictError(t *testing.T) {

func TestBatchSizeOverflow(t *testing.T) {
log.SetLevel("debug")
coreconfig.Reset()

dispatched := make(chan *DispatchPayload)
cancel, mdi, bp := newTestBatchProcessor(t, func(c context.Context, state *DispatchPayload) error {
Expand Down Expand Up @@ -553,7 +551,6 @@ func TestStartQuiesceNonBlocking(t *testing.T) {

func TestMarkMessageDispatchedUnpinnedOK(t *testing.T) {
log.SetLevel("debug")
coreconfig.Reset()

dispatched := make(chan *DispatchPayload)
cancel, mdi, bp := newTestBatchProcessor(t, func(c context.Context, state *DispatchPayload) error {
Expand Down Expand Up @@ -611,7 +608,6 @@ func TestMarkMessageDispatchedUnpinnedOK(t *testing.T) {

func TestMaskContextsRetryAfterPinsAssigned(t *testing.T) {
log.SetLevel("debug")
coreconfig.Reset()

dispatched := make(chan *DispatchPayload)
cancel, mdi, bp := newTestBatchProcessor(t, func(c context.Context, state *DispatchPayload) error {
Expand Down Expand Up @@ -681,7 +677,6 @@ func TestMaskContextsRetryAfterPinsAssigned(t *testing.T) {

func TestMaskContextsUpdateMessageFail(t *testing.T) {
log.SetLevel("debug")
coreconfig.Reset()

dispatched := make(chan *DispatchPayload)
cancel, mdi, bp := newTestBatchProcessor(t, func(c context.Context, state *DispatchPayload) error {
Expand Down Expand Up @@ -720,7 +715,6 @@ func TestMaskContextsUpdateMessageFail(t *testing.T) {
}

func TestSealBatchTXAlreadyAssigned(t *testing.T) {
coreconfig.Reset()

dispatched := make(chan *DispatchPayload)
cancel, mdi, bp := newTestBatchProcessor(t, func(c context.Context, state *DispatchPayload) error {
Expand Down Expand Up @@ -831,7 +825,6 @@ func TestCalculateContextsLoadPinsFail(t *testing.T) {

func TestBigBatchEstimate(t *testing.T) {
log.SetLevel("debug")
coreconfig.Reset()

bd := []byte(`{
"id": "37ba893b-fcfa-4cf9-8ce8-34cd8bc9bc72",
Expand Down
1 change: 0 additions & 1 deletion internal/blockchain/ethereum/address_resolver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ import (
)

func utAddresResolverConfig() config.Section {
coreconfig.Reset()
config := config.RootSection("utaddressresovler")
(&Ethereum{}).InitConfig(config)
return config.SubSection(AddressResolverConfigKey)
Expand Down
1 change: 0 additions & 1 deletion internal/blockchain/ethereum/ethereum_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ func testFFIErrors() []*fftypes.FFIError {
}

func resetConf(e *Ethereum) {
coreconfig.Reset()
e.InitConfig(utConfig)
}

Expand Down
1 change: 0 additions & 1 deletion internal/blockchain/fabric/fabric_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ var (
)

func resetConf(e *Fabric) {
coreconfig.Reset()
e.InitConfig(utConfig)
}

Expand Down
1 change: 0 additions & 1 deletion internal/blockchain/tezos/address_resolver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ import (
)

func utAddresResolverConfig() config.Section {
coreconfig.Reset()
config := config.RootSection("utaddressresovler")
(&Tezos{}).InitConfig(config)
return config.SubSection(AddressResolverConfigKey)
Expand Down
1 change: 0 additions & 1 deletion internal/blockchain/tezos/tezos_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ func testFFIMethod() *fftypes.FFIMethod {
}

func resetConf(t *Tezos) {
coreconfig.Reset()
t.InitConfig(utConfig)
}

Expand Down
1 change: 0 additions & 1 deletion internal/broadcast/manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ import (
)

func newTestBroadcastCommon(t *testing.T, metricsEnabled bool) (*broadcastManager, func()) {
coreconfig.Reset()
mdi := &databasemocks.Plugin{}
mim := &identitymanagermocks.Manager{}
mdm := &datamocks.Manager{}
Expand Down
5 changes: 0 additions & 5 deletions internal/cache/cache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import (
)

func TestNewCacheCreationFail(t *testing.T) {
coreconfig.Reset()
ctx := context.Background()
cacheManager := NewCacheManager(ctx)
_, err := cacheManager.GetCache(NewCacheConfig(ctx, "", "", ""))
Expand All @@ -41,7 +40,6 @@ func TestNewCacheCreationFail(t *testing.T) {
}

func TestGetCacheReturnsSameCacheForSameConfig(t *testing.T) {
coreconfig.Reset()
ctx := context.Background()
cacheManager := NewCacheManager(ctx)
cache0, _ := cacheManager.GetCache(NewCacheConfig(ctx, "cache.batch.limit", "cache.batch.ttl", "testnamespace"))
Expand All @@ -57,7 +55,6 @@ func TestGetCacheReturnsSameCacheForSameConfig(t *testing.T) {
}

func TestTwoSeparateCacheWorksIndependently(t *testing.T) {
coreconfig.Reset()
ctx := context.Background()
cacheManager := NewCacheManager(ctx)
cache0, _ := cacheManager.GetCache(NewCacheConfig(ctx, "cache.batch.limit", "cache.batch.ttl", ""))
Expand All @@ -77,7 +74,6 @@ func TestTwoSeparateCacheWorksIndependently(t *testing.T) {
}

func TestReturnsDummyCacheWhenCacheDisabled(t *testing.T) {
coreconfig.Reset()
config.Set(coreconfig.CacheEnabled, false)
ctx := context.Background()
cacheManager := NewCacheManager(ctx)
Expand All @@ -93,7 +89,6 @@ func TestUmmanagedCacheInstance(t *testing.T) {
}

func TestResetCachesForNamespace(t *testing.T) {
coreconfig.Reset()
ctx := context.Background()
cacheManager := NewCacheManager(ctx)
cacheNS1, _ := cacheManager.GetCache(NewCacheConfig(ctx, "cache.batch.limit", "cache.batch.ttl", "ns1"))
Expand Down
4 changes: 0 additions & 4 deletions internal/coreconfig/coreconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,3 @@ func setDefaults() {
viper.SetDefault(string(CacheTokenPoolLimit), 100)
viper.SetDefault(string(CacheTokenPoolTTL), "1h")
}

func Reset() {
config.RootConfigReset(setDefaults)
}
1 change: 0 additions & 1 deletion internal/coreconfig/coreconfig_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import (
const configDir = "../../test/data/config"

func TestInitConfigOK(t *testing.T) {
Reset()

assert.Equal(t, 25, config.GetInt(APIDefaultFilterLimit))
assert.Equal(t, "localhost", config.GetString(DebugAddress))
Expand Down
5 changes: 0 additions & 5 deletions internal/data/data_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ import (

func TestCacheInitFail(t *testing.T) {
cacheInitError := errors.New("Initialization error.")
coreconfig.Reset()
config.Set(coreconfig.MessageWriterCount, 1)
ctx := context.Background()
mdi := &databasemocks.Plugin{}
Expand Down Expand Up @@ -80,7 +79,6 @@ func TestCacheInitFail(t *testing.T) {
}

func newTestDataManager(t *testing.T) (*dataManager, context.Context, func()) {
coreconfig.Reset()
config.Set(coreconfig.MessageWriterCount, 1)
ctx, cancel := context.WithCancel(context.Background())
mdi := &databasemocks.Plugin{}
Expand Down Expand Up @@ -134,7 +132,6 @@ func testNewMessage() (*fftypes.UUID, *fftypes.Bytes32, *NewMessage) {

func TestValidateE2E(t *testing.T) {

coreconfig.Reset()
dm, ctx, cancel := newTestDataManager(t)
defer cancel()
mdi := dm.database.(*databasemocks.Plugin)
Expand Down Expand Up @@ -281,7 +278,6 @@ func TestInitBadDeps(t *testing.T) {
}

func TestValidatorLookupCached(t *testing.T) {
coreconfig.Reset()
dm, ctx, cancel := newTestDataManager(t)
defer cancel()
mdi := dm.database.(*databasemocks.Plugin)
Expand Down Expand Up @@ -309,7 +305,6 @@ func TestValidatorLookupCached(t *testing.T) {

func TestValidateBadHash(t *testing.T) {

coreconfig.Reset()
dm, ctx, cancel := newTestDataManager(t)
defer cancel()
mdi := dm.database.(*databasemocks.Plugin)
Expand Down
1 change: 0 additions & 1 deletion internal/database/sqlcommon/chart_sql_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,6 @@ func TestGetChartHistogramValidCollectionNameWithTypes(t *testing.T) {

func TestGetChartHistogramValidCollectionNameWithTypesAndCapped(t *testing.T) {
s, mock := newMockProvider().init()
coreconfig.Reset()
config.Set(coreconfig.HistogramsMaxChartRows, 10)
for i := range validCollectionsWithTypes {
mock.ExpectQuery("SELECT .*").WillReturnRows(sqlmock.NewRows([]string{"timestamp", "type"}).
Expand Down
1 change: 0 additions & 1 deletion internal/database/sqlcommon/provider_mock_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ type mockProvider struct {
}

func newMockProvider() *mockProvider {
coreconfig.Reset()
conf := config.RootSection("unittest.db")
conf.AddKnownKey("url", "test")
mp := &mockProvider{
Expand Down
Loading