Skip to content

Commit

Permalink
Add tests cases (second is not working)
Browse files Browse the repository at this point in the history
  • Loading branch information
maximopalopoli committed Jan 21, 2025
1 parent 9c61d80 commit e457239
Showing 1 changed file with 68 additions and 0 deletions.
68 changes: 68 additions & 0 deletions chainio/clients/avsregistry/writer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,16 @@ import (
"context"
"testing"

"github.com/Layr-Labs/eigensdk-go/chainio/clients/avsregistry"
chainioutils "github.com/Layr-Labs/eigensdk-go/chainio/utils"
regcoord "github.com/Layr-Labs/eigensdk-go/contracts/bindings/RegistryCoordinator"
"github.com/Layr-Labs/eigensdk-go/crypto/bls"
"github.com/Layr-Labs/eigensdk-go/testutils"
"github.com/Layr-Labs/eigensdk-go/testutils/testclients"
"github.com/Layr-Labs/eigensdk-go/types"
gethcommon "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/ethclient"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
Expand Down Expand Up @@ -87,6 +90,71 @@ func TestWriterMethods(t *testing.T) {
require.NoError(t, err)
require.NotNil(t, receipt)
})

t.Run("update socket", func(t *testing.T) {
receipt, err := chainWriter.RegisterOperator(
context.Background(),
ecdsaPrivateKey,
keypair,
quorumNumbers,
"",
true,
)
require.NoError(t, err)
require.NotNil(t, receipt)

receipt, err = chainWriter.UpdateSocket(
context.Background(),
types.Socket(""),
true,
)
require.NoError(t, err)
require.NotNil(t, receipt)
})

t.Run("deregister operator operator sets", func(t *testing.T) {
operator := types.Operator{
Address: testutils.ANVIL_FIRST_ADDRESS,
}

receipt, err := chainWriter.RegisterOperator(
context.Background(),
ecdsaPrivateKey,
keypair,
quorumNumbers,
"",
true,
)
require.NoError(t, err)
require.NotNil(t, receipt)

ethHttpClient, err := ethclient.Dial(anvilHttpEndpoint)
require.NoError(t, err)

registryCoordinatorAddress := contractAddrs.RegistryCoordinator
registryCoordinator, err := regcoord.NewContractRegistryCoordinator(
registryCoordinatorAddress,
ethHttpClient,
)
require.NoError(t, err)

txManager, err := testclients.NewTestTxManager(anvilHttpEndpoint, testutils.ANVIL_FIRST_PRIVATE_KEY)
require.NoError(t, err)

noSendTxOpts, err := txManager.GetNoSendTxOpts()
require.NoError(t, err)

tx, err := registryCoordinator.EnableOperatorSets(noSendTxOpts)
require.NoError(t, err)

_, err = txManager.Send(context.Background(), tx, true)
require.NoError(t, err)

// Failing because OperatorSetsNotSupported() err, which means operator was registered but not as set.
receipt, err = chainWriter.DeregisterOperatorOperatorSets(context.Background(), types.OperatorSetIds{0}, operator, chainioutils.ConvertToBN254G1Point(keypair.PubKey), true)
require.NoError(t, err)
require.NotNil(t, receipt)
})
}

// Compliance test for BLS signature
Expand Down

0 comments on commit e457239

Please sign in to comment.