code.vegaprotocol.io/vega@v0.79.0/datanode/entities/reward_summary_filter_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 entities
    17  
    18  import (
    19  	"testing"
    20  
    21  	v2 "code.vegaprotocol.io/vega/protos/data-node/api/v2"
    22  
    23  	"github.com/stretchr/testify/assert"
    24  )
    25  
    26  func TestRewardSummaryFromProto(t *testing.T) {
    27  	type args struct {
    28  		pb *v2.RewardSummaryFilter
    29  	}
    30  	tests := []struct {
    31  		name string
    32  		args args
    33  		want RewardSummaryFilter
    34  	}{
    35  		{
    36  			name: "nil",
    37  			args: args{
    38  				pb: nil,
    39  			},
    40  			want: RewardSummaryFilter{},
    41  		}, {
    42  			name: "empty",
    43  			args: args{
    44  				pb: &v2.RewardSummaryFilter{},
    45  			},
    46  			want: RewardSummaryFilter{},
    47  		}, {
    48  			name: "with values",
    49  			args: args{
    50  				pb: &v2.RewardSummaryFilter{
    51  					AssetIds:  []string{"asset1", "asset2"},
    52  					MarketIds: []string{"market1", "market2"},
    53  					FromEpoch: toPtr(uint64(1)),
    54  					ToEpoch:   toPtr(uint64(2)),
    55  				},
    56  			},
    57  			want: RewardSummaryFilter{
    58  				AssetIDs:  []AssetID{"asset1", "asset2"},
    59  				MarketIDs: []MarketID{"market1", "market2"},
    60  				FromEpoch: toPtr(uint64(1)),
    61  				ToEpoch:   toPtr(uint64(2)),
    62  			},
    63  		},
    64  	}
    65  	for _, tt := range tests {
    66  		t.Run(tt.name, func(t *testing.T) {
    67  			filter := RewardSummaryFilterFromProto(tt.args.pb)
    68  			assert.Equalf(t, tt.want, filter, "RewardSummaryFilterFromProto(%v)", tt.args.pb)
    69  		})
    70  	}
    71  }