-
Notifications
You must be signed in to change notification settings - Fork 476
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add counter metric to already closed guard
- Loading branch information
Showing
3 changed files
with
94 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// Copyright (C) 2019-2023 Algorand, Inc. | ||
// This file is part of go-algorand | ||
// | ||
// go-algorand is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU Affero General Public License as | ||
// published by the Free Software Foundation, either version 3 of the | ||
// License, or (at your option) any later version. | ||
// | ||
// go-algorand is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU Affero General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU Affero General Public License | ||
// along with go-algorand. If not, see <https://www.gnu.org/licenses/>. | ||
|
||
package storetest | ||
|
||
import ( | ||
"fmt" | ||
"strings" | ||
"testing" | ||
|
||
"github.com/algorand/go-algorand/crypto" | ||
"github.com/algorand/go-algorand/logging" | ||
"github.com/algorand/go-algorand/util/db" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
// DbOpenTest opens a db file for testing purposes. | ||
func DbOpenTest(t testing.TB, inMemory bool) (db.Pair, string) { | ||
fn := fmt.Sprintf("%s.%d", strings.ReplaceAll(t.Name(), "/", "."), crypto.RandUint64()) | ||
dbs, err := db.OpenPair(fn, inMemory) | ||
require.NoErrorf(t, err, "Filename : %s\nInMemory: %v", fn, inMemory) | ||
return dbs, fn | ||
} | ||
|
||
// SetDbLogging sets a testing logger on a database. | ||
func SetDbLogging(t testing.TB, dbs db.Pair) { | ||
dblogger := logging.TestingLog(t) | ||
dbs.Rdb.SetLogger(dblogger) | ||
dbs.Wdb.SetLogger(dblogger) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package storetest | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
|
||
"github.com/algorand/go-algorand/config" | ||
"github.com/algorand/go-algorand/data/basics" | ||
"github.com/algorand/go-algorand/ledger/ledgercore" | ||
"github.com/algorand/go-algorand/ledger/store" | ||
"github.com/algorand/go-algorand/logging" | ||
"github.com/algorand/go-algorand/protocol" | ||
) | ||
|
||
// testinterfaces.go contains interface extensions for the store package | ||
// to use test-only functionality, cast your Interface to the test-version, eg: | ||
// testTx := tx.(TransactionTestScope) | ||
// implementations of test functionality should live in the store package to prevent import cycles | ||
|
||
type BatchTestScope interface { | ||
store.BatchScope | ||
|
||
AccountsInitTest(tb testing.TB, initAccounts map[basics.Address]basics.AccountData, proto protocol.ConsensusVersion) (newDatabase bool) | ||
AccountsUpdateSchemaTest(ctx context.Context) (err error) | ||
RunMigrations(ctx context.Context, params store.TrackerDBParams, log logging.Logger, targetVersion int32) (mgr store.TrackerDBInitParams, err error) | ||
} | ||
|
||
type TransactionTestScope interface { | ||
store.TransactionScope | ||
|
||
MakeAccountsOptimizedReader() (store.AccountsReader, error) | ||
MakeOnlineAccountsOptimizedReader() (store.OnlineAccountsReader, error) | ||
AccountsInitTest(tb testing.TB, initAccounts map[basics.Address]basics.AccountData, proto protocol.ConsensusVersion) (newDatabase bool) | ||
AccountsInitLightTest(tb testing.TB, initAccounts map[basics.Address]basics.AccountData, proto config.ConsensusParams) (newDatabase bool, err error) | ||
} | ||
|
||
type TestAccountsReaderExt interface { | ||
store.AccountsReaderExt | ||
|
||
AccountsAllTest() (bals map[basics.Address]basics.AccountData, err error) | ||
CheckCreatablesTest(t *testing.T, iteration int, expectedDbImage map[basics.CreatableIndex]ledgercore.ModifiedCreatable) | ||
} | ||
|
||
type TestTrackerStore interface { | ||
store.TrackerStore | ||
|
||
CleanupTest(dbName string, inMemory bool) | ||
ResetToV6Test(ctx context.Context) error | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters