@@ -8,8 +8,10 @@ import (
88 "time"
99
1010 "github.com/ethereum/go-ethereum/accounts/abi"
11+
1112 v1 "github.com/smartcontractkit/data-streams-sdk/go/report/v1"
1213 v10 "github.com/smartcontractkit/data-streams-sdk/go/report/v10"
14+ v13 "github.com/smartcontractkit/data-streams-sdk/go/report/v13"
1315 v2 "github.com/smartcontractkit/data-streams-sdk/go/report/v2"
1416 v3 "github.com/smartcontractkit/data-streams-sdk/go/report/v3"
1517 v4 "github.com/smartcontractkit/data-streams-sdk/go/report/v4"
@@ -160,6 +162,20 @@ func TestReport(t *testing.T) {
160162 if ! reflect .DeepEqual (v10Report , rv10 ) {
161163 t .Errorf ("expected: %#v, got: %#v" , v10Report , rv10 )
162164 }
165+
166+ b , err = schema .Pack (v13Report .ReportContext , v13Report .ReportBlob , v13Report .RawRs , v13Report .RawSs , v13Report .RawVs )
167+ if err != nil {
168+ t .Errorf ("failed to encode report: %s" , err )
169+ }
170+
171+ rv13 , err := Decode [v13.Data ](b )
172+ if err != nil {
173+ t .Errorf ("failed to decode report: %s" , err )
174+ }
175+
176+ if ! reflect .DeepEqual (v13Report , rv13 ) {
177+ t .Errorf ("expected: %#v, got: %#v" , v13Report , rv13 )
178+ }
163179}
164180
165181var v1Report = & Report [v1.Data ]{
@@ -252,6 +268,15 @@ var v10Report = &Report[v10.Data]{
252268 RawVs : [32 ]uint8 {00 , 01 , 10 , 74 , 67 , 29 , 24 , 17 , 12 , 18 , 22 , 11 , 69 , 11 , 63 , 86 , 12 , 86 , 23 , 58 , 13 , 53 , 29 , 12 , 17 , 10 , 17 , 12 , 63 , 27 , 12 , 14 },
253269}
254270
271+ var v13Report = & Report [v13.Data ]{
272+ Data : v13Data ,
273+ ReportContext : [3 ][32 ]uint8 {},
274+ ReportBlob : mustPackData (v13Data ),
275+ RawRs : [][32 ]uint8 {{00 , 01 , 10 , 74 , 67 , 29 , 24 , 17 , 12 , 18 , 22 , 11 , 69 , 11 , 63 , 86 , 12 , 86 , 23 , 58 , 13 , 53 , 29 , 12 , 17 , 10 , 17 , 12 , 63 , 27 , 12 , 14 }},
276+ RawSs : [][32 ]uint8 {{01 , 02 , 10 , 73 , 65 , 19 , 14 , 27 , 42 , 48 , 52 , 18 , 39 , 116 , 67 , 85 , 13 , 82 , 33 , 48 , 23 , 33 , 49 , 32 , 67 , 50 , 37 , 32 , 63 , 77 , 14 , 64 }},
277+ RawVs : [32 ]uint8 {00 , 01 , 10 , 74 , 67 , 29 , 24 , 17 , 12 , 18 , 22 , 11 , 69 , 11 , 63 , 86 , 12 , 86 , 23 , 58 , 13 , 53 , 29 , 12 , 17 , 10 , 17 , 12 , 63 , 27 , 12 , 14 },
278+ }
279+
255280var v1Data = v1.Data {
256281 FeedID : [32 ]uint8 {00 , 01 , 107 , 74 , 167 , 229 , 124 , 167 , 182 , 138 , 225 , 191 , 69 , 101 , 63 , 86 , 182 , 86 , 253 , 58 , 163 , 53 , 239 , 127 , 174 , 105 , 107 , 102 , 63 , 27 , 132 , 114 },
257282 ObservationsTimestamp : uint32 (time .Now ().Unix ()),
@@ -374,6 +399,20 @@ var v10Data = v10.Data{
374399 TokenizedPrice : big .NewInt (1001 ),
375400}
376401
402+ var v13Data = v13.Data {
403+ FeedID : [32 ]uint8 {00 , 13 , 19 , 169 , 185 , 197 , 227 , 122 , 9 , 159 , 55 , 78 , 146 , 195 , 121 , 20 , 175 , 92 , 38 , 143 , 58 , 138 , 151 , 33 , 241 , 114 , 81 , 53 , 191 , 180 , 203 , 184 },
404+ ValidFromTimestamp : uint32 (time .Now ().Unix ()),
405+ ObservationsTimestamp : uint32 (time .Now ().Unix ()),
406+ NativeFee : big .NewInt (10 ),
407+ LinkFee : big .NewInt (10 ),
408+ ExpiresAt : uint32 (time .Now ().Unix ()) + 100 ,
409+ BestAsk : big .NewInt (75 ),
410+ BestBid : big .NewInt (78 ),
411+ AskVolume : 10000 ,
412+ BidVolume : 11000 ,
413+ LastTradedPrice : big .NewInt (76 ),
414+ }
415+
377416func mustPackData (d interface {}) []byte {
378417 var args []interface {}
379418 var dataSchema abi.Arguments
@@ -511,6 +550,21 @@ func mustPackData(d interface{}) []byte {
511550 v .ActivationDateTime ,
512551 v .TokenizedPrice ,
513552 }
553+ case v13.Data :
554+ dataSchema = v13 .Schema ()
555+ args = []interface {}{
556+ v .FeedID ,
557+ v .ValidFromTimestamp ,
558+ v .ObservationsTimestamp ,
559+ v .NativeFee ,
560+ v .LinkFee ,
561+ v .ExpiresAt ,
562+ v .BestAsk ,
563+ v .BestBid ,
564+ v .AskVolume ,
565+ v .BidVolume ,
566+ v .LastTradedPrice ,
567+ }
514568 default :
515569 panic (fmt .Sprintf ("invalid type to pack: %#v" , v ))
516570 }
0 commit comments