Skip to content

Commit

Permalink
bump common & libocr; remove context (#61)
Browse files Browse the repository at this point in the history
  • Loading branch information
jmank88 authored Mar 27, 2024
1 parent 87a36ee commit af2f85f
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 22 deletions.
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ go 1.21.3

require (
github.com/hashicorp/go-plugin v1.6.0
github.com/smartcontractkit/chainlink-common v0.1.7-0.20240324182820-92b84cfb6373
github.com/smartcontractkit/libocr v0.0.0-20240322223357-61738d25af14
github.com/smartcontractkit/chainlink-common v0.1.7-0.20240327133125-eed636b9a6df
github.com/smartcontractkit/libocr v0.0.0-20240326191951-2bbe9382d052
github.com/stretchr/testify v1.9.0
)

Expand Down
10 changes: 4 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -207,19 +207,17 @@ github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjR
github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog=
github.com/shopspring/decimal v1.3.1 h1:2Usl1nmF/WZucqkFZhnfFYxxxu8LG21F6nPQBE5gKV8=
github.com/shopspring/decimal v1.3.1/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o=
github.com/smartcontractkit/chainlink-common v0.1.7-0.20240324182820-92b84cfb6373 h1:zlPLi+aJRwOp4Y/JlHSqKnBd038rCCUzgDSYszbmySI=
github.com/smartcontractkit/chainlink-common v0.1.7-0.20240324182820-92b84cfb6373/go.mod h1:kmBPIyrTt8Q3HuSC3qdK96uwr4edw9SYbxjWmle7la4=
github.com/smartcontractkit/chainlink-common v0.1.7-0.20240327133125-eed636b9a6df h1:AKjckaIV8R53dLJwoQ3VlUI56L34Ca+nkkzjR1784zY=
github.com/smartcontractkit/chainlink-common v0.1.7-0.20240327133125-eed636b9a6df/go.mod h1:u2XnvJHl7sQ9HMlRnVLsOKgV9ihk0RGIYywB12p9gQQ=
github.com/smartcontractkit/go-plugin v0.0.0-20240208201424-b3b91517de16 h1:TFe+FvzxClblt6qRfqEhUfa4kFQx5UobuoFGO2W4mMo=
github.com/smartcontractkit/go-plugin v0.0.0-20240208201424-b3b91517de16/go.mod h1:lBS5MtSSBZk0SHc66KACcjjlU6WzEVP/8pwz68aMkCI=
github.com/smartcontractkit/grpc-proxy v0.0.0-20230731113816-f1be6620749f h1:hgJif132UCdjo8u43i7iPN1/MFnu49hv7lFGFftCHKU=
github.com/smartcontractkit/grpc-proxy v0.0.0-20230731113816-f1be6620749f/go.mod h1:MvMXoufZAtqExNexqi4cjrNYE9MefKddKylxjS+//n0=
github.com/smartcontractkit/libocr v0.0.0-20240322223357-61738d25af14 h1:sGlxJ7y3guP20ohhn23XDj5kPXf+sOR7iFJaWjIvao0=
github.com/smartcontractkit/libocr v0.0.0-20240322223357-61738d25af14/go.mod h1:SJEZCHgMCAzzBvo9vMV2DQ9onfEcIJCYSViyP4JI6c4=
github.com/smartcontractkit/libocr v0.0.0-20240326191951-2bbe9382d052 h1:1WFjrrVrWoQ9UpVMh7Mx4jDpzhmo1h8hFUKd9awIhIU=
github.com/smartcontractkit/libocr v0.0.0-20240326191951-2bbe9382d052/go.mod h1:SJEZCHgMCAzzBvo9vMV2DQ9onfEcIJCYSViyP4JI6c4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY=
github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
Expand Down
6 changes: 3 additions & 3 deletions median/report_codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ type reportCodec struct {

var _ median.ReportCodec = &reportCodec{}

func (r *reportCodec) BuildReport(ctx context.Context, observations []median.ParsedAttributedObservation) (ocrtypes.Report, error) {
func (r *reportCodec) BuildReport(observations []median.ParsedAttributedObservation) (ocrtypes.Report, error) {
if len(observations) == 0 {
return nil, fmt.Errorf("cannot build report from empty attributed observations")
}

return r.codec.Encode(context.Background(), aggregate(observations), typeName)
}

func (r *reportCodec) MedianFromReport(ctx context.Context, report ocrtypes.Report) (*big.Int, error) {
func (r *reportCodec) MedianFromReport(report ocrtypes.Report) (*big.Int, error) {
agg := &aggregatedAttributedObservation{}
if err := r.codec.Decode(context.Background(), report, agg, typeName); err != nil {
return nil, err
Expand All @@ -38,6 +38,6 @@ func (r *reportCodec) MedianFromReport(ctx context.Context, report ocrtypes.Repo
return agg.Observations[medianObservation], nil
}

func (r *reportCodec) MaxReportLength(ctx context.Context, n int) (int, error) {
func (r *reportCodec) MaxReportLength(n int) (int, error) {
return r.codec.GetMaxDecodingSize(context.Background(), n, typeName)
}
19 changes: 8 additions & 11 deletions median/report_codec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ import (
"github.com/smartcontractkit/libocr/offchainreporting2plus/types"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/smartcontractkit/chainlink-common/pkg/utils/tests"
)

func TestReportCodec(t *testing.T) {
Expand Down Expand Up @@ -61,7 +59,7 @@ func TestReportCodec(t *testing.T) {
},
}

encoded, err := rc.BuildReport(tests.Context(t), anyReports)
encoded, err := rc.BuildReport(anyReports)
require.NoError(t, err)
assert.Equal(t, types.Report(anyEncodedReport), encoded)
})
Expand All @@ -75,11 +73,10 @@ func TestReportCodec(t *testing.T) {
},
}

ctx := tests.Context(t)
_, err := rc.BuildReport(ctx, nil)
_, err := rc.BuildReport(nil)
assert.Error(t, err)

_, err = rc.BuildReport(ctx, []median.ParsedAttributedObservation{})
_, err = rc.BuildReport([]median.ParsedAttributedObservation{})
assert.Error(t, err)
})

Expand All @@ -93,7 +90,7 @@ func TestReportCodec(t *testing.T) {
},
}

_, err := rc.BuildReport(tests.Context(t), anyReports)
_, err := rc.BuildReport(anyReports)
assert.Equal(t, anyError, err)
})

Expand All @@ -106,7 +103,7 @@ func TestReportCodec(t *testing.T) {
},
}

medianVal, err := rc.MedianFromReport(tests.Context(t), anyEncodedReport)
medianVal, err := rc.MedianFromReport(anyEncodedReport)
require.NoError(t, err)
assert.Equal(t, big.NewInt(250), medianVal)
})
Expand All @@ -121,7 +118,7 @@ func TestReportCodec(t *testing.T) {
},
}

_, err := rc.MedianFromReport(tests.Context(t), anyEncodedReport)
_, err := rc.MedianFromReport(anyEncodedReport)
assert.Equal(t, anyError, err)
})

Expand All @@ -136,7 +133,7 @@ func TestReportCodec(t *testing.T) {
},
}

length, err := rc.MaxReportLength(tests.Context(t), anyN)
length, err := rc.MaxReportLength(anyN)
require.NoError(t, err)
assert.Equal(t, anyLen, length)
})
Expand All @@ -150,7 +147,7 @@ func TestReportCodec(t *testing.T) {
},
}

_, err := rc.MaxReportLength(tests.Context(t), 10)
_, err := rc.MaxReportLength(10)
assert.Equal(t, anyError, err)
})
}
Expand Down

0 comments on commit af2f85f

Please sign in to comment.