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.
This commit is contained in:
parent
0424fd22ec
commit
de4662e5df
3 changed files with 10 additions and 14 deletions
|
@ -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
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in a new issue