Skip to content

Commit

Permalink
Merge pull request #108 from 0xPolygon/feature/107-abs_signedSeq
Browse files Browse the repository at this point in the history
add Set and Get for Signature of interface `SignedSequenceInterface`
  • Loading branch information
joanestebanr authored Jul 22, 2024
2 parents 796e6c9 + 90d2f61 commit 2812c9e
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 0 deletions.
2 changes: 2 additions & 0 deletions types/interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,6 @@ type SignedSequenceInterface interface {
Signer() (common.Address, error)
OffChainData() []OffChainData
Sign(privateKey *ecdsa.PrivateKey) (ArgBytes, error)
SetSignature([]byte)
GetSignature() []byte
}
10 changes: 10 additions & 0 deletions types/sequence.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,13 @@ func (s *SignedSequence) OffChainData() []OffChainData {
func (s *SignedSequence) Sign(privateKey *ecdsa.PrivateKey) (ArgBytes, error) {
return s.Sequence.Sign(privateKey)
}

// SetSignature set signature
func (s *SignedSequence) SetSignature(sign []byte) {
s.Signature = sign
}

// GetSignature returns signature
func (s *SignedSequence) GetSignature() []byte {
return s.Signature
}
7 changes: 7 additions & 0 deletions types/sequence_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,10 @@ func TestSigning(t *testing.T) {
}
}
}

func TestGetSetSignature(t *testing.T) {
sut := SignedSequence{}
signature := []byte{1, 2, 3}
sut.SetSignature(signature)
assert.Equal(t, signature, sut.GetSignature())
}
10 changes: 10 additions & 0 deletions types/sequencebanana.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,3 +114,13 @@ func (s *SignedSequenceBanana) OffChainData() []OffChainData {
func (s *SignedSequenceBanana) Sign(privateKey *ecdsa.PrivateKey) (ArgBytes, error) {
return s.Sequence.Sign(privateKey)
}

// SetSignature set signature
func (s *SignedSequenceBanana) SetSignature(sign []byte) {
s.Signature = sign
}

// GetSignature returns signature
func (s *SignedSequenceBanana) GetSignature() []byte {
return s.Signature
}
14 changes: 14 additions & 0 deletions types/sequencebanana_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package types

import (
"testing"

"github.com/stretchr/testify/assert"
)

func TestGetSetSignatureBanana(t *testing.T) {
sut := SignedSequenceBanana{}
signature := []byte{1, 2, 3}
sut.SetSignature(signature)
assert.Equal(t, signature, sut.GetSignature())
}

0 comments on commit 2812c9e

Please sign in to comment.