@@ -179,24 +179,22 @@ describe('HAKeyStore', () => {
179179 ) ;
180180 } ) ;
181181
182- it ( 'should return null when duty was already signed' , async ( ) => {
183- mockHASigner . signWithProtection . mockRejectedValue (
184- new DutyAlreadySignedError ( SlotNumber ( 100 ) , DutyType . BLOCK_PROPOSAL , 'other-node' ) ,
185- ) ;
186-
187- const result = await haKeyStore . signMessageWithAddress ( VALIDATOR_ADDRESS , SIGNING_ROOT , context ) ;
188-
189- expect ( result ) . toBeNull ( ) ;
190- } ) ;
182+ it ( 'should throw DutyAlreadySignedError when duty was already signed' , async ( ) => {
183+ const error = new DutyAlreadySignedError ( SlotNumber ( 100 ) , DutyType . BLOCK_PROPOSAL , 'other-node' ) ;
184+ mockHASigner . signWithProtection . mockRejectedValue ( error ) ;
191185
192- it ( 'should return null when slashing protection triggers' , async ( ) => {
193- mockHASigner . signWithProtection . mockRejectedValue (
194- new SlashingProtectionError ( SlotNumber ( 100 ) , DutyType . BLOCK_PROPOSAL , '0xexisting' , '0xattempted' ) ,
186+ await expect ( haKeyStore . signMessageWithAddress ( VALIDATOR_ADDRESS , SIGNING_ROOT , context ) ) . rejects . toThrow (
187+ DutyAlreadySignedError ,
195188 ) ;
189+ } ) ;
196190
197- const result = await haKeyStore . signMessageWithAddress ( VALIDATOR_ADDRESS , SIGNING_ROOT , context ) ;
191+ it ( 'should throw SlashingProtectionError when slashing protection triggers' , async ( ) => {
192+ const error = new SlashingProtectionError ( SlotNumber ( 100 ) , DutyType . BLOCK_PROPOSAL , '0xexisting' , '0xattempted' ) ;
193+ mockHASigner . signWithProtection . mockRejectedValue ( error ) ;
198194
199- expect ( result ) . toBeNull ( ) ;
195+ await expect ( haKeyStore . signMessageWithAddress ( VALIDATOR_ADDRESS , SIGNING_ROOT , context ) ) . rejects . toThrow (
196+ SlashingProtectionError ,
197+ ) ;
200198 } ) ;
201199
202200 it ( 'should re-throw unexpected errors' , async ( ) => {
@@ -270,24 +268,22 @@ describe('HAKeyStore', () => {
270268 ) ;
271269 } ) ;
272270
273- it ( 'should return null when duty was already signed' , async ( ) => {
274- mockHASigner . signWithProtection . mockRejectedValue (
275- new DutyAlreadySignedError ( SlotNumber ( 100 ) , DutyType . ATTESTATION , 'other-node' ) ,
276- ) ;
271+ it ( 'should throw DutyAlreadySignedError when duty was already signed' , async ( ) => {
272+ const error = new DutyAlreadySignedError ( SlotNumber ( 100 ) , DutyType . ATTESTATION , 'other-node' ) ;
273+ mockHASigner . signWithProtection . mockRejectedValue ( error ) ;
277274
278- const result = await haKeyStore . signTypedDataWithAddress ( VALIDATOR_ADDRESS , mockTypedData , context ) ;
279-
280- expect ( result ) . toBeNull ( ) ;
281- } ) ;
282-
283- it ( 'should return null when slashing protection triggers' , async ( ) => {
284- mockHASigner . signWithProtection . mockRejectedValue (
285- new SlashingProtectionError ( SlotNumber ( 100 ) , DutyType . ATTESTATION , '0xexisting' , '0xattempted' ) ,
275+ await expect ( haKeyStore . signTypedDataWithAddress ( VALIDATOR_ADDRESS , mockTypedData , context ) ) . rejects . toThrow (
276+ DutyAlreadySignedError ,
286277 ) ;
278+ } ) ;
287279
288- const result = await haKeyStore . signTypedDataWithAddress ( VALIDATOR_ADDRESS , mockTypedData , context ) ;
280+ it ( 'should throw SlashingProtectionError when slashing protection triggers' , async ( ) => {
281+ const error = new SlashingProtectionError ( SlotNumber ( 100 ) , DutyType . ATTESTATION , '0xexisting' , '0xattempted' ) ;
282+ mockHASigner . signWithProtection . mockRejectedValue ( error ) ;
289283
290- expect ( result ) . toBeNull ( ) ;
284+ await expect ( haKeyStore . signTypedDataWithAddress ( VALIDATOR_ADDRESS , mockTypedData , context ) ) . rejects . toThrow (
285+ SlashingProtectionError ,
286+ ) ;
291287 } ) ;
292288
293289 it ( 'should call base key store signTypedDataWithAddress through callback' , async ( ) => {
0 commit comments