Skip to content

Commit

Permalink
test DeregisterFromOperatorSets method
Browse files Browse the repository at this point in the history
  • Loading branch information
ricomateo committed Jan 9, 2025
1 parent 9a79bd5 commit a862fda
Showing 1 changed file with 37 additions and 16 deletions.
53 changes: 37 additions & 16 deletions chainio/clients/elcontracts/writer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,7 @@ func newTestChainWriterFromConfig(
return testWriter, nil
}

func TestRegisterForOperatorSets(t *testing.T) {
func TestRegisterAndDeregisterFromOperatorSets(t *testing.T) {
eigenClients, anvilHttpEndpoint := testclients.BuildTestClients(t)
contractAddrs := testutils.GetContractAddressesFromContractRegistry(anvilHttpEndpoint)

Expand Down Expand Up @@ -548,23 +548,44 @@ func TestRegisterForOperatorSets(t *testing.T) {
}

registryCoordinatorAddress := contractAddrs.RegistryCoordinator
receipt, err := operatorClients.ElChainWriter.RegisterForOperatorSets(
context.Background(),
registryCoordinatorAddress,
request,
)
t.Run("register operator for operator set", func(t *testing.T) {
receipt, err := operatorClients.ElChainWriter.RegisterForOperatorSets(
context.Background(),
registryCoordinatorAddress,
request,
)

require.NoError(t, err)
const RECEIPT_SUCCESS_STATUS = uint64(1)
require.Equal(t, RECEIPT_SUCCESS_STATUS, receipt.Status)
require.NoError(t, err)
require.Equal(t, SUCCESS_STATUS, receipt.Status)

isRegistered, err := operatorClients.ElChainReader.IsOperatorRegisteredWithOperatorSet(
context.Background(),
operatorAddress,
operatorSet,
)
require.NoError(t, err)
require.Equal(t, isRegistered, true)
isRegistered, err := operatorClients.ElChainReader.IsOperatorRegisteredWithOperatorSet(
context.Background(),
operatorAddress,
operatorSet,
)
require.NoError(t, err)
require.True(t, isRegistered)
})

deregistrationRequest := elcontracts.DeregistrationRequest{
AVSAddress: avsAddress,
OperatorSetIds: []uint32{operatorSetId},
WaitForReceipt: true,
}

t.Run("deregister operator from operator set", func(t *testing.T) {
receipt, err := operatorClients.ElChainWriter.DeregisterFromOperatorSets(context.Background(), operatorAddress, deregistrationRequest)
require.Equal(t, SUCCESS_STATUS, receipt.Status)
require.NoError(t, err)

isRegistered, err := operatorClients.ElChainReader.IsOperatorRegisteredWithOperatorSet(
context.Background(),
operatorAddress,
operatorSet,
)
require.NoError(t, err)
require.False(t, isRegistered)
})
}

func TestModifyAllocations(t *testing.T) {
Expand Down

0 comments on commit a862fda

Please sign in to comment.