channeldb: ensure restored channels can't be mutated

This commit is contained in:
Olaoluwa Osuntokun
2019-01-18 19:00:37 -08:00
parent 4fd1f832d7
commit 480ec3bbca
2 changed files with 42 additions and 0 deletions

View File

@@ -395,6 +395,22 @@ func TestRestoreChannelShells(t *testing.T) {
"pubkey: %v", err)
}
// Ensure that it isn't possible to modify the commitment state machine
// of this restored channel.
channel := nodeChans[0]
err = channel.UpdateCommitment(nil)
if err != ErrNoRestoredChannelMutation {
t.Fatalf("able to mutate restored channel")
}
err = channel.AppendRemoteCommitChain(nil)
if err != ErrNoRestoredChannelMutation {
t.Fatalf("able to mutate restored channel")
}
err = channel.AdvanceCommitChainTail(nil)
if err != ErrNoRestoredChannelMutation {
t.Fatalf("able to mutate restored channel")
}
// That single channel should have the proper channel point, and also
// the expected set of flags to indicate that it was a restored
// channel.