1919 */
2020
2121import { expect } from 'chai' ;
22+ import pino from 'pino' ;
2223import HbarLimit from '../../src/lib/hbarlimiter' ;
2324
25+ const logger = pino ( ) ;
26+
2427describe ( 'HBAR Rate Limiter' , async function ( ) {
2528 this . timeout ( 20000 ) ;
2629 let rateLimiter : HbarLimit ;
@@ -35,7 +38,7 @@ describe('HBAR Rate Limiter', async function () {
3538 } ) ;
3639
3740 it ( 'should be disabled, if we pass invalid total' , async function ( ) {
38- rateLimiter = new HbarLimit ( currentDateNow , invalidTotal , validDuration ) ;
41+ rateLimiter = new HbarLimit ( logger , currentDateNow , invalidTotal , validDuration ) ;
3942
4043 const isEnabled = rateLimiter . isEnabled ( ) ;
4144 const limiterResetTime = rateLimiter . getResetTime ( ) ;
@@ -50,7 +53,7 @@ describe('HBAR Rate Limiter', async function () {
5053 } ) ;
5154
5255 it ( 'should be disabled, if we pass invalid duration' , async function ( ) {
53- rateLimiter = new HbarLimit ( currentDateNow , validTotal , invalidDuration ) ;
56+ rateLimiter = new HbarLimit ( logger , currentDateNow , validTotal , invalidDuration ) ;
5457
5558 const isEnabled = rateLimiter . isEnabled ( ) ;
5659 const limiterResetTime = rateLimiter . getResetTime ( ) ;
@@ -65,7 +68,7 @@ describe('HBAR Rate Limiter', async function () {
6568 } ) ;
6669
6770 it ( 'should be disabled, if we pass both invalid duration and total' , async function ( ) {
68- rateLimiter = new HbarLimit ( currentDateNow , invalidTotal , invalidDuration ) ;
71+ rateLimiter = new HbarLimit ( logger , currentDateNow , invalidTotal , invalidDuration ) ;
6972
7073 const isEnabled = rateLimiter . isEnabled ( ) ;
7174 const limiterResetTime = rateLimiter . getResetTime ( ) ;
@@ -80,7 +83,7 @@ describe('HBAR Rate Limiter', async function () {
8083 } ) ;
8184
8285 it ( 'should be enabled, if we pass valid duration and total' , async function ( ) {
83- rateLimiter = new HbarLimit ( currentDateNow , validTotal , validDuration ) ;
86+ rateLimiter = new HbarLimit ( logger , currentDateNow , validTotal , validDuration ) ;
8487
8588 const isEnabled = rateLimiter . isEnabled ( ) ;
8689 const limiterResetTime = rateLimiter . getResetTime ( ) ;
@@ -95,7 +98,7 @@ describe('HBAR Rate Limiter', async function () {
9598
9699 it ( 'should not rate limit' , async function ( ) {
97100 const cost = 10000000 ;
98- rateLimiter = new HbarLimit ( currentDateNow , validTotal , validDuration ) ;
101+ rateLimiter = new HbarLimit ( logger , currentDateNow , validTotal , validDuration ) ;
99102 rateLimiter . addExpense ( cost , currentDateNow ) ;
100103
101104 const isEnabled = rateLimiter . isEnabled ( ) ;
@@ -111,7 +114,7 @@ describe('HBAR Rate Limiter', async function () {
111114
112115 it ( 'should rate limit' , async function ( ) {
113116 const cost = 1000000000 ;
114- rateLimiter = new HbarLimit ( currentDateNow , validTotal , validDuration ) ;
117+ rateLimiter = new HbarLimit ( logger , currentDateNow , validTotal , validDuration ) ;
115118 rateLimiter . addExpense ( cost , currentDateNow ) ;
116119
117120 const isEnabled = rateLimiter . isEnabled ( ) ;
@@ -127,7 +130,7 @@ describe('HBAR Rate Limiter', async function () {
127130
128131 it ( 'should reset budget, while checking if we should rate limit' , async function ( ) {
129132 const cost = 1000000000 ;
130- rateLimiter = new HbarLimit ( currentDateNow , validTotal , validDuration ) ;
133+ rateLimiter = new HbarLimit ( logger , currentDateNow , validTotal , validDuration ) ;
131134 rateLimiter . addExpense ( cost , currentDateNow ) ;
132135
133136 const isEnabled = rateLimiter . isEnabled ( ) ;
@@ -144,7 +147,7 @@ describe('HBAR Rate Limiter', async function () {
144147
145148 it ( 'should reset budget, while adding expense' , async function ( ) {
146149 const cost = 1000000000 ;
147- rateLimiter = new HbarLimit ( currentDateNow , validTotal , validDuration ) ;
150+ rateLimiter = new HbarLimit ( logger , currentDateNow , validTotal , validDuration ) ;
148151
149152 rateLimiter . addExpense ( cost , currentDateNow ) ;
150153 const shouldRateLimitBefore = rateLimiter . shouldLimit ( currentDateNow ) ;
0 commit comments