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
|
// Use of this source code is governed by an ISC
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
package wtxmgr_test
|
package wtxmgr
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
@ -11,29 +11,28 @@ import (
|
||||||
"github.com/btcsuite/btcd/chaincfg/chainhash"
|
"github.com/btcsuite/btcd/chaincfg/chainhash"
|
||||||
"github.com/btcsuite/btcd/wire"
|
"github.com/btcsuite/btcd/wire"
|
||||||
"github.com/btcsuite/btcwallet/walletdb"
|
"github.com/btcsuite/btcwallet/walletdb"
|
||||||
"github.com/btcsuite/btcwallet/wtxmgr"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
// Spends: bogus
|
// Spends: bogus
|
||||||
// Outputs: 10 BTC
|
// Outputs: 10 BTC
|
||||||
exampleTxRecordA *wtxmgr.TxRecord
|
exampleTxRecordA *TxRecord
|
||||||
|
|
||||||
// Spends: A:0
|
// Spends: A:0
|
||||||
// Outputs: 5 BTC, 5 BTC
|
// Outputs: 5 BTC, 5 BTC
|
||||||
exampleTxRecordB *wtxmgr.TxRecord
|
exampleTxRecordB *TxRecord
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
tx := spendOutput(&chainhash.Hash{}, 0, 10e8)
|
tx := spendOutput(&chainhash.Hash{}, 0, 10e8)
|
||||||
rec, err := wtxmgr.NewTxRecordFromMsgTx(tx, timeNow())
|
rec, err := NewTxRecordFromMsgTx(tx, timeNow())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
exampleTxRecordA = rec
|
exampleTxRecordA = rec
|
||||||
|
|
||||||
tx = spendOutput(&exampleTxRecordA.Hash, 0, 5e8, 5e8)
|
tx = spendOutput(&exampleTxRecordA.Hash, 0, 5e8, 5e8)
|
||||||
rec, err = wtxmgr.NewTxRecordFromMsgTx(tx, timeNow())
|
rec, err = NewTxRecordFromMsgTx(tx, timeNow())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
@ -183,12 +182,12 @@ func Example_basicUsage() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create and open the transaction store in the provided namespace.
|
// Create and open the transaction store in the provided namespace.
|
||||||
err = wtxmgr.Create(b)
|
err = Create(b)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
s, err := wtxmgr.Open(b, &chaincfg.TestNet3Params)
|
s, err := Open(b, &chaincfg.TestNet3Params)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
return
|
return
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
// Use of this source code is governed by an ISC
|
// Use of this source code is governed by an ISC
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
package wtxmgr_test
|
package wtxmgr
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
@ -16,7 +16,6 @@ import (
|
||||||
"github.com/btcsuite/btcd/wire"
|
"github.com/btcsuite/btcd/wire"
|
||||||
"github.com/btcsuite/btcutil"
|
"github.com/btcsuite/btcutil"
|
||||||
"github.com/btcsuite/btcwallet/walletdb"
|
"github.com/btcsuite/btcwallet/walletdb"
|
||||||
. "github.com/btcsuite/btcwallet/wtxmgr"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type queryState struct {
|
type queryState struct {
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
// Use of this source code is governed by an ISC
|
// Use of this source code is governed by an ISC
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
package wtxmgr_test
|
package wtxmgr
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
@ -19,8 +19,6 @@ import (
|
||||||
"github.com/btcsuite/btcutil"
|
"github.com/btcsuite/btcutil"
|
||||||
"github.com/btcsuite/btcwallet/walletdb"
|
"github.com/btcsuite/btcwallet/walletdb"
|
||||||
_ "github.com/btcsuite/btcwallet/walletdb/bdb"
|
_ "github.com/btcsuite/btcwallet/walletdb/bdb"
|
||||||
"github.com/btcsuite/btcwallet/wtxmgr"
|
|
||||||
. "github.com/btcsuite/btcwallet/wtxmgr"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Received transaction output for mainnet outpoint
|
// Received transaction output for mainnet outpoint
|
||||||
|
@ -1572,7 +1570,7 @@ func testInsertMempoolDoubleSpendTx(t *testing.T, first bool) {
|
||||||
Time: time.Now(),
|
Time: time.Now(),
|
||||||
}
|
}
|
||||||
|
|
||||||
var confirmedSpendRec *wtxmgr.TxRecord
|
var confirmedSpendRec *TxRecord
|
||||||
if first {
|
if first {
|
||||||
confirmedSpendRec = firstSpendRec
|
confirmedSpendRec = firstSpendRec
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue