code.vegaprotocol.io/vega@v0.79.0/datanode/sqlsubscribers/game_scores_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 sqlsubscribers_test 17 18 import ( 19 "context" 20 "testing" 21 "time" 22 23 "code.vegaprotocol.io/vega/core/events" 24 "code.vegaprotocol.io/vega/core/types" 25 "code.vegaprotocol.io/vega/datanode/sqlsubscribers" 26 "code.vegaprotocol.io/vega/datanode/sqlsubscribers/mocks" 27 "code.vegaprotocol.io/vega/libs/num" 28 29 "github.com/golang/mock/gomock" 30 ) 31 32 func TestGameScore_Push(t *testing.T) { 33 ctrl := gomock.NewController(t) 34 35 store := mocks.NewMockGameScoreStore(ctrl) 36 37 store.EXPECT().AddPartyScore(gomock.Any(), gomock.Any()).Times(2) 38 store.EXPECT().AddTeamScore(gomock.Any(), gomock.Any()).Times(2) 39 subscriber := sqlsubscribers.NewGameScore(store) 40 subscriber.Flush(context.Background()) 41 subscriber.Push(context.Background(), events.NewTeamGameScoresEvent( 42 context.Background(), 43 1, 44 "game1", 45 time.Now(), 46 []*types.PartyContributionScore{{Party: "team1", Score: num.DecimalOne()}, {Party: "team2", Score: num.DecimalOne()}}, 47 map[string][]*types.PartyContributionScore{ 48 "team1": {{Party: "party1", Score: num.DecimalOne(), StakingBalance: num.UintZero(), OpenVolume: num.UintZero(), TotalFeesPaid: num.UintZero()}}, 49 "team2": {{Party: "party2", Score: num.DecimalOne(), StakingBalance: num.UintZero(), OpenVolume: num.UintZero(), TotalFeesPaid: num.UintZero()}}, 50 })) 51 }