From 31dc387e0f919d68cfe4e3c3f3c15247a217de21 Mon Sep 17 00:00:00 2001 From: "Johan T. Halseth" Date: Fri, 24 Aug 2018 14:13:52 +0200 Subject: [PATCH] chainntnfs/btcd+bitcoind tests: use common TxConfStatus --- chainntnfs/bitcoindnotify/bitcoind_test.go | 14 +++++++------- chainntnfs/btcdnotify/btcd_test.go | 21 +++++++++++---------- 2 files changed, 18 insertions(+), 17 deletions(-) diff --git a/chainntnfs/bitcoindnotify/bitcoind_test.go b/chainntnfs/bitcoindnotify/bitcoind_test.go index ad71a4d0..16bbc2ed 100644 --- a/chainntnfs/bitcoindnotify/bitcoind_test.go +++ b/chainntnfs/bitcoindnotify/bitcoind_test.go @@ -111,8 +111,8 @@ func TestHistoricalConfDetailsTxIndex(t *testing.T) { } switch txStatus { - case txNotFoundIndex: - case txNotFoundManually: + case chainntnfs.TxNotFoundIndex: + case chainntnfs.TxNotFoundManually: t.Fatal("should not have proceeded with fallback method, but did") default: t.Fatal("should not have found non-existent transaction, but did") @@ -137,7 +137,7 @@ func TestHistoricalConfDetailsTxIndex(t *testing.T) { // Since it has yet to be included in a block, it should have been found // within the mempool. switch txStatus { - case txFoundMempool: + case chainntnfs.TxFoundMempool: default: t.Fatal("should have found the transaction within the "+ "mempool, but did not: %v", txStatus) @@ -159,7 +159,7 @@ func TestHistoricalConfDetailsTxIndex(t *testing.T) { // Since the backend node's txindex is enabled and the transaction has // confirmed, we should be able to retrieve it using the txindex. switch txStatus { - case txFoundIndex: + case chainntnfs.TxFoundIndex: default: t.Fatal("should have found the transaction within the " + "txindex, but did not") @@ -196,8 +196,8 @@ func TestHistoricalConfDetailsNoTxIndex(t *testing.T) { } switch txStatus { - case txNotFoundManually: - case txNotFoundIndex: + case chainntnfs.TxNotFoundManually: + case chainntnfs.TxNotFoundIndex: t.Fatal("should have proceeded with fallback method, but did not") default: t.Fatal("should not have found non-existent transaction, but did") @@ -237,7 +237,7 @@ func TestHistoricalConfDetailsNoTxIndex(t *testing.T) { // confirmed, we should be able to find it by falling back to scanning // the chain manually. switch txStatus { - case txFoundManually: + case chainntnfs.TxFoundManually: default: t.Fatal("should have found the transaction by manually " + "scanning the chain, but did not") diff --git a/chainntnfs/btcdnotify/btcd_test.go b/chainntnfs/btcdnotify/btcd_test.go index 464c928e..34f53d5b 100644 --- a/chainntnfs/btcdnotify/btcd_test.go +++ b/chainntnfs/btcdnotify/btcd_test.go @@ -71,8 +71,8 @@ func TestHistoricalConfDetailsTxIndex(t *testing.T) { } switch txStatus { - case txNotFoundIndex: - case txNotFoundManually: + case chainntnfs.TxNotFoundIndex: + case chainntnfs.TxNotFoundManually: t.Fatal("should not have proceeded with fallback method, but did") default: t.Fatal("should not have found non-existent transaction, but did") @@ -88,6 +88,7 @@ func TestHistoricalConfDetailsTxIndex(t *testing.T) { t.Fatalf("unable to find tx in the mempool: %v", err) } + // The transaction should be found in the mempool at this point. _, txStatus, err = notifier.historicalConfDetails(txid, 0, 0) if err != nil { t.Fatalf("unable to retrieve historical conf details: %v", err) @@ -96,10 +97,10 @@ func TestHistoricalConfDetailsTxIndex(t *testing.T) { // Since it has yet to be included in a block, it should have been found // within the mempool. switch txStatus { - case txFoundMempool: + case chainntnfs.TxFoundMempool: default: - t.Fatal("should have found the transaction within the " + - "mempool, but did not") + t.Fatalf("should have found the transaction within the "+ + "mempool, but did not: %v", txStatus) } // We'll now confirm this transaction and re-attempt to retrieve its @@ -116,7 +117,7 @@ func TestHistoricalConfDetailsTxIndex(t *testing.T) { // Since the backend node's txindex is enabled and the transaction has // confirmed, we should be able to retrieve it using the txindex. switch txStatus { - case txFoundIndex: + case chainntnfs.TxFoundIndex: default: t.Fatal("should have found the transaction within the " + "txindex, but did not") @@ -145,8 +146,8 @@ func TestHistoricalConfDetailsNoTxIndex(t *testing.T) { } switch txStatus { - case txNotFoundManually: - case txNotFoundIndex: + case chainntnfs.TxNotFoundManually: + case chainntnfs.TxNotFoundIndex: t.Fatal("should have proceeded with fallback method, but did not") default: t.Fatal("should not have found non-existent transaction, but did") @@ -175,7 +176,7 @@ func TestHistoricalConfDetailsNoTxIndex(t *testing.T) { // Since it has yet to be included in a block, it should have been found // within the mempool. - if txStatus != txFoundMempool { + if txStatus != chainntnfs.TxFoundMempool { t.Fatal("should have found the transaction within the " + "mempool, but did not") } @@ -196,7 +197,7 @@ func TestHistoricalConfDetailsNoTxIndex(t *testing.T) { // Since the backend node's txindex is disabled and the transaction has // confirmed, we should be able to find it by falling back to scanning // the chain manually. - if txStatus != txFoundManually { + if txStatus != chainntnfs.TxFoundManually { t.Fatal("should have found the transaction by manually " + "scanning the chain, but did not") }