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 14, 2025
1 parent 79f1441 commit fbd271f
Showing 1 changed file with 41 additions and 16 deletions.
57 changes: 41 additions & 16 deletions chainio/clients/elcontracts/writer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ func TestRegisterOperator(t *testing.T) {
})
}

func TestRegisterForOperatorSets(t *testing.T) {
func TestRegisterAndDeregisterFromOperatorSets(t *testing.T) {
testConfig := testutils.GetDefaultTestConfig()
anvilC, err := testutils.StartAnvilContainer(testConfig.AnvilStateFileName)
require.NoError(t, err)
Expand Down Expand Up @@ -171,24 +171,49 @@ func TestRegisterForOperatorSets(t *testing.T) {
Avs: avsAddress,
Id: uint32(operatorSetId),
}
t.Run("register operator for operator set", func(t *testing.T) {
registryCoordinatorAddress := contractAddrs.RegistryCoordinator
receipt, err := chainWriter.RegisterForOperatorSets(
context.Background(),
registryCoordinatorAddress,
request,
)

registryCoordinatorAddress := contractAddrs.RegistryCoordinator
receipt, err := chainWriter.RegisterForOperatorSets(
context.Background(),
registryCoordinatorAddress,
request,
)
require.NoError(t, err)
require.Equal(t, gethtypes.ReceiptStatusSuccessful, receipt.Status)

require.NoError(t, err)
require.Equal(t, gethtypes.ReceiptStatusSuccessful, receipt.Status)
isRegistered, err := chainReader.IsOperatorRegisteredWithOperatorSet(
context.Background(),
operatorAddress,
operatorSet,
)
require.NoError(t, err)
require.Equal(t, true, isRegistered)
})

isRegistered, err := chainReader.IsOperatorRegisteredWithOperatorSet(
context.Background(),
operatorAddress,
operatorSet,
)
require.NoError(t, err)
require.Equal(t, isRegistered, true)
deregistrationRequest := elcontracts.DeregistrationRequest{
AVSAddress: avsAddress,
OperatorSetIds: []uint32{operatorSetId},
WaitForReceipt: true,
}

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

isRegistered, err := chainReader.IsOperatorRegisteredWithOperatorSet(
context.Background(),
operatorAddress,
operatorSet,
)
require.NoError(t, err)
require.Equal(t, false, isRegistered)
})
}

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

0 comments on commit fbd271f

Please sign in to comment.