@@ -1737,23 +1737,24 @@ class NormalStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with
1737
1737
relayerA.expectNoMsg(1 seconds)
1738
1738
}
1739
1739
1740
- def testCmdClose (f : FixtureParam ): Unit = {
1740
+ def testCmdClose (f : FixtureParam , script_opt : Option [ ByteVector ] ): Unit = {
1741
1741
import f ._
1742
1742
val sender = TestProbe ()
1743
1743
awaitCond(alice.stateData.asInstanceOf [DATA_NORMAL ].localShutdown.isEmpty)
1744
- alice ! CMD_CLOSE (sender.ref, None )
1744
+ alice ! CMD_CLOSE (sender.ref, script_opt )
1745
1745
sender.expectMsgType[RES_SUCCESS [CMD_CLOSE ]]
1746
- alice2bob.expectMsgType[Shutdown ]
1746
+ val shutdown = alice2bob.expectMsgType[Shutdown ]
1747
+ script_opt.foreach(script => assert(script === shutdown.scriptPubKey))
1747
1748
awaitCond(alice.stateName == NORMAL )
1748
1749
awaitCond(alice.stateData.asInstanceOf [DATA_NORMAL ].localShutdown.isDefined)
1749
1750
}
1750
1751
1751
- test(" recv CMD_CLOSE (no pending htlcs)" ) {
1752
- testCmdClose _
1752
+ test(" recv CMD_CLOSE (no pending htlcs)" ) { f =>
1753
+ testCmdClose(f, None )
1753
1754
}
1754
1755
1755
- test(" recv CMD_CLOSE (no pending htlcs) (anchor outputs)" , Tag (StateTestsTags .AnchorOutputs )) {
1756
- testCmdClose _
1756
+ test(" recv CMD_CLOSE (no pending htlcs) (anchor outputs)" , Tag (StateTestsTags .AnchorOutputs )) { f =>
1757
+ testCmdClose(f, None )
1757
1758
}
1758
1759
1759
1760
test(" recv CMD_CLOSE (with noSender)" ) { f =>
@@ -1794,6 +1795,17 @@ class NormalStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with
1794
1795
sender.expectMsgType[RES_FAILURE [CMD_CLOSE , InvalidFinalScript ]]
1795
1796
}
1796
1797
1798
+ test(" recv CMD_CLOSE (with unsupported native segwit script)" ) { f =>
1799
+ import f ._
1800
+ val sender = TestProbe ()
1801
+ alice ! CMD_CLOSE (sender.ref, Some (hex " 51050102030405 " ))
1802
+ sender.expectMsgType[RES_FAILURE [CMD_CLOSE , InvalidFinalScript ]]
1803
+ }
1804
+
1805
+ test(" recv CMD_CLOSE (with native segwit script)" , Tag (StateTestsTags .ShutdownAnySegwit )) { f =>
1806
+ testCmdClose(f, Some (hex " 51050102030405 " ))
1807
+ }
1808
+
1797
1809
test(" recv CMD_CLOSE (with signed sent htlcs)" ) { f =>
1798
1810
import f ._
1799
1811
val sender = TestProbe ()
@@ -1849,22 +1861,22 @@ class NormalStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with
1849
1861
awaitCond(alice.stateName == NORMAL )
1850
1862
}
1851
1863
1852
- def testShutdown (f : FixtureParam ): Unit = {
1864
+ def testShutdown (f : FixtureParam , script_opt : Option [ ByteVector ] ): Unit = {
1853
1865
import f ._
1854
- alice ! Shutdown (ByteVector32 .Zeroes , Bob .channelParams.defaultFinalScriptPubKey)
1866
+ alice ! Shutdown (ByteVector32 .Zeroes , script_opt.getOrElse( Bob .channelParams.defaultFinalScriptPubKey) )
1855
1867
alice2bob.expectMsgType[Shutdown ]
1856
1868
alice2bob.expectMsgType[ClosingSigned ]
1857
1869
awaitCond(alice.stateName == NEGOTIATING )
1858
1870
// channel should be advertised as down
1859
1871
assert(channelUpdateListener.expectMsgType[LocalChannelDown ].channelId === alice.stateData.asInstanceOf [DATA_NEGOTIATING ].channelId)
1860
1872
}
1861
1873
1862
- test(" recv Shutdown (no pending htlcs)" ) {
1863
- testShutdown _
1874
+ test(" recv Shutdown (no pending htlcs)" ) { f =>
1875
+ testShutdown(f, None )
1864
1876
}
1865
1877
1866
- test(" recv Shutdown (no pending htlcs) (anchor outputs)" , Tag (StateTestsTags .AnchorOutputs )) {
1867
- testShutdown _
1878
+ test(" recv Shutdown (no pending htlcs) (anchor outputs)" , Tag (StateTestsTags .AnchorOutputs )) { f =>
1879
+ testShutdown(f, None )
1868
1880
}
1869
1881
1870
1882
test(" recv Shutdown (with unacked sent htlcs)" ) { f =>
@@ -1938,6 +1950,18 @@ class NormalStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with
1938
1950
awaitCond(bob.stateName == CLOSING )
1939
1951
}
1940
1952
1953
+ test(" recv Shutdown (with unsupported native segwit script)" ) { f =>
1954
+ import f ._
1955
+ bob ! Shutdown (ByteVector32 .Zeroes , hex " 51050102030405 " )
1956
+ bob2alice.expectMsgType[Error ]
1957
+ bob2blockchain.expectMsgType[PublishTx ]
1958
+ awaitCond(bob.stateName == CLOSING )
1959
+ }
1960
+
1961
+ test(" recv Shutdown (with native segwit script)" , Tag (StateTestsTags .ShutdownAnySegwit )) { f =>
1962
+ testShutdown(f, Some (hex " 51050102030405 " ))
1963
+ }
1964
+
1941
1965
test(" recv Shutdown (with invalid final script and signed htlcs, in response to a Shutdown)" ) { f =>
1942
1966
import f ._
1943
1967
val sender = TestProbe ()
0 commit comments