code.vegaprotocol.io/vega@v0.79.0/core/execution/common/mark_price_snapshot_test.go (about) 1 // Copyright (C) 2023 Gobalsky Labs Limited 2 // 3 // This program is free software: you can redistribute it and/or modify 4 // it under the terms of the GNU Affero General Public License as 5 // published by the Free Software Foundation, either version 3 of the 6 // License, or (at your option) any later version. 7 // 8 // This program is distributed in the hope that it will be useful, 9 // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 // GNU Affero General Public License for more details. 12 // 13 // You should have received a copy of the GNU Affero General Public License 14 // along with this program. If not, see <http://www.gnu.org/licenses/>. 15 16 package common 17 18 import ( 19 "testing" 20 21 dstypes "code.vegaprotocol.io/vega/core/datasource/common" 22 "code.vegaprotocol.io/vega/core/types" 23 vega "code.vegaprotocol.io/vega/protos/vega" 24 datav1 "code.vegaprotocol.io/vega/protos/vega/data/v1" 25 26 "github.com/stretchr/testify/require" 27 ) 28 29 func TestSerialisation(t *testing.T) { 30 pubKey := dstypes.CreateSignerFromString("0xDEADBEEF", dstypes.SignerTypePubKey) 31 mpcProto := &vega.CompositePriceConfiguration{ 32 DecayWeight: "0.1", 33 DecayPower: 2, 34 CashAmount: "100", 35 SourceStalenessTolerance: []string{"30s", "30s", "15s", "30s"}, 36 CompositePriceType: types.CompositePriceTypeByMedian, 37 DataSourcesSpec: []*vega.DataSourceDefinition{ 38 { 39 SourceType: &vega.DataSourceDefinition_External{ 40 External: &vega.DataSourceDefinitionExternal{ 41 SourceType: &vega.DataSourceDefinitionExternal_Oracle{ 42 Oracle: &vega.DataSourceSpecConfiguration{ 43 Signers: []*datav1.Signer{pubKey.IntoProto()}, 44 Filters: []*datav1.Filter{ 45 { 46 Key: &datav1.PropertyKey{ 47 Name: "ethereum.oracle.test.settlement_3DB2D971C6", 48 Type: datav1.PropertyKey_TYPE_INTEGER, 49 }, 50 Conditions: []*datav1.Condition{}, 51 }, 52 }, 53 }, 54 }, 55 }, 56 }, 57 }, 58 }, 59 DataSourcesSpecBinding: []*vega.SpecBindingForCompositePrice{ 60 {PriceSourceProperty: "ethereum.oracle.test.settlement_3DB2D971C6"}, 61 }, 62 } 63 64 mpc := types.CompositePriceConfigurationFromProto(mpcProto) 65 mpcProto2 := mpc.IntoProto() 66 require.Equal(t, mpcProto, mpcProto2) 67 }