From de4662e5dfce420fe471beabd7811ad85f79e059 Mon Sep 17 00:00:00 2001 From: Wilmer Paulino Date: Wed, 7 Nov 2018 18:15:03 -0800 Subject: [PATCH] wtxmgr: convert unit tests to be package-level This allows us to reuse some of the existing code to test migrations of the transaction store. --- wtxmgr/example_test.go | 15 +++++++-------- wtxmgr/query_test.go | 3 +-- wtxmgr/tx_test.go | 6 ++---- 3 files changed, 10 insertions(+), 14 deletions(-) diff --git a/wtxmgr/example_test.go b/wtxmgr/example_test.go index 7f418e5..3ef60a4 100644 --- a/wtxmgr/example_test.go +++ b/wtxmgr/example_test.go @@ -2,7 +2,7 @@ // Use of this source code is governed by an ISC // license that can be found in the LICENSE file. -package wtxmgr_test +package wtxmgr import ( "fmt" @@ -11,29 +11,28 @@ import ( "github.com/btcsuite/btcd/chaincfg/chainhash" "github.com/btcsuite/btcd/wire" "github.com/btcsuite/btcwallet/walletdb" - "github.com/btcsuite/btcwallet/wtxmgr" ) var ( // Spends: bogus // Outputs: 10 BTC - exampleTxRecordA *wtxmgr.TxRecord + exampleTxRecordA *TxRecord // Spends: A:0 // Outputs: 5 BTC, 5 BTC - exampleTxRecordB *wtxmgr.TxRecord + exampleTxRecordB *TxRecord ) func init() { tx := spendOutput(&chainhash.Hash{}, 0, 10e8) - rec, err := wtxmgr.NewTxRecordFromMsgTx(tx, timeNow()) + rec, err := NewTxRecordFromMsgTx(tx, timeNow()) if err != nil { panic(err) } exampleTxRecordA = rec tx = spendOutput(&exampleTxRecordA.Hash, 0, 5e8, 5e8) - rec, err = wtxmgr.NewTxRecordFromMsgTx(tx, timeNow()) + rec, err = NewTxRecordFromMsgTx(tx, timeNow()) if err != nil { panic(err) } @@ -183,12 +182,12 @@ func Example_basicUsage() { } // Create and open the transaction store in the provided namespace. - err = wtxmgr.Create(b) + err = Create(b) if err != nil { fmt.Println(err) return } - s, err := wtxmgr.Open(b, &chaincfg.TestNet3Params) + s, err := Open(b, &chaincfg.TestNet3Params) if err != nil { fmt.Println(err) return diff --git a/wtxmgr/query_test.go b/wtxmgr/query_test.go index bd2acf1..0cf702d 100644 --- a/wtxmgr/query_test.go +++ b/wtxmgr/query_test.go @@ -2,7 +2,7 @@ // Use of this source code is governed by an ISC // license that can be found in the LICENSE file. -package wtxmgr_test +package wtxmgr import ( "bytes" @@ -16,7 +16,6 @@ import ( "github.com/btcsuite/btcd/wire" "github.com/btcsuite/btcutil" "github.com/btcsuite/btcwallet/walletdb" - . "github.com/btcsuite/btcwallet/wtxmgr" ) type queryState struct { diff --git a/wtxmgr/tx_test.go b/wtxmgr/tx_test.go index 187eee3..ad271c0 100644 --- a/wtxmgr/tx_test.go +++ b/wtxmgr/tx_test.go @@ -2,7 +2,7 @@ // Use of this source code is governed by an ISC // license that can be found in the LICENSE file. -package wtxmgr_test +package wtxmgr import ( "bytes" @@ -19,8 +19,6 @@ import ( "github.com/btcsuite/btcutil" "github.com/btcsuite/btcwallet/walletdb" _ "github.com/btcsuite/btcwallet/walletdb/bdb" - "github.com/btcsuite/btcwallet/wtxmgr" - . "github.com/btcsuite/btcwallet/wtxmgr" ) // Received transaction output for mainnet outpoint @@ -1572,7 +1570,7 @@ func testInsertMempoolDoubleSpendTx(t *testing.T, first bool) { Time: time.Now(), } - var confirmedSpendRec *wtxmgr.TxRecord + var confirmedSpendRec *TxRecord if first { confirmedSpendRec = firstSpendRec } else {