-
Notifications
You must be signed in to change notification settings - Fork 2.3k
multi: resend shutdown on reestablish #8464
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
Changes from all commits
71753af
972f57e
8c064b8
987604e
dc25b42
5de7792
785790a
2fe8520
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 |
|---|---|---|
|
|
@@ -1158,6 +1158,70 @@ func TestFetchWaitingCloseChannels(t *testing.T) { | |
| } | ||
| } | ||
|
|
||
| // TestShutdownInfo tests that a channel's shutdown info can correctly be | ||
| // persisted and retrieved. | ||
| func TestShutdownInfo(t *testing.T) { | ||
| t.Parallel() | ||
|
|
||
| tests := []struct { | ||
| name string | ||
| localInit bool | ||
| }{ | ||
| { | ||
| name: "local node initiated", | ||
| localInit: true, | ||
| }, | ||
| { | ||
| name: "remote node initiated", | ||
| localInit: false, | ||
| }, | ||
| } | ||
|
|
||
| for _, test := range tests { | ||
| test := test | ||
|
|
||
| t.Run(test.name, func(t *testing.T) { | ||
| t.Parallel() | ||
|
|
||
| testShutdownInfo(t, test.localInit) | ||
| }) | ||
| } | ||
| } | ||
|
|
||
| func testShutdownInfo(t *testing.T, locallyInitiated bool) { | ||
| fullDB, err := MakeTestDB(t) | ||
| require.NoError(t, err, "unable to make test database") | ||
|
|
||
| cdb := fullDB.ChannelStateDB() | ||
|
|
||
| // First a test channel. | ||
| channel := createTestChannel(t, cdb) | ||
|
|
||
| // We haven't persisted any shutdown info for this channel yet. | ||
| _, err = channel.ShutdownInfo() | ||
| require.Error(t, err, ErrNoShutdownInfo) | ||
|
|
||
| // Construct a new delivery script and create a new ShutdownInfo object. | ||
| script := []byte{1, 3, 4, 5} | ||
|
|
||
| // Create a ShutdownInfo struct. | ||
| shutdownInfo := NewShutdownInfo(script, locallyInitiated) | ||
|
Comment on lines
1205
to
1208
Collaborator
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. The fact that this works implies we need to fix our type system. I figured we'd have to newtype wrap the byte array or use a constructor that lifts it into the DeliveryAddress. The test overall seems fine but I don't think you should be able to construct a DeliveryAddress that looks like this. Fixing it is better done in a diff PR though. |
||
|
|
||
| // Persist the shutdown info. | ||
| require.NoError(t, channel.MarkShutdownSent(shutdownInfo)) | ||
|
|
||
| // We should now be able to retrieve the shutdown info. | ||
| info, err := channel.ShutdownInfo() | ||
| require.NoError(t, err) | ||
| require.True(t, info.IsSome()) | ||
|
|
||
| // Assert that the decoded values of the shutdown info are correct. | ||
| info.WhenSome(func(info ShutdownInfo) { | ||
| require.EqualValues(t, script, info.DeliveryScript.Val) | ||
| require.Equal(t, locallyInitiated, info.LocalInitiator.Val) | ||
| }) | ||
| } | ||
|
|
||
| // TestRefresh asserts that Refresh updates the in-memory state of another | ||
| // OpenChannel to reflect a preceding call to MarkOpen on a different | ||
| // OpenChannel. | ||
|
|
||
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.
nit: I'm generally not a fan of things that end in "Info". Looking at this structure it seems to contain the Shutdown parameters, state, or metadata, but I'm not sure which of these is most appropriate. Ultimately if you think we should leave it as info, that's fine but just figured I'd mention it since in my experience "Info" is usually a stand-in for a more appropriate, more descriptive name.
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.
cool yeah gonna leave this one I think just cause in this case I cant really think of a better term & feel that Info is pretty appropriate because it contains a mixture of things we need to put in the shutdown message as well as other things about the shutdown that we should remember.