@@ -14,18 +14,22 @@ import (
1414 "time"
1515
1616 "github.com/Layr-Labs/eigensdk-go/chainio/clients/eth"
17+ "github.com/Layr-Labs/eigensdk-go/crypto/bls"
1718 rpccalls "github.com/Layr-Labs/eigensdk-go/metrics/collectors/rpc_calls"
1819 backoff "github.com/cenkalti/backoff/v4"
1920 "github.com/ethereum/go-ethereum/accounts/abi/bind"
2021 "github.com/ethereum/go-ethereum/common"
2122 "github.com/ethereum/go-ethereum/core/types"
2223 "github.com/prometheus/client_golang/prometheus"
2324 "github.com/stretchr/testify/assert"
25+ aggregator "github.com/yetanotherco/aligned_layer/aggregator/pkg"
2426 servicemanager "github.com/yetanotherco/aligned_layer/contracts/bindings/AlignedLayerServiceManager"
2527 retry "github.com/yetanotherco/aligned_layer/core"
2628 "github.com/yetanotherco/aligned_layer/core/chainio"
2729 "github.com/yetanotherco/aligned_layer/core/config"
30+ core_types "github.com/yetanotherco/aligned_layer/core/types"
2831 "github.com/yetanotherco/aligned_layer/core/utils"
32+ operator "github.com/yetanotherco/aligned_layer/operator/pkg"
2933)
3034
3135func DummyFunction (x uint64 ) (uint64 , error ) {
@@ -923,3 +927,69 @@ func TestBatchersBalances(t *testing.T) {
923927 return
924928 }
925929}
930+
931+ func TestSendSignedTaskResponse (t * testing.T ) {
932+ cmd , _ , err := SetupAnvil (8545 )
933+ if err != nil {
934+ t .Errorf ("Error setting up Anvil: %s\n " , err )
935+ }
936+
937+ aggregatorConfig := config .NewAggregatorConfig ("../config-files/config-aggregator-test.yaml" )
938+ operatorConfig := config .NewOperatorConfig ("../config-files/config-operator-test.yaml" )
939+
940+ agg , err := aggregator .NewAggregator (* aggregatorConfig )
941+ if err != nil {
942+ fmt .Errorf ("Could not load aggregator %s" , err )
943+ }
944+ ctx , cancel := context .WithCancel (context .Background ())
945+ go func () {
946+ err = agg .Start (ctx )
947+ if err != nil {
948+ fmt .Errorf ("Could not start Aggregator %s" , err )
949+ }
950+ }()
951+ if err != nil {
952+ fmt .Errorf ("Could not start Aggregator %s" , err )
953+ }
954+
955+ logger := operatorConfig .BaseConfig .Logger
956+ rpcClient , err := operator .NewAggregatorRpcClient (operatorConfig .Operator .AggregatorServerIpPortAddress , logger )
957+ // This is a mock to verify that a lost connection to the aggregator does not return anything.
958+ disconnected_rpcClient , err := operator .NewAggregatorRpcClient ("localhost:8999" , logger )
959+ if err != nil {
960+ fmt .Errorf ("Could not create RPC client: %s. Is aggregator running?" , err )
961+ }
962+
963+ //zero_bytes := [32]byte{}
964+ signedTaskResponse := & core_types.SignedTaskResponse {
965+ BatchIdentifierHash : [32 ]byte {},
966+ BatchMerkleRoot : [32 ]byte {},
967+ SenderAddress : [20 ]byte {},
968+ BlsSignature : bls.Signature {},
969+ OperatorId : [32 ]byte {},
970+ }
971+
972+ task_resp_func := operator .SendSignedTaskResponse (rpcClient , signedTaskResponse )
973+ _ , err = task_resp_func ()
974+ assert .Nil (t , err )
975+
976+ fmt .Printf ("stuff" )
977+ task_resp_func = operator .SendSignedTaskResponse (disconnected_rpcClient , signedTaskResponse )
978+ // NOTE: This the expected behavior of a net/rpc/clint/Go for an invalid connection ref: https://cs.opensource.google/go/go/+/refs/tags/go1.23.3:src/net/rpc/client.go;l=298
979+ assert .Panics (t , func () { _ , err = task_resp_func () })
980+ fmt .Printf ("error: %s" , err )
981+ assert .Nil (t , err )
982+
983+ task_resp_func = operator .SendSignedTaskResponse (rpcClient , signedTaskResponse )
984+ _ , err = task_resp_func ()
985+ assert .Nil (t , err )
986+
987+ // Kill Aggregator
988+ cancel ()
989+
990+ if err := cmd .Process .Kill (); err != nil {
991+ t .Errorf ("Error killing process: %v\n " , err )
992+ return
993+ }
994+
995+ }
0 commit comments