code.vegaprotocol.io/vega@v0.79.0/core/rewards/lottery_ranking_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 rewards 17 18 import ( 19 "testing" 20 "time" 21 22 "code.vegaprotocol.io/vega/core/types" 23 "code.vegaprotocol.io/vega/libs/num" 24 25 "github.com/stretchr/testify/require" 26 ) 27 28 func TestLotteryRewardScoreSorting(t *testing.T) { 29 for i := 0; i < 100; i++ { 30 adjustedRewardScores := []*types.PartyContributionScore{ 31 {Party: "p1", Score: num.DecimalOne()}, 32 {Party: "p2", Score: num.DecimalTwo()}, 33 {Party: "p3", Score: num.DecimalFromFloat(0.01)}, 34 } 35 const layout = "Jan 2, 2006 at 3:04pm" 36 37 timestamp, _ := time.Parse(layout, "Aug 7, 2024 at 12:00pm") 38 lottery := lotteryRewardScoreSorting(adjustedRewardScores, timestamp) 39 require.Equal(t, "p2", lottery[0].Party) 40 require.Equal(t, "p1", lottery[1].Party) 41 require.Equal(t, "p3", lottery[2].Party) 42 } 43 }