-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Expose confirmation count for pending 'channel open' transactions #9677
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
6e2bdd0
eda86d1
a72e4fe
d5a6f55
88c2b30
a45ae64
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -271,12 +271,14 @@ func TestTxNotifierFutureConfDispatch(t *testing.T) { | |
// We should only receive one update for tx1 since it only requires | ||
// one confirmation and it already met it. | ||
select { | ||
case numConfsLeft := <-ntfn1.Event.Updates: | ||
const expected = 0 | ||
if numConfsLeft != expected { | ||
case updDetails := <-ntfn1.Event.Updates: | ||
expected := chainntnfs.TxUpdateInfo{ | ||
NumConfsLeft: 0, | ||
BlockHeight: 11, | ||
} | ||
if !updDetails.Equal(&expected) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry for the different signal here, but we should just update tests to use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Makes sense. Should I also remove the convenience methods from There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Cool, if the convenience methods are not used after this change yeah we can remove it. |
||
t.Fatalf("Received incorrect confirmation update: tx1 "+ | ||
"expected %d confirmations left, got %d", | ||
expected, numConfsLeft) | ||
"expected %s, got %s", expected, updDetails) | ||
} | ||
default: | ||
t.Fatal("Expected confirmation update for tx1") | ||
|
@@ -300,12 +302,14 @@ func TestTxNotifierFutureConfDispatch(t *testing.T) { | |
// We should only receive one update for tx2 since it only has one | ||
// confirmation so far and it requires two. | ||
select { | ||
case numConfsLeft := <-ntfn2.Event.Updates: | ||
const expected = 1 | ||
if numConfsLeft != expected { | ||
case updDetails := <-ntfn2.Event.Updates: | ||
expected := chainntnfs.TxUpdateInfo{ | ||
NumConfsLeft: 1, | ||
BlockHeight: 11, | ||
} | ||
if !updDetails.Equal(&expected) { | ||
t.Fatalf("Received incorrect confirmation update: tx2 "+ | ||
"expected %d confirmations left, got %d", | ||
expected, numConfsLeft) | ||
"expected %s, got %s", expected, updDetails) | ||
} | ||
default: | ||
t.Fatal("Expected confirmation update for tx2") | ||
|
@@ -341,12 +345,14 @@ func TestTxNotifierFutureConfDispatch(t *testing.T) { | |
// We should only receive one update since the last at the new height, | ||
// indicating how many confirmations are still left. | ||
select { | ||
case numConfsLeft := <-ntfn2.Event.Updates: | ||
const expected = 0 | ||
if numConfsLeft != expected { | ||
case updDetails := <-ntfn2.Event.Updates: | ||
expected := chainntnfs.TxUpdateInfo{ | ||
NumConfsLeft: 0, | ||
BlockHeight: 11, | ||
} | ||
if !updDetails.Equal(&expected) { | ||
t.Fatalf("Received incorrect confirmation update: tx2 "+ | ||
"expected %d confirmations left, got %d", | ||
expected, numConfsLeft) | ||
"expected %s, got %s", expected, updDetails) | ||
} | ||
default: | ||
t.Fatal("Expected confirmation update for tx2") | ||
|
@@ -411,12 +417,14 @@ func TestTxNotifierHistoricalConfDispatch(t *testing.T) { | |
err = n.UpdateConfDetails(ntfn1.HistoricalDispatch.ConfRequest, &txConf1) | ||
require.NoError(t, err, "unable to update conf details") | ||
select { | ||
case numConfsLeft := <-ntfn1.Event.Updates: | ||
const expected = 0 | ||
if numConfsLeft != expected { | ||
case updDetails := <-ntfn1.Event.Updates: | ||
expected := chainntnfs.TxUpdateInfo{ | ||
NumConfsLeft: 0, | ||
BlockHeight: 9, | ||
} | ||
if !updDetails.Equal(&expected) { | ||
t.Fatalf("Received incorrect confirmation update: tx1 "+ | ||
"expected %d confirmations left, got %d", | ||
expected, numConfsLeft) | ||
"expected %s, got %s", expected, updDetails) | ||
} | ||
default: | ||
t.Fatal("Expected confirmation update for tx1") | ||
|
@@ -443,12 +451,14 @@ func TestTxNotifierHistoricalConfDispatch(t *testing.T) { | |
err = n.UpdateConfDetails(ntfn2.HistoricalDispatch.ConfRequest, &txConf2) | ||
require.NoError(t, err, "unable to update conf details") | ||
select { | ||
case numConfsLeft := <-ntfn2.Event.Updates: | ||
const expected = 1 | ||
if numConfsLeft != expected { | ||
case updDetails := <-ntfn2.Event.Updates: | ||
expected := chainntnfs.TxUpdateInfo{ | ||
NumConfsLeft: 1, | ||
BlockHeight: 9, | ||
} | ||
if !updDetails.Equal(&expected) { | ||
t.Fatalf("Received incorrect confirmation update: tx2 "+ | ||
"expected %d confirmations left, got %d", | ||
expected, numConfsLeft) | ||
"expected %s, got %s", expected, updDetails) | ||
} | ||
default: | ||
t.Fatal("Expected confirmation update for tx2") | ||
|
@@ -485,12 +495,14 @@ func TestTxNotifierHistoricalConfDispatch(t *testing.T) { | |
// We should only receive one update for tx2 since the last one, | ||
// indicating how many confirmations are still left. | ||
select { | ||
case numConfsLeft := <-ntfn2.Event.Updates: | ||
const expected = 0 | ||
if numConfsLeft != expected { | ||
case updDetails := <-ntfn2.Event.Updates: | ||
expected := chainntnfs.TxUpdateInfo{ | ||
NumConfsLeft: 0, | ||
BlockHeight: 9, | ||
} | ||
if !updDetails.Equal(&expected) { | ||
t.Fatalf("Received incorrect confirmation update: tx2 "+ | ||
"expected %d confirmations left, got %d", | ||
expected, numConfsLeft) | ||
"expected %s, got %s", expected, updDetails) | ||
} | ||
default: | ||
t.Fatal("Expected confirmation update for tx2") | ||
|
@@ -1490,12 +1502,14 @@ func TestTxNotifierConfReorg(t *testing.T) { | |
// We should only receive one update for tx2 since it only requires | ||
// one confirmation and it already met it. | ||
select { | ||
case numConfsLeft := <-ntfn2.Event.Updates: | ||
const expected = 0 | ||
if numConfsLeft != expected { | ||
case updDetails := <-ntfn2.Event.Updates: | ||
expected := chainntnfs.TxUpdateInfo{ | ||
NumConfsLeft: 0, | ||
BlockHeight: 12, | ||
} | ||
if !updDetails.Equal(&expected) { | ||
t.Fatalf("Received incorrect confirmation update: tx2 "+ | ||
"expected %d confirmations left, got %d", | ||
expected, numConfsLeft) | ||
"expected %s, got %s", expected, updDetails) | ||
} | ||
default: | ||
t.Fatal("Expected confirmation update for tx2") | ||
|
@@ -1520,15 +1534,18 @@ func TestTxNotifierConfReorg(t *testing.T) { | |
// confirmations and it has already met them. | ||
for i := uint32(1); i <= 2; i++ { | ||
select { | ||
case numConfsLeft := <-ntfn3.Event.Updates: | ||
expected := tx3NumConfs - i | ||
if numConfsLeft != expected { | ||
t.Fatalf("Received incorrect confirmation update: tx3 "+ | ||
"expected %d confirmations left, got %d", | ||
expected, numConfsLeft) | ||
case updDetails := <-ntfn3.Event.Updates: | ||
expected := chainntnfs.TxUpdateInfo{ | ||
NumConfsLeft: tx3NumConfs - i, | ||
BlockHeight: 12, | ||
} | ||
if !updDetails.Equal(&expected) { | ||
t.Fatalf("Received incorrect confirmation "+ | ||
"update: tx3 expected %s, got %s", | ||
expected, updDetails) | ||
} | ||
default: | ||
t.Fatal("Expected confirmation update for tx2") | ||
t.Fatal("Expected confirmation update for tx3") | ||
} | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I recommend adding some convenience methods to this struct which can then be used by tests:
this make sure we always compare all values rather then having to compare them separately as seen in the tests.