@@ -3,6 +3,7 @@ const mockHexStripPrefix = jest.fn().mockImplementation(params => params);
3
3
4
4
import { Test , TestingModule } from '@nestjs/testing' ;
5
5
import { BigNumber } from '@polymeshassociation/polymesh-sdk' ;
6
+ import { TxTags } from '@polymeshassociation/polymesh-sdk/types' ;
6
7
7
8
import { MockMiddlewareMetadata } from '~/network/mocks/middleware-metadata.mock' ;
8
9
import { MockNetworkProperties } from '~/network/mocks/network-properties.mock' ;
@@ -96,6 +97,39 @@ describe('NetworkService', () => {
96
97
} ) ;
97
98
} ) ;
98
99
100
+ describe ( 'getProtocolFees' , ( ) => {
101
+ it ( 'should return protocol fees for the provided tags' , async ( ) => {
102
+ const tag = TxTags . asset . CreateAsset ;
103
+ const protocolFees = [ { tag, fees : new BigNumber ( 1 ) } ] ;
104
+
105
+ mockPolymeshApi . network . getProtocolFees . mockResolvedValue ( protocolFees ) ;
106
+
107
+ const result = await networkService . getProtocolFees ( [ tag ] ) ;
108
+
109
+ expect ( result ) . toBe ( protocolFees ) ;
110
+ expect ( mockPolymeshApi . network . getProtocolFees ) . toHaveBeenCalledWith ( {
111
+ tags : [ tag ] ,
112
+ blockHash : undefined ,
113
+ } ) ;
114
+ } ) ;
115
+
116
+ it ( 'should forward block hash when provided' , async ( ) => {
117
+ const tag = TxTags . asset . CreateAsset ;
118
+ const blockHash = '0x123' ;
119
+ const protocolFees = [ { tag, fees : new BigNumber ( 2 ) } ] ;
120
+
121
+ mockPolymeshApi . network . getProtocolFees . mockResolvedValue ( protocolFees ) ;
122
+
123
+ const result = await networkService . getProtocolFees ( [ tag ] , blockHash ) ;
124
+
125
+ expect ( result ) . toBe ( protocolFees ) ;
126
+ expect ( mockPolymeshApi . network . getProtocolFees ) . toHaveBeenCalledWith ( {
127
+ tags : [ tag ] ,
128
+ blockHash,
129
+ } ) ;
130
+ } ) ;
131
+ } ) ;
132
+
99
133
describe ( 'getTransactionByHash' , ( ) => {
100
134
it ( 'should return the extrinsic details' , async ( ) => {
101
135
mockPolymeshApi . network . getTransactionByHash . mockReturnValue ( extrinsicWithFees ) ;
0 commit comments