@@ -758,9 +758,9 @@ func testAbandonChannel(ht *lntest.HarnessTest) {
758758 ht .ForceCloseChannel (bob , chanPoint )
759759}
760760
761- // testSweepAllCoins tests that we're able to properly sweep all coins from the
761+ // testSendAllCoins tests that we're able to properly sweep all coins from the
762762// wallet into a single target address at the specified fee rate.
763- func testSweepAllCoins (ht * lntest.HarnessTest ) {
763+ func testSendAllCoins (ht * lntest.HarnessTest ) {
764764 // First, we'll make a new node, Ainz who'll we'll use to test wallet
765765 // sweeping.
766766 //
@@ -777,20 +777,22 @@ func testSweepAllCoins(ht *lntest.HarnessTest) {
777777 sendCoinsLabel := "send all coins"
778778
779779 // Ensure that we can't send coins to our own Pubkey.
780- ainz .RPC .SendCoinsAssertErr (& lnrpc.SendCoinsRequest {
780+ err := ainz .RPC .SendCoinsAssertErr (& lnrpc.SendCoinsRequest {
781781 Addr : ainz .RPC .GetInfo ().IdentityPubkey ,
782782 SendAll : true ,
783783 Label : sendCoinsLabel ,
784784 TargetConf : 6 ,
785785 })
786+ require .ErrorContains (ht , err , "cannot send coins to pubkeys" )
786787
787788 // Ensure that we can't send coins to another user's Pubkey.
788- ainz .RPC .SendCoinsAssertErr (& lnrpc.SendCoinsRequest {
789+ err = ainz .RPC .SendCoinsAssertErr (& lnrpc.SendCoinsRequest {
789790 Addr : ht .Alice .RPC .GetInfo ().IdentityPubkey ,
790791 SendAll : true ,
791792 Label : sendCoinsLabel ,
792793 TargetConf : 6 ,
793794 })
795+ require .ErrorContains (ht , err , "cannot send coins to pubkey" )
794796
795797 // With the two coins above mined, we'll now instruct Ainz to sweep all
796798 // the coins to an external address not under its control. We will first
@@ -800,20 +802,23 @@ func testSweepAllCoins(ht *lntest.HarnessTest) {
800802 // same network as the user.
801803
802804 // Send coins to a testnet3 address.
803- ainz .RPC .SendCoinsAssertErr (& lnrpc.SendCoinsRequest {
805+ err = ainz .RPC .SendCoinsAssertErr (& lnrpc.SendCoinsRequest {
804806 Addr : "tb1qfc8fusa98jx8uvnhzavxccqlzvg749tvjw82tg" ,
805807 SendAll : true ,
806808 Label : sendCoinsLabel ,
807809 TargetConf : 6 ,
808810 })
811+ require .ErrorContains (ht , err , "not valid for this network" )
809812
810813 // Send coins to a mainnet address.
811- ainz .RPC .SendCoinsAssertErr (& lnrpc.SendCoinsRequest {
814+ err = ainz .RPC .SendCoinsAssertErr (& lnrpc.SendCoinsRequest {
812815 Addr : "1MPaXKp5HhsLNjVSqaL7fChE3TVyrTMRT3" ,
813816 SendAll : true ,
814817 Label : sendCoinsLabel ,
815818 TargetConf : 6 ,
816819 })
820+ // TODO(yy): should instead return "not valid for this network".
821+ require .ErrorContains (ht , err , "unknown address type" )
817822
818823 // TODO(yy): we still allow default values to be used when neither conf
819824 // target or fee rate is set in 0.18.0. When future release forbidden
@@ -883,7 +888,7 @@ func testSweepAllCoins(ht *lntest.HarnessTest) {
883888 // label our transaction with an empty label, and check that we fail as
884889 // expected.
885890 sweepHash := sweepTx .TxHash ()
886- err : = ainz .RPC .LabelTransactionAssertErr (
891+ err = ainz .RPC .LabelTransactionAssertErr (
887892 & walletrpc.LabelTransactionRequest {
888893 Txid : sweepHash [:],
889894 Label : "" ,
@@ -929,13 +934,14 @@ func testSweepAllCoins(ht *lntest.HarnessTest) {
929934
930935 // If we try again, but this time specifying an amount, then the call
931936 // should fail.
932- ainz .RPC .SendCoinsAssertErr (& lnrpc.SendCoinsRequest {
937+ err = ainz .RPC .SendCoinsAssertErr (& lnrpc.SendCoinsRequest {
933938 Addr : ht .NewMinerAddress ().String (),
934939 Amount : 10000 ,
935940 SendAll : true ,
936941 Label : sendCoinsLabel ,
937942 TargetConf : 6 ,
938943 })
944+ require .ErrorContains (ht , err , "amount set while SendAll is active" )
939945
940946 // With all the edge cases tested, we'll now test the happy paths of
941947 // change output types.
0 commit comments