From 24f9504e274e5de7d94402c76369ad5afeb4d6c5 Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Wed, 12 Sep 2018 20:51:27 -0700 Subject: [PATCH] lnwallet: add test to ensure that all backends show unconf txns in ListTransactionDetails In this commit, we add a new test to the set of lnwallet integration tests. In this new test, we aim to ensure that all backends are able to display unconfirmed transactions in ListChainTransactions. As of this commit, this test fails as no backends will return unconfirmed transactions properly. --- lnwallet/interface_test.go | 39 +++++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/lnwallet/interface_test.go b/lnwallet/interface_test.go index eb2be23e..cd112583 100644 --- a/lnwallet/interface_test.go +++ b/lnwallet/interface_test.go @@ -1055,7 +1055,9 @@ func testListTransactionDetails(miner *rpctest.Harness, delete(txids, txDetail.Hash) } if len(txids) != 0 { - t.Fatalf("all transactions not found in details!") + t.Fatalf("all transactions not found in details: left=%v, "+ + "returned_set=%v", spew.Sdump(txids), + spew.Sdump(txDetails)) } // Next create a transaction paying to an output which isn't under the @@ -1075,6 +1077,41 @@ func testListTransactionDetails(miner *rpctest.Harness, if err != nil { t.Fatalf("tx not relayed to miner: %v", err) } + + // Before we mine the next block, we'll ensure that the above + // transaction shows up in the set of unconfirmed transactions returned + // by ListTransactionDetails. + err = waitForWalletSync(miner, alice) + if err != nil { + t.Fatalf("Couldn't sync Alice's wallet: %v", err) + } + + // We should be able to find the transaction above in the set of + // returned transactions, and it should have a confirmation of -1, + // indicating that it's not yet mined. + txDetails, err = alice.ListTransactionDetails() + if err != nil { + t.Fatalf("unable to fetch tx details: %v", err) + } + var mempoolTxFound bool + for _, txDetail := range txDetails { + if !bytes.Equal(txDetail.Hash[:], burnTXID[:]) { + continue + } + + // Now that we've found the transaction, ensure that it has a + // negative number of confirmations to indicate that it's + // unconfirmed. + mempoolTxFound = true + if txDetail.NumConfirmations != 0 { + t.Fatalf("num confs incorrect, got %v expected %v", + txDetail.NumConfirmations, 0) + } + } + if !mempoolTxFound { + t.Fatalf("unable to find mempool tx in tx details!") + } + burnBlock, err := miner.Node.Generate(1) if err != nil { t.Fatalf("unable to mine block: %v", err)