From 61da2da9a3c90f79852515d0d4d11e5aa82fb460 Mon Sep 17 00:00:00 2001 From: Robert Raynor <35671663+mooselumph@users.noreply.github.com> Date: Fri, 2 Feb 2024 03:00:28 +0000 Subject: [PATCH] Fix integ tests --- .github/workflows/integration-tests.yml | 2 +- churner/tests/churner_test.go | 34 ++++--------------------- core/indexer/state_test.go | 4 +-- 3 files changed, 8 insertions(+), 32 deletions(-) diff --git a/.github/workflows/integration-tests.yml b/.github/workflows/integration-tests.yml index e2c9771b7..6919959ad 100644 --- a/.github/workflows/integration-tests.yml +++ b/.github/workflows/integration-tests.yml @@ -83,7 +83,7 @@ jobs: run: make build && go test -v ./core/thegraph - name: Inabox E2E - run: make build && cd inabox && make run-e2e-nochurner + run: make build && cd inabox && make run-e2e - name: Save logs if: always() diff --git a/churner/tests/churner_test.go b/churner/tests/churner_test.go index fe9218c18..f2ba7b8ed 100644 --- a/churner/tests/churner_test.go +++ b/churner/tests/churner_test.go @@ -2,11 +2,9 @@ package test import ( "context" - "crypto/rand" "flag" "fmt" "log" - "math/big" "os" "testing" @@ -39,7 +37,7 @@ var ( logger = &commock.Logger{} mockIndexer = &indexermock.MockIndexedChainState{} rpcURL = "http://localhost:8545" - quorumIds = []uint32{0} + quorumIds = []uint32{0, 1} operatorAddr = gethcommon.HexToAddress("0x0000000000000000000000000000000000000001") churnerPrivateKeyHex = "ac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80" operatorToChurnInPrivateKeyHex = "0000000000000000000000000000000000000000000000000000000000000020" @@ -91,39 +89,14 @@ func teardown() { func TestChurner(t *testing.T) { ctx := context.Background() - // get the operator to churn in's transactor and bls public key registered - op := testConfig.Operators[0] - operatorTransactor, err := createTransactorFromScratch( - op.NODE_PRIVATE_KEY, - testConfig.EigenDA.OperatorStateRetreiver, - testConfig.EigenDA.ServiceManager, - logger, - ) - assert.NoError(t, err) - keyPair, err := dacore.GenRandomBlsKeys() assert.NoError(t, err) - quorumIds_ := make([]uint8, len(quorumIds)) - for i, q := range quorumIds { - quorumIds_[i] = uint8(q) - } - - operatorSalt := [32]byte{} - _, err = rand.Read(operatorSalt[:]) - assert.NoError(t, err) - - expiry := big.NewInt(1000) - privKey, err := crypto.GenerateKey() - assert.NoError(t, err) - - err = operatorTransactor.RegisterOperator(ctx, keyPair, "socket", quorumIds_, privKey, operatorSalt, expiry) - assert.NoError(t, err) - server := newTestServer(t) salt := crypto.Keccak256([]byte(operatorToChurnInPrivateKeyHex), []byte("ChurnRequest")) request := &pb.ChurnRequest{ + OperatorAddress: operatorAddr.Hex(), OperatorToRegisterPubkeyG1: keyPair.PubKey.Serialize(), OperatorToRegisterPubkeyG2: keyPair.GetPubKeyG2().Serialize(), Salt: salt, @@ -133,6 +106,7 @@ func TestChurner(t *testing.T) { var requestHash [32]byte requestHashBytes := crypto.Keccak256( []byte("ChurnRequest"), + []byte(request.OperatorAddress), request.OperatorToRegisterPubkeyG1, request.OperatorToRegisterPubkeyG2, request.Salt, @@ -147,6 +121,7 @@ func TestChurner(t *testing.T) { }, nil) reply, err := server.Churn(ctx, request) + assert.NoError(t, err) assert.NotNil(t, reply) assert.NotNil(t, reply.SignatureWithSaltAndExpiry.GetSalt()) @@ -159,6 +134,7 @@ func TestChurner(t *testing.T) { assert.Equal(t, operatorAddr.Bytes(), param.GetOperator()) assert.Equal(t, keyPair.PubKey.Serialize(), param.GetPubkey()) } + } func createTransactorFromScratch(privateKey, operatorStateRetriever, serviceManager string, logger common.Logger) (*eth.Transactor, error) { diff --git a/core/indexer/state_test.go b/core/indexer/state_test.go index 8c0e01556..b836d05e5 100644 --- a/core/indexer/state_test.go +++ b/core/indexer/state_test.go @@ -58,8 +58,8 @@ func mustRegisterOperators(env *deploy.Config, logger common.Logger) { _, err = rand.Read(salt[:]) Expect(err).To(BeNil()) - expiry := big.NewInt(1000) - privKey, err := crypto.GenerateKey() + expiry := big.NewInt((time.Now().Add(10 * time.Minute)).Unix()) + privKey, err := crypto.HexToECDSA(op.NODE_PRIVATE_KEY) Expect(err).To(BeNil()) err = tx.RegisterOperator(context.Background(), keyPair, socket, quorums, privKey, salt, expiry)