Skip to content

Commit 2812c9e

Browse files
authored
Merge pull request #108 from 0xPolygon/feature/107-abs_signedSeq
add Set and Get for Signature of interface `SignedSequenceInterface`
2 parents 796e6c9 + 90d2f61 commit 2812c9e

File tree

5 files changed

+43
-0
lines changed

5 files changed

+43
-0
lines changed

types/interfaces.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,6 @@ type SignedSequenceInterface interface {
1111
Signer() (common.Address, error)
1212
OffChainData() []OffChainData
1313
Sign(privateKey *ecdsa.PrivateKey) (ArgBytes, error)
14+
SetSignature([]byte)
15+
GetSignature() []byte
1416
}

types/sequence.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,3 +84,13 @@ func (s *SignedSequence) OffChainData() []OffChainData {
8484
func (s *SignedSequence) Sign(privateKey *ecdsa.PrivateKey) (ArgBytes, error) {
8585
return s.Sequence.Sign(privateKey)
8686
}
87+
88+
// SetSignature set signature
89+
func (s *SignedSequence) SetSignature(sign []byte) {
90+
s.Signature = sign
91+
}
92+
93+
// GetSignature returns signature
94+
func (s *SignedSequence) GetSignature() []byte {
95+
return s.Signature
96+
}

types/sequence_test.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,10 @@ func TestSigning(t *testing.T) {
5656
}
5757
}
5858
}
59+
60+
func TestGetSetSignature(t *testing.T) {
61+
sut := SignedSequence{}
62+
signature := []byte{1, 2, 3}
63+
sut.SetSignature(signature)
64+
assert.Equal(t, signature, sut.GetSignature())
65+
}

types/sequencebanana.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,3 +114,13 @@ func (s *SignedSequenceBanana) OffChainData() []OffChainData {
114114
func (s *SignedSequenceBanana) Sign(privateKey *ecdsa.PrivateKey) (ArgBytes, error) {
115115
return s.Sequence.Sign(privateKey)
116116
}
117+
118+
// SetSignature set signature
119+
func (s *SignedSequenceBanana) SetSignature(sign []byte) {
120+
s.Signature = sign
121+
}
122+
123+
// GetSignature returns signature
124+
func (s *SignedSequenceBanana) GetSignature() []byte {
125+
return s.Signature
126+
}

types/sequencebanana_test.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package types
2+
3+
import (
4+
"testing"
5+
6+
"github.com/stretchr/testify/assert"
7+
)
8+
9+
func TestGetSetSignatureBanana(t *testing.T) {
10+
sut := SignedSequenceBanana{}
11+
signature := []byte{1, 2, 3}
12+
sut.SetSignature(signature)
13+
assert.Equal(t, signature, sut.GetSignature())
14+
}

0 commit comments

Comments
 (0)