11package operator
22
33import (
4+ "context"
45 "fmt"
56 "net/http"
67 "net/http/httptest"
@@ -10,12 +11,8 @@ import (
1011 "testing"
1112 "time"
1213
13- "github.com/ethereum/go-ethereum/accounts/abi/bind"
14- "github.com/ethereum/go-ethereum/common"
1514 "github.com/stretchr/testify/assert"
1615 retry "github.com/yetanotherco/aligned_layer/core"
17- "github.com/yetanotherco/aligned_layer/core/chainio"
18- s3 "github.com/yetanotherco/aligned_layer/operator/pkg/s3"
1916)
2017
2118// Function wrapper around `make run_storage`
@@ -38,34 +35,38 @@ func RunStorage() (*exec.Cmd, error) {
3835
3936 return cmd , nil
4037}
41-
42- func TestBatchersBalances ( t * testing. T ) {
43- cmd , err := RunStorage ()
44- if err != nil {
45- t .Errorf ("Error setting up Anvil: %s\n " , err )
46- }
47-
38+ func TestRequestBatch ( t * testing. T ) {
39+ /*
40+ cmd, err := RunStorage()
41+ if err != nil {
42+ t.Errorf("Error setting up Anvil: %s\n", err)
43+ }
44+ */
4845 // To Simulate Retrieving information from S3 we create a mock http server.
4946 expected := "dummy data"
5047 svr := httptest .NewServer (http .HandlerFunc (func (w http.ResponseWriter , r * http.Request ) {
51- fmt . Fprintf ( w , expected )
48+ t . Errorf ( "error %v %v" , w , expected )
5249 }))
5350 defer svr .Close ()
51+
52+ req , err := http .NewRequestWithContext (context .Background (), "GET" , svr .URL , nil )
5453 if err != nil {
55- return
54+ t . Errorf ( "Error creating req: %s \n " , err )
5655 }
57- senderAddress := common .HexToAddress ("0x0" )
5856
59- batcher_func := s3 . RequestBatch (avsWriter , & bind. CallOpts {}, senderAddress )
57+ batcher_func := RequestBatch (req , context . Background () )
6058 _ , err = batcher_func ()
6159 assert .Nil (t , err )
6260
63- if err := cmd .Process .Kill (); err != nil {
64- t .Errorf ("Error killing process: %v\n " , err )
65- return
66- }
61+ svr .Close ()
62+ /*
63+ if err := cmd.Process.Kill(); err != nil {
64+ t.Errorf("Error killing process: %v\n", err)
65+ return
66+ }
67+ */
6768
68- batcher_func = chainio . BatcherBalances ( avsWriter , & bind. CallOpts {}, senderAddress )
69+ batcher_func = RequestBatch ( req , context . Background () )
6970 _ , err = batcher_func ()
7071 assert .NotNil (t , err )
7172 if _ , ok := err .(retry.PermanentError ); ok {
@@ -77,17 +78,22 @@ func TestBatchersBalances(t *testing.T) {
7778 return
7879 }
7980
80- cmd , _ , err = retry_test .SetupAnvil (8545 )
81- if err != nil {
82- t .Errorf ("Error setting up Anvil: %s\n " , err )
83- }
81+ svr .Start ()
82+ /*
83+ cmd, err = RunStorage()
84+ if err != nil {
85+ t.Errorf("Error setting up Anvil: %s\n", err)
86+ }
87+ */
8488
85- batcher_func = chainio . BatcherBalances ( avsWriter , & bind. CallOpts {}, senderAddress )
89+ batcher_func = RequestBatch ( req , context . Background () )
8690 _ , err = batcher_func ()
8791 assert .Nil (t , err )
8892
89- if err := cmd .Process .Kill (); err != nil {
90- t .Errorf ("Error killing process: %v\n " , err )
91- return
92- }
93+ /*
94+ if err := cmd.Process.Kill(); err != nil {
95+ t.Errorf("Error killing process: %v\n", err)
96+ return
97+ }
98+ */
9399}
0 commit comments