Skip to content

Commit

Permalink
go/signature: check consistent PrepareSignerMessage
Browse files Browse the repository at this point in the history
  • Loading branch information
pro-wh committed Mar 23, 2022
1 parent f515995 commit 0318535
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions go/common/crypto/signature/signer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,10 @@ func TestContext(t *testing.T) {
require.NoError(err, "PrepareSignerMessage should work")
require.NotEqual(msg3, msg4, "messages for different contexts should be different")

ctx5 := NewContext("test: dummy context 5", WithChainSeparation())
msg5, err := PrepareSignerMessage(ctx5, []byte("message"))
require.NoError(err, "PrepareSignerMessage before UnsafeResetChainContext")

// The remote signer requires bypassing the context registration checks.
UnsafeAllowUnregisteredContexts()
defer func() {
Expand All @@ -135,6 +139,10 @@ func TestContext(t *testing.T) {

_, err = PrepareSignerMessage(unregCtx, []byte("message"))
require.NoError(err, "PrepareSignerMessage should work with unregisered context (bypassed)")

msg5UAUC, err := PrepareSignerMessage(ctx5, []byte("message"))
require.NoError(err, "PrepareSignerMessage after UnsafeAllowUnregisteredContexts")
require.Equal(msg5, msg5UAUC, "message for same chain context should be same")
}

func TestSignerRoles(t *testing.T) {
Expand Down

0 comments on commit 0318535

Please sign in to comment.