Skip to content

Commit

Permalink
udb: Remove v25 upgrade test
Browse files Browse the repository at this point in the history
This test only verifies the database version number and not any real
functionality. It is inconsistent with the other upgrade tests which do not
perform this check.

The test was also brittle because it assumed the post-upgrade database to be
exactly version 25. This has not failed so far because the assumption happens to
be correct, but it will fail in future when newer DB versions are created.
  • Loading branch information
jholdstock authored and jrick committed Jun 27, 2023
1 parent efededa commit d6c3b29
Showing 1 changed file with 1 addition and 25 deletions.
26 changes: 1 addition & 25 deletions wallet/udb/upgrades_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2017 The Decred developers
// Copyright (c) 2017-2023 The Decred developers
// Use of this source code is governed by an ISC
// license that can be found in the LICENSE file.

Expand Down Expand Up @@ -37,8 +37,6 @@ var dbUpgradeTests = [...]struct {
// No upgrade test for V9, it is a fix for V8 and the previous test still applies
// TODO: V10 upgrade test
{verifyV12Upgrade, "v11.db.gz"},
// TODO: V13-24 tests
{verifyV25Upgrade, "v24.db.gz"},
}

var pubPass = []byte("public")
Expand Down Expand Up @@ -533,25 +531,3 @@ func verifyV12Upgrade(ctx context.Context, t *testing.T, db walletdb.DB) {
t.Error(err)
}
}

func verifyV25Upgrade(ctx context.Context, t *testing.T, db walletdb.DB) {
const wantVer = 25
_, _, _, err := Open(ctx, db, chaincfg.TestNet3Params(), pubPass)
if err != nil {
t.Fatalf("Open after Upgrade failed: %v", err)
}
if err = walletdb.View(ctx, db, func(tx walletdb.ReadTx) error {
metadataBucket := tx.ReadBucket(unifiedDBMetadata{}.rootBucketKey())

dbVer, err := unifiedDBMetadata{}.getVersion(metadataBucket)
if err != nil {
return err
}
if dbVer != wantVer {
return fmt.Errorf("wanted version %d but got %d", wantVer, dbVer)
}
return nil
}); err != nil {
t.Fatal(err)
}
}

0 comments on commit d6c3b29

Please sign in to comment.