@@ -837,6 +837,24 @@ func testFundingExpiryBlocksOnPending(ht *lntest.HarnessTest) {
837
837
param := lntest.OpenChannelParams {Amt : 100000 }
838
838
ht .OpenChannelAssertPending (alice , bob , param )
839
839
840
+ // assertExpiry is a helper closure to assert the FundingExpiryBlocks
841
+ // has been updated to the expected value.
842
+ assertExpiry := func (hn * node.HarnessNode , expected int32 ) {
843
+ err := wait .NoError (func () error {
844
+ pending := ht .AssertNumPendingOpenChannels (hn , 1 )
845
+ expiry := pending [0 ].FundingExpiryBlocks
846
+
847
+ // Exit early if matched.
848
+ if expected == expiry {
849
+ return nil
850
+ }
851
+
852
+ return fmt .Errorf ("want %v, got %v" , expected , expiry )
853
+ }, wait .DefaultTimeout )
854
+ require .NoErrorf (ht , err , "%s: assert FundingExpiryBlocks " +
855
+ "timeout" , hn .Name ())
856
+ }
857
+
840
858
// At this point, the channel's funding transaction will have been
841
859
// broadcast, but not confirmed. Alice and Bob's nodes should reflect
842
860
// this when queried via RPC. FundingExpiryBlock should decrease
@@ -846,15 +864,16 @@ func testFundingExpiryBlocksOnPending(ht *lntest.HarnessTest) {
846
864
const numEmptyBlocks = 3
847
865
for i := int32 (0 ); i < numEmptyBlocks ; i ++ {
848
866
expectedVal := lncfg .DefaultMaxWaitNumBlocksFundingConf - i
849
- pending := ht .AssertNumPendingOpenChannels (alice , 1 )
850
- require .Equal (ht , expectedVal , pending [0 ].FundingExpiryBlocks )
851
- pending = ht .AssertNumPendingOpenChannels (bob , 1 )
852
- require .Equal (ht , expectedVal , pending [0 ].FundingExpiryBlocks )
867
+
868
+ // Assert Alice and Bob have updated the FundingExpiryBlocks.
869
+ assertExpiry (alice , expectedVal )
870
+ assertExpiry (bob , expectedVal )
871
+
853
872
ht .MineEmptyBlocks (1 )
854
873
}
855
874
856
- // Mine 1 block to confirm the funding transaction, and then close the
857
- // channel .
875
+ // Mine 1 block to confirm the funding transaction so clean up the
876
+ // mempool .
858
877
ht .MineBlocksAndAssertNumTxes (1 , 1 )
859
878
}
860
879
0 commit comments