contractcourt: revamp HTLC success unit test

We add checkpoint assertions and resume the resolver from every
checkpoint to ensure it can handle restarts.
This commit is contained in:
Johan T. Halseth committed 2020-12-10 14:24:20 +01:00
1 parent 7142a302c9
commit d02b486195
2 files changed
+232 -74

No files matched your search

+12 -8
View File
@@ -103,17 +103,19 @@ func (i *commitSweepResolverTestContext) waitForResult() {
}
type mockSweeper struct {
sweptInputs chan input.Input
updatedInputs chan wire.OutPoint
sweepTx *wire.MsgTx
sweepErr error
sweptInputs chan input.Input
updatedInputs chan wire.OutPoint
sweepTx *wire.MsgTx
sweepErr error
createSweepTxChan chan *wire.MsgTx
}
func newMockSweeper() *mockSweeper {
return &mockSweeper{
sweptInputs: make(chan input.Input),
updatedInputs: make(chan wire.OutPoint),
sweepTx: &wire.MsgTx{},
sweptInputs: make(chan input.Input),
updatedInputs: make(chan wire.OutPoint),
sweepTx: &wire.MsgTx{},
createSweepTxChan: make(chan *wire.MsgTx),
}
}
@@ -133,7 +135,9 @@ func (s *mockSweeper) SweepInput(input input.Input, params sweep.Params) (
func (s *mockSweeper) CreateSweepTx(inputs []input.Input, feePref sweep.FeePreference,
currentBlockHeight uint32) (*wire.MsgTx, error) {
return nil, nil
// We will wait for the test to supply the sweep tx to return.
sweepTx := <-s.createSweepTxChan
return sweepTx, nil
}
func (s *mockSweeper) RelayFeePerKW() chainfee.SatPerKWeight {