Skip to content

Commit

Permalink
test/signer_mock: return signatures of real size
Browse files Browse the repository at this point in the history
Size of a signature affects the weight of transaction, which is verified
in tests.

Also method SignOutputRaw now returns the number of signatures matching
the number of signature descriptors to prevent crashes in tests where
multiple inputs are signed.
  • Loading branch information
starius committed Jul 18, 2024
1 parent 3303780 commit 6627368
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions test/signer_mock.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,12 @@ func (s *mockSigner) SignOutputRaw(ctx context.Context, tx *wire.MsgTx,
SignDescriptors: signDescriptors,
}

rawSigs := [][]byte{{1, 2, 3}}
rawSigs := make([][]byte, len(signDescriptors))
for i := range signDescriptors {
sig := make([]byte, 64)
sig[0] = byte(i + 1)
rawSigs[i] = sig
}

return rawSigs, nil
}
Expand Down Expand Up @@ -118,7 +123,10 @@ func (s *mockSigner) MuSig2Sign(context.Context, [32]byte, [32]byte,
func (s *mockSigner) MuSig2CombineSig(context.Context, [32]byte,
[][]byte) (bool, []byte, error) {

return true, nil, nil
sig := make([]byte, 64)
sig[0] = 42

return true, sig, nil
}

// MuSig2Cleanup removes a session from memory to free up resources.
Expand Down

0 comments on commit 6627368

Please sign in to comment.