@@ -17,38 +17,51 @@ func TestGetPeginReportUseCase_Run(t *testing.T) {
1717 retainedQuotes := []quote.RetainedPeginQuote {
1818 {QuoteHash : "hash1" },
1919 {QuoteHash : "hash2" },
20+ {QuoteHash : "hash3" },
21+ {QuoteHash : "hash4" },
22+ {QuoteHash : "hash5" },
23+ {QuoteHash : "hash6" },
24+ {QuoteHash : "hash7" },
25+ {QuoteHash : "hash8" },
26+ {QuoteHash : "hash9" },
27+ {QuoteHash : "hash10" },
2028 }
2129
2230 peginQuotes := []quote.PeginQuote {
23- {
24- Value : entities .NewWei (1000 ),
25- CallFee : entities .NewWei (10 ),
26- },
27- {
28- Value : entities .NewWei (3000 ),
29- CallFee : entities .NewWei (20 ),
30- },
31+ {Value : entities .NewWei (1000 ), CallFee : entities .NewWei (10 )},
32+ {Value : entities .NewWei (2000 ), CallFee : entities .NewWei (20 )},
33+ {Value : entities .NewWei (3000 ), CallFee : entities .NewWei (30 )},
34+ {Value : entities .NewWei (4000 ), CallFee : entities .NewWei (40 )},
35+ {Value : entities .NewWei (5000 ), CallFee : entities .NewWei (50 )},
36+ {Value : entities .NewWei (6000 ), CallFee : entities .NewWei (60 )},
37+ {Value : entities .NewWei (7000 ), CallFee : entities .NewWei (70 )},
38+ {Value : entities .NewWei (8000 ), CallFee : entities .NewWei (80 )},
39+ {Value : entities .NewWei (9000 ), CallFee : entities .NewWei (90 )},
40+ {Value : entities .NewWei (10000 ), CallFee : entities .NewWei (100 )},
3141 }
3242
43+ // Calculate expected values
3344 expectedMinimumValue := entities .NewWei (1000 )
34- expectedMaximumValue := entities .NewWei (3000 )
35- expectedAverageValue := entities .NewWei (( 1000 + 3000 ) / 2 )
36- expectedTotalFees := entities .NewWei (10 + 20 )
37- expectedAverageFee := entities .NewWei (( 10 + 20 ) / 2 )
45+ expectedMaximumValue := entities .NewWei (10000 )
46+ expectedAverageValue := entities .NewWei (5500 )
47+ expectedTotalFees := entities .NewWei (550 )
48+ expectedAverageFee := entities .NewWei (55 )
3849
3950 peginQuoteRepository := & mocks.PeginQuoteRepositoryMock {}
4051 peginQuoteRepository .On ("GetRetainedQuoteByState" , ctx , quote .PeginStateRegisterPegInSucceeded ).
4152 Return (retainedQuotes , nil ).Once ()
42- peginQuoteRepository .On ("GetQuote" , ctx , "hash1" ).Return (& peginQuotes [0 ], nil ).Once ()
43- peginQuoteRepository .On ("GetQuote" , ctx , "hash2" ).Return (& peginQuotes [1 ], nil ).Once ()
53+
54+ for i , retainedQuote := range retainedQuotes {
55+ peginQuoteRepository .On ("GetQuote" , ctx , retainedQuote .QuoteHash ).Return (& peginQuotes [i ], nil ).Once ()
56+ }
4457
4558 useCase := pegin .NewGetPeginReportUseCase (peginQuoteRepository )
4659
4760 result , err := useCase .Run (ctx )
4861
4962 peginQuoteRepository .AssertExpectations (t )
5063 require .NoError (t , err )
51- assert .Equal (t , 2 , result .NumberOfQuotes )
64+ assert .Equal (t , 10 , result .NumberOfQuotes )
5265 assert .Equal (t , expectedMinimumValue , result .MinimumQuoteValue )
5366 assert .Equal (t , expectedMaximumValue , result .MaximumQuoteValue )
5467 assert .Equal (t , expectedAverageValue , result .AverageQuoteValue )
0 commit comments