Skip to content

Commit 16879ce

Browse files
committed
Fix message handling tests
The tests use the eon instead of the keyper config index in the eon fields of messages. They also prevented messages with duplicate identity preimages which are used in Shutterized Gnosis Chain.
1 parent 7033ed4 commit 16879ce

File tree

1 file changed

+10
-28
lines changed

1 file changed

+10
-28
lines changed

rolling-shutter/keyper/epochkghandler/keyshare_test.go

Lines changed: 10 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ func TestHandleDecryptionKeyShareIntegration(t *testing.T) {
3232
identityPreimages = append(identityPreimages, identityPreimage)
3333
}
3434
keyperIndex := uint64(1)
35+
keyperConfigIndex := uint64(1)
3536

3637
tkg := testsetup.InitializeEon(ctx, t, dbpool, config, keyperIndex)
3738
var handler p2p.MessageHandler = &DecryptionKeyShareHandler{config: config, dbpool: dbpool}
@@ -52,7 +53,7 @@ func TestHandleDecryptionKeyShareIntegration(t *testing.T) {
5253
}
5354
msgs := p2ptest.MustHandleMessage(t, handler, ctx, &p2pmsg.DecryptionKeyShares{
5455
InstanceID: config.GetInstanceID(),
55-
Eon: config.GetEon(),
56+
Eon: keyperConfigIndex,
5657
KeyperIndex: 0,
5758
Shares: shares,
5859
})
@@ -70,7 +71,7 @@ func TestHandleDecryptionKeyShareIntegration(t *testing.T) {
7071
}
7172
msgs = p2ptest.MustHandleMessage(t, handler, ctx, &p2pmsg.DecryptionKeyShares{
7273
InstanceID: config.GetInstanceID(),
73-
Eon: config.GetEon(),
74+
Eon: keyperConfigIndex,
7475
KeyperIndex: 2,
7576
Shares: shares,
7677
})
@@ -96,7 +97,7 @@ func TestDecryptionKeyshareValidatorIntegration(t *testing.T) {
9697
t.Cleanup(dbclose)
9798

9899
keyperIndex := uint64(1)
99-
eon := config.GetEon()
100+
keyperConfigIndex := uint64(1)
100101
identityPreimage := identitypreimage.BigToIdentityPreimage(common.Big0)
101102
secondIdentityPreimage := identitypreimage.BigToIdentityPreimage(common.Big1)
102103
wrongIdentityPreimage := identitypreimage.BigToIdentityPreimage(common.Big2)
@@ -115,7 +116,7 @@ func TestDecryptionKeyshareValidatorIntegration(t *testing.T) {
115116
validationResult: pubsub.ValidationAccept,
116117
msg: &p2pmsg.DecryptionKeyShares{
117118
InstanceID: config.GetInstanceID(),
118-
Eon: eon,
119+
Eon: keyperConfigIndex,
119120
KeyperIndex: keyperIndex,
120121
Shares: []*p2pmsg.KeyShare{
121122
{
@@ -134,7 +135,7 @@ func TestDecryptionKeyshareValidatorIntegration(t *testing.T) {
134135
validationResult: pubsub.ValidationReject,
135136
msg: &p2pmsg.DecryptionKeyShares{
136137
InstanceID: config.GetInstanceID(),
137-
Eon: eon,
138+
Eon: keyperConfigIndex,
138139
KeyperIndex: keyperIndex,
139140
Shares: []*p2pmsg.KeyShare{
140141
{
@@ -149,7 +150,7 @@ func TestDecryptionKeyshareValidatorIntegration(t *testing.T) {
149150
validationResult: pubsub.ValidationReject,
150151
msg: &p2pmsg.DecryptionKeyShares{
151152
InstanceID: config.GetInstanceID() + 1,
152-
Eon: eon,
153+
Eon: keyperConfigIndex,
153154
KeyperIndex: keyperIndex,
154155
Shares: []*p2pmsg.KeyShare{
155156
{
@@ -164,7 +165,7 @@ func TestDecryptionKeyshareValidatorIntegration(t *testing.T) {
164165
validationResult: pubsub.ValidationReject,
165166
msg: &p2pmsg.DecryptionKeyShares{
166167
InstanceID: config.GetInstanceID(),
167-
Eon: eon,
168+
Eon: keyperConfigIndex,
168169
KeyperIndex: keyperIndex + 1,
169170
Shares: []*p2pmsg.KeyShare{
170171
{
@@ -179,36 +180,17 @@ func TestDecryptionKeyshareValidatorIntegration(t *testing.T) {
179180
validationResult: pubsub.ValidationReject,
180181
msg: &p2pmsg.DecryptionKeyShares{
181182
InstanceID: config.GetInstanceID(),
182-
Eon: eon,
183+
Eon: keyperConfigIndex,
183184
KeyperIndex: keyperIndex,
184185
Shares: []*p2pmsg.KeyShare{},
185186
},
186187
},
187-
{
188-
name: "invalid decryption key share duplicate",
189-
validationResult: pubsub.ValidationReject,
190-
msg: &p2pmsg.DecryptionKeyShares{
191-
InstanceID: config.GetInstanceID(),
192-
Eon: eon,
193-
KeyperIndex: keyperIndex,
194-
Shares: []*p2pmsg.KeyShare{
195-
{
196-
EpochID: identityPreimage.Bytes(),
197-
Share: keyshare,
198-
},
199-
{
200-
EpochID: identityPreimage.Bytes(),
201-
Share: keyshare,
202-
},
203-
},
204-
},
205-
},
206188
{
207189
name: "invalid decryption key share unordered",
208190
validationResult: pubsub.ValidationReject,
209191
msg: &p2pmsg.DecryptionKeyShares{
210192
InstanceID: config.GetInstanceID(),
211-
Eon: eon,
193+
Eon: keyperConfigIndex,
212194
KeyperIndex: keyperIndex,
213195
Shares: []*p2pmsg.KeyShare{
214196
{

0 commit comments

Comments
 (0)