multi: allow mock aux signer to customize sig jobs

This commit is contained in:
Jonathan Harvey-Buschel
2024-10-17 13:38:27 +02:00
committed by Oliver Gugger
parent 395a761eb6
commit b3f953b1c4
5 changed files with 32 additions and 12 deletions

View File

@@ -443,9 +443,26 @@ func (*MockAuxLeafStore) ApplyHtlcView(
return fn.Ok(fn.None[tlv.Blob]())
}
// EmptyMockJobHandler is a mock job handler that just sends an empty response
// to all jobs.
func EmptyMockJobHandler(jobs []AuxSigJob) {
for _, sigJob := range jobs {
sigJob.Resp <- AuxSigJobResp{}
}
}
// MockAuxSigner is a mock implementation of the AuxSigner interface.
type MockAuxSigner struct {
mock.Mock
jobHandlerFunc func([]AuxSigJob)
}
// NewAuxSignerMock creates a new mock aux signer with the given job handler.
func NewAuxSignerMock(jobHandler func([]AuxSigJob)) *MockAuxSigner {
return &MockAuxSigner{
jobHandlerFunc: jobHandler,
}
}
// SubmitSecondLevelSigBatch takes a batch of aux sign jobs and
@@ -455,10 +472,8 @@ func (a *MockAuxSigner) SubmitSecondLevelSigBatch(chanState AuxChanState,
args := a.Called(chanState, tx, jobs)
// While we return, we'll also send back an instant response for the
// set of jobs.
for _, sigJob := range jobs {
sigJob.Resp <- AuxSigJobResp{}
if a.jobHandlerFunc != nil {
a.jobHandlerFunc(jobs)
}
return args.Error(0)