itest+lntest: stop using pointer to chainhash.Hash

This commit fixes the methods used in `lntest` so they stop using
pointers to chainhash.
This commit is contained in:
yyforyongyu committed 2024-10-17 07:14:51 +08:00
1 parent af6b88a9f6
commit ed3cb26188
16 files changed
+99 -93

No files matched your search

+12 -12
View File
@@ -128,7 +128,7 @@ func breachRetributionTestCase(ht *lntest.HarnessTest,
// ordering, the first output in this breach tx is the to_remote
// output.
toRemoteOp := wire.OutPoint{
Hash: *breachTXID,
Hash: breachTXID,
Index: 0,
}
@@ -151,7 +151,7 @@ func breachRetributionTestCase(ht *lntest.HarnessTest,
// Assert that all the inputs of this transaction are spending outputs
// generated by Bob's breach transaction above.
for _, txIn := range justiceTx.TxIn {
require.Equal(ht, *breachTXID, txIn.PreviousOutPoint.Hash,
require.Equal(ht, breachTXID, txIn.PreviousOutPoint.Hash,
"justice tx not spending commitment utxo")
}
@@ -174,7 +174,7 @@ func breachRetributionTestCase(ht *lntest.HarnessTest,
// transaction which was just accepted into the mempool.
block = ht.MineBlocksAndAssertNumTxes(1, 1)[0]
justiceTxid := justiceTx.TxHash()
ht.AssertTxInBlock(block, &justiceTxid)
ht.AssertTxInBlock(block, justiceTxid)
ht.AssertNodeNumChannels(carol, 0)
@@ -318,7 +318,7 @@ func revokedCloseRetributionZeroValueRemoteOutputCase(ht *lntest.HarnessTest,
// ordering, the first output in this breach tx is the to_local
// output.
toLocalOp := wire.OutPoint{
Hash: *breachTXID,
Hash: breachTXID,
Index: 0,
}
@@ -363,7 +363,7 @@ func revokedCloseRetributionZeroValueRemoteOutputCase(ht *lntest.HarnessTest,
// transaction which was just accepted into the mempool.
block := ht.MineBlocksAndAssertNumTxes(1, 1)[0]
justiceTxid := justiceTx.TxHash()
ht.AssertTxInBlock(block, &justiceTxid)
ht.AssertTxInBlock(block, justiceTxid)
// At this point, Dave should have no pending channels.
ht.AssertNodeNumChannels(dave, 0)
@@ -567,7 +567,7 @@ func revokedCloseRetributionRemoteHodlCase(ht *lntest.HarnessTest,
// outputs to the second level before Dave broadcasts his justice tx,
// we'll search through the mempool for a tx that matches the number of
// expected inputs in the justice tx.
var justiceTxid *chainhash.Hash
var justiceTxid chainhash.Hash
errNotFound := errors.New("justice tx not found")
findJusticeTx := func() (*chainhash.Hash, error) {
mempool := ht.GetRawMempool()
@@ -579,14 +579,14 @@ func revokedCloseRetributionRemoteHodlCase(ht *lntest.HarnessTest,
// NOTE: We don't use `ht.GetRawTransaction`
// which asserts a txid must be found as the HTLC
// spending txes might be aggregated.
tx, err := ht.Miner().Client.GetRawTransaction(txid)
tx, err := ht.Miner().Client.GetRawTransaction(&txid)
if err != nil {
return nil, err
}
exNumInputs := 2 + numInvoices
if len(tx.MsgTx().TxIn) == exNumInputs {
return txid, nil
return &txid, nil
}
}
@@ -598,7 +598,7 @@ func revokedCloseRetributionRemoteHodlCase(ht *lntest.HarnessTest,
if err != nil {
return err
}
justiceTxid = txid
justiceTxid = *txid
return nil
}, defaultTimeout)
@@ -619,7 +619,7 @@ func revokedCloseRetributionRemoteHodlCase(ht *lntest.HarnessTest,
return err
}
justiceTxid = txid
justiceTxid = *txid
return nil
}, defaultTimeout)
@@ -631,7 +631,7 @@ func revokedCloseRetributionRemoteHodlCase(ht *lntest.HarnessTest,
// isSecondLevelSpend checks that the passed secondLevelTxid is a
// potentitial second level spend spending from the commit tx.
isSecondLevelSpend := func(commitTxid,
secondLevelTxid *chainhash.Hash) bool {
secondLevelTxid chainhash.Hash) bool {
secondLevel := ht.GetRawTransaction(secondLevelTxid)
@@ -661,7 +661,7 @@ func revokedCloseRetributionRemoteHodlCase(ht *lntest.HarnessTest,
// the breach tx, Carol might have had the time to take an
// output to the second level. In that case, check that the
// justice tx is spending this second level output.
if isSecondLevelSpend(breachTXID, &txIn.PreviousOutPoint.Hash) {
if isSecondLevelSpend(breachTXID, txIn.PreviousOutPoint.Hash) {
continue
}
require.Fail(ht, "justice tx not spending commitment utxo "+