2020-04-25 02:44:21 +02:00
|
|
|
// Copyright (c) 2018 The btcsuite developers
|
|
|
|
// Use of this source code is governed by an ISC
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
|
|
|
package wallet
|
|
|
|
|
|
|
|
import (
|
|
|
|
"io/ioutil"
|
|
|
|
"os"
|
|
|
|
"testing"
|
|
|
|
"time"
|
|
|
|
|
|
|
|
"github.com/btcsuite/btcd/chaincfg"
|
|
|
|
_ "github.com/btcsuite/btcwallet/walletdb/bdb"
|
|
|
|
)
|
|
|
|
|
|
|
|
// TestCreateWatchingOnly checks that we can construct a watching-only
|
|
|
|
// wallet.
|
|
|
|
func TestCreateWatchingOnly(t *testing.T) {
|
|
|
|
// Set up a wallet.
|
|
|
|
dir, err := ioutil.TempDir("", "watchingonly_test")
|
|
|
|
if err != nil {
|
|
|
|
t.Fatalf("Failed to create db dir: %v", err)
|
|
|
|
}
|
|
|
|
defer os.RemoveAll(dir)
|
|
|
|
|
|
|
|
pubPass := []byte("hello")
|
|
|
|
|
2020-08-11 21:53:04 +02:00
|
|
|
loader := NewLoader(
|
|
|
|
&chaincfg.TestNet3Params, dir, true, defaultDBTimeout, 250,
|
|
|
|
)
|
2020-04-25 02:44:21 +02:00
|
|
|
_, err = loader.CreateNewWatchingOnlyWallet(pubPass, time.Now())
|
|
|
|
if err != nil {
|
|
|
|
t.Fatalf("unable to create wallet: %v", err)
|
|
|
|
}
|
|
|
|
}
|