Skip to content

Commit

Permalink
Move defer after error check
Browse files Browse the repository at this point in the history
  • Loading branch information
damiramirez committed Jan 21, 2025
1 parent ad12dc3 commit 500af3c
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions chainio/clients/avsregistry/subscriber_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ func TestSubscriberAvsRegistry(t *testing.T) {

t.Run("subscribe to new pubkey registrations", func(t *testing.T) {
pubKeyRegistrationsC, event, err := chainSubscriber.SubscribeToNewPubkeyRegistrations()
defer event.Unsubscribe()
require.NoError(t, err)
defer event.Unsubscribe()

// Emit a NewPubkeyRegistration event creating a new operator
keypair, err := bls.NewKeyPairFromString("0x01")
require.NoError(t, err, "Failed to create BLS key pair")
require.NoError(t, err)

ecdsaPrivateKey, err := crypto.HexToECDSA(testutils.ANVIL_FIRST_PRIVATE_KEY)
require.NoError(t, err, "Failed to parse ECDSA private key")
require.NoError(t, err)

quorumNumbers := types.QuorumNums{0}

Expand All @@ -56,8 +56,8 @@ func TestSubscriberAvsRegistry(t *testing.T) {

t.Run("subscribe to operator socket updates", func(t *testing.T) {
socketC, event, err := chainSubscriber.SubscribeToOperatorSocketUpdates()
defer event.Unsubscribe()
require.NoError(t, err)
defer event.Unsubscribe()

// Emit a SocketUpdate event
socketUpdate := "socket-update"
Expand All @@ -70,7 +70,7 @@ func TestSubscriberAvsRegistry(t *testing.T) {
assert.Equal(t, socketUpdate, operatorSocketUpdate.Socket)
case <-time.After(10 * time.Second):
// Throw an error if the event is not received within 10 seconds, making the test fail
t.Fatal("Timed out waiting for NewPubkeyRegistration event")
t.Fatal("Timed out waiting for operatorSocketUpdate event")
}
})
}

0 comments on commit 500af3c

Please sign in to comment.