itest: add label check to sweep coins test
Add a label to our sweep all coins itest and check that it is correctly set.
This commit is contained in:
parent
e8ca306f12
commit
d021eae392
@ -12486,9 +12486,13 @@ func testSweepAllCoins(net *lntest.NetworkHarness, t *harnessTest) {
|
|||||||
t.Fatalf("unable to get node info: %v", err)
|
t.Fatalf("unable to get node info: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Create a label that we will used to label the transaction with.
|
||||||
|
sendCoinsLabel := "send all coins"
|
||||||
|
|
||||||
sweepReq := &lnrpc.SendCoinsRequest{
|
sweepReq := &lnrpc.SendCoinsRequest{
|
||||||
Addr: info.IdentityPubkey,
|
Addr: info.IdentityPubkey,
|
||||||
SendAll: true,
|
SendAll: true,
|
||||||
|
Label: sendCoinsLabel,
|
||||||
}
|
}
|
||||||
_, err = ainz.SendCoins(ctxt, sweepReq)
|
_, err = ainz.SendCoins(ctxt, sweepReq)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
@ -12504,6 +12508,7 @@ func testSweepAllCoins(net *lntest.NetworkHarness, t *harnessTest) {
|
|||||||
sweepReq = &lnrpc.SendCoinsRequest{
|
sweepReq = &lnrpc.SendCoinsRequest{
|
||||||
Addr: info.IdentityPubkey,
|
Addr: info.IdentityPubkey,
|
||||||
SendAll: true,
|
SendAll: true,
|
||||||
|
Label: sendCoinsLabel,
|
||||||
}
|
}
|
||||||
_, err = ainz.SendCoins(ctxt, sweepReq)
|
_, err = ainz.SendCoins(ctxt, sweepReq)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
@ -12522,6 +12527,7 @@ func testSweepAllCoins(net *lntest.NetworkHarness, t *harnessTest) {
|
|||||||
sweepReq = &lnrpc.SendCoinsRequest{
|
sweepReq = &lnrpc.SendCoinsRequest{
|
||||||
Addr: "tb1qfc8fusa98jx8uvnhzavxccqlzvg749tvjw82tg",
|
Addr: "tb1qfc8fusa98jx8uvnhzavxccqlzvg749tvjw82tg",
|
||||||
SendAll: true,
|
SendAll: true,
|
||||||
|
Label: sendCoinsLabel,
|
||||||
}
|
}
|
||||||
_, err = ainz.SendCoins(ctxt, sweepReq)
|
_, err = ainz.SendCoins(ctxt, sweepReq)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
@ -12533,6 +12539,7 @@ func testSweepAllCoins(net *lntest.NetworkHarness, t *harnessTest) {
|
|||||||
sweepReq = &lnrpc.SendCoinsRequest{
|
sweepReq = &lnrpc.SendCoinsRequest{
|
||||||
Addr: "1MPaXKp5HhsLNjVSqaL7fChE3TVyrTMRT3",
|
Addr: "1MPaXKp5HhsLNjVSqaL7fChE3TVyrTMRT3",
|
||||||
SendAll: true,
|
SendAll: true,
|
||||||
|
Label: sendCoinsLabel,
|
||||||
}
|
}
|
||||||
_, err = ainz.SendCoins(ctxt, sweepReq)
|
_, err = ainz.SendCoins(ctxt, sweepReq)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
@ -12548,6 +12555,7 @@ func testSweepAllCoins(net *lntest.NetworkHarness, t *harnessTest) {
|
|||||||
sweepReq = &lnrpc.SendCoinsRequest{
|
sweepReq = &lnrpc.SendCoinsRequest{
|
||||||
Addr: minerAddr.String(),
|
Addr: minerAddr.String(),
|
||||||
SendAll: true,
|
SendAll: true,
|
||||||
|
Label: sendCoinsLabel,
|
||||||
}
|
}
|
||||||
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
|
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
|
||||||
_, err = ainz.SendCoins(ctxt, sweepReq)
|
_, err = ainz.SendCoins(ctxt, sweepReq)
|
||||||
@ -12566,6 +12574,24 @@ func testSweepAllCoins(net *lntest.NetworkHarness, t *harnessTest) {
|
|||||||
t.Fatalf("expected 2 inputs instead have %v", len(sweepTx.TxIn))
|
t.Fatalf("expected 2 inputs instead have %v", len(sweepTx.TxIn))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// List all transactions relevant to our wallet, and find the sweep tx
|
||||||
|
// so that we can check the correct label has been set.
|
||||||
|
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
|
||||||
|
txResp, err := ainz.GetTransactions(ctxt, &lnrpc.GetTransactionsRequest{})
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("could not get transactions: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
sweepTxStr := sweepTx.TxHash().String()
|
||||||
|
for _, txn := range txResp.Transactions {
|
||||||
|
if txn.TxHash == sweepTxStr {
|
||||||
|
if txn.Label != sendCoinsLabel {
|
||||||
|
t.Fatalf("expected label: %v, got: %v",
|
||||||
|
sendCoinsLabel, txn.Label)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Finally, Ainz should now have no coins at all within his wallet.
|
// Finally, Ainz should now have no coins at all within his wallet.
|
||||||
balReq := &lnrpc.WalletBalanceRequest{}
|
balReq := &lnrpc.WalletBalanceRequest{}
|
||||||
resp, err := ainz.WalletBalance(ctxt, balReq)
|
resp, err := ainz.WalletBalance(ctxt, balReq)
|
||||||
|
Loading…
Reference in New Issue
Block a user