test: fix race conditions in tests
This commit is contained in:
parent
a7cbb7c481
commit
56a178f545
2 changed files with 20 additions and 11 deletions
|
@ -12,11 +12,11 @@ import (
|
||||||
// TestStoreMaxReorgDepth ensures that we can only store up to MaxReorgDepth
|
// TestStoreMaxReorgDepth ensures that we can only store up to MaxReorgDepth
|
||||||
// blocks at any given time.
|
// blocks at any given time.
|
||||||
func TestStoreMaxReorgDepth(t *testing.T) {
|
func TestStoreMaxReorgDepth(t *testing.T) {
|
||||||
t.Parallel()
|
|
||||||
|
|
||||||
teardown, db, _ := setupManager(t)
|
teardown, db, _ := setupManager(t)
|
||||||
defer teardown()
|
defer teardown()
|
||||||
|
|
||||||
|
t.Parallel()
|
||||||
|
|
||||||
// We'll start the test by simulating a synced chain where we start from
|
// We'll start the test by simulating a synced chain where we start from
|
||||||
// 1000 and end at 109999.
|
// 1000 and end at 109999.
|
||||||
const (
|
const (
|
||||||
|
|
|
@ -2129,11 +2129,12 @@ func deriveTestAccountKey(t *testing.T) *hdkeychain.ExtendedKey {
|
||||||
// TestManagerIncorrectVersion ensures that that the manager cannot be accessed
|
// TestManagerIncorrectVersion ensures that that the manager cannot be accessed
|
||||||
// if its version does not match the latest version.
|
// if its version does not match the latest version.
|
||||||
func TestManagerHigherVersion(t *testing.T) {
|
func TestManagerHigherVersion(t *testing.T) {
|
||||||
t.Parallel()
|
|
||||||
|
|
||||||
teardown, db, _ := setupManager(t)
|
teardown, db, _ := setupManager(t)
|
||||||
defer teardown()
|
defer teardown()
|
||||||
|
|
||||||
|
t.Parallel()
|
||||||
|
|
||||||
// We'll update our manager's version to be one higher than the latest.
|
// We'll update our manager's version to be one higher than the latest.
|
||||||
latestVersion := getLatestVersion()
|
latestVersion := getLatestVersion()
|
||||||
err := walletdb.Update(db, func(tx walletdb.ReadWriteTx) error {
|
err := walletdb.Update(db, func(tx walletdb.ReadWriteTx) error {
|
||||||
|
@ -2186,11 +2187,12 @@ func TestManagerHigherVersion(t *testing.T) {
|
||||||
// TestEncryptDecryptErrors ensures that errors which occur while encrypting and
|
// TestEncryptDecryptErrors ensures that errors which occur while encrypting and
|
||||||
// decrypting data return the expected errors.
|
// decrypting data return the expected errors.
|
||||||
func TestEncryptDecryptErrors(t *testing.T) {
|
func TestEncryptDecryptErrors(t *testing.T) {
|
||||||
t.Parallel()
|
|
||||||
|
|
||||||
teardown, db, mgr := setupManager(t)
|
teardown, db, mgr := setupManager(t)
|
||||||
defer teardown()
|
defer teardown()
|
||||||
|
|
||||||
|
t.Parallel()
|
||||||
|
|
||||||
invalidKeyType := CryptoKeyType(0xff)
|
invalidKeyType := CryptoKeyType(0xff)
|
||||||
if _, err := mgr.Encrypt(invalidKeyType, []byte{}); err == nil {
|
if _, err := mgr.Encrypt(invalidKeyType, []byte{}); err == nil {
|
||||||
t.Fatalf("Encrypt accepted an invalid key type!")
|
t.Fatalf("Encrypt accepted an invalid key type!")
|
||||||
|
@ -2239,11 +2241,12 @@ func TestEncryptDecryptErrors(t *testing.T) {
|
||||||
// TestEncryptDecrypt ensures that encrypting and decrypting data with the
|
// TestEncryptDecrypt ensures that encrypting and decrypting data with the
|
||||||
// the various crypto key types works as expected.
|
// the various crypto key types works as expected.
|
||||||
func TestEncryptDecrypt(t *testing.T) {
|
func TestEncryptDecrypt(t *testing.T) {
|
||||||
t.Parallel()
|
|
||||||
|
|
||||||
teardown, db, mgr := setupManager(t)
|
teardown, db, mgr := setupManager(t)
|
||||||
defer teardown()
|
defer teardown()
|
||||||
|
|
||||||
|
t.Parallel()
|
||||||
|
|
||||||
plainText := []byte("this is a plaintext")
|
plainText := []byte("this is a plaintext")
|
||||||
|
|
||||||
// Make sure address manager is unlocked
|
// Make sure address manager is unlocked
|
||||||
|
@ -2282,11 +2285,12 @@ func TestEncryptDecrypt(t *testing.T) {
|
||||||
// create, retrieve, and utilize new scoped managers outside the set of default
|
// create, retrieve, and utilize new scoped managers outside the set of default
|
||||||
// created scopes.
|
// created scopes.
|
||||||
func TestScopedKeyManagerManagement(t *testing.T) {
|
func TestScopedKeyManagerManagement(t *testing.T) {
|
||||||
t.Parallel()
|
|
||||||
|
|
||||||
teardown, db := emptyDB(t)
|
teardown, db := emptyDB(t)
|
||||||
defer teardown()
|
defer teardown()
|
||||||
|
|
||||||
|
t.Parallel()
|
||||||
|
|
||||||
// We'll start the test by creating a new root manager that will be
|
// We'll start the test by creating a new root manager that will be
|
||||||
// used for the duration of the test.
|
// used for the duration of the test.
|
||||||
var mgr *Manager
|
var mgr *Manager
|
||||||
|
@ -2531,11 +2535,12 @@ func TestScopedKeyManagerManagement(t *testing.T) {
|
||||||
// TestRootHDKeyNeutering tests that callers are unable to create new scoped
|
// TestRootHDKeyNeutering tests that callers are unable to create new scoped
|
||||||
// managers once the root HD key has been deleted from the database.
|
// managers once the root HD key has been deleted from the database.
|
||||||
func TestRootHDKeyNeutering(t *testing.T) {
|
func TestRootHDKeyNeutering(t *testing.T) {
|
||||||
t.Parallel()
|
|
||||||
|
|
||||||
teardown, db := emptyDB(t)
|
teardown, db := emptyDB(t)
|
||||||
defer teardown()
|
defer teardown()
|
||||||
|
|
||||||
|
t.Parallel()
|
||||||
|
|
||||||
// We'll start the test by creating a new root manager that will be
|
// We'll start the test by creating a new root manager that will be
|
||||||
// used for the duration of the test.
|
// used for the duration of the test.
|
||||||
var mgr *Manager
|
var mgr *Manager
|
||||||
|
@ -2623,11 +2628,12 @@ func TestRootHDKeyNeutering(t *testing.T) {
|
||||||
// raw accounts created with only an account number, and not a string which is
|
// raw accounts created with only an account number, and not a string which is
|
||||||
// eventually mapped to an account number.
|
// eventually mapped to an account number.
|
||||||
func TestNewRawAccount(t *testing.T) {
|
func TestNewRawAccount(t *testing.T) {
|
||||||
t.Parallel()
|
|
||||||
|
|
||||||
teardown, db := emptyDB(t)
|
teardown, db := emptyDB(t)
|
||||||
defer teardown()
|
defer teardown()
|
||||||
|
|
||||||
|
t.Parallel()
|
||||||
|
|
||||||
// We'll start the test by creating a new root manager that will be
|
// We'll start the test by creating a new root manager that will be
|
||||||
// used for the duration of the test.
|
// used for the duration of the test.
|
||||||
var mgr *Manager
|
var mgr *Manager
|
||||||
|
@ -2682,11 +2688,12 @@ func TestNewRawAccount(t *testing.T) {
|
||||||
// only an account number, and not a string which is eventually mapped
|
// only an account number, and not a string which is eventually mapped
|
||||||
// to an account number.
|
// to an account number.
|
||||||
func TestNewRawAccountWatchingOnly(t *testing.T) {
|
func TestNewRawAccountWatchingOnly(t *testing.T) {
|
||||||
t.Parallel()
|
|
||||||
|
|
||||||
teardown, db := emptyDB(t)
|
teardown, db := emptyDB(t)
|
||||||
defer teardown()
|
defer teardown()
|
||||||
|
|
||||||
|
t.Parallel()
|
||||||
|
|
||||||
// We'll start the test by creating a new root manager that will be
|
// We'll start the test by creating a new root manager that will be
|
||||||
// used for the duration of the test.
|
// used for the duration of the test.
|
||||||
var mgr *Manager
|
var mgr *Manager
|
||||||
|
@ -2749,11 +2756,12 @@ func TestNewRawAccountWatchingOnly(t *testing.T) {
|
||||||
// shows that watch-only accounts can be added to managers with
|
// shows that watch-only accounts can be added to managers with
|
||||||
// non-watch-only accounts.
|
// non-watch-only accounts.
|
||||||
func TestNewRawAccountHybrid(t *testing.T) {
|
func TestNewRawAccountHybrid(t *testing.T) {
|
||||||
t.Parallel()
|
|
||||||
|
|
||||||
teardown, db := emptyDB(t)
|
teardown, db := emptyDB(t)
|
||||||
defer teardown()
|
defer teardown()
|
||||||
|
|
||||||
|
t.Parallel()
|
||||||
|
|
||||||
// We'll start the test by creating a new root manager that will be
|
// We'll start the test by creating a new root manager that will be
|
||||||
// used for the duration of the test.
|
// used for the duration of the test.
|
||||||
var mgr *Manager
|
var mgr *Manager
|
||||||
|
@ -2869,11 +2877,12 @@ func testNewRawAccount(t *testing.T, _ *Manager, db walletdb.DB,
|
||||||
// properly cache items in the cache, and return corresponding errors if the
|
// properly cache items in the cache, and return corresponding errors if the
|
||||||
// account isn't properly cached.
|
// account isn't properly cached.
|
||||||
func TestDeriveFromKeyPathCache(t *testing.T) {
|
func TestDeriveFromKeyPathCache(t *testing.T) {
|
||||||
t.Parallel()
|
|
||||||
|
|
||||||
teardown, db := emptyDB(t)
|
teardown, db := emptyDB(t)
|
||||||
defer teardown()
|
defer teardown()
|
||||||
|
|
||||||
|
t.Parallel()
|
||||||
|
|
||||||
// We'll start the test by creating a new root manager that will be
|
// We'll start the test by creating a new root manager that will be
|
||||||
// used for the duration of the test.
|
// used for the duration of the test.
|
||||||
var mgr *Manager
|
var mgr *Manager
|
||||||
|
|
Loading…
Reference in a new issue