File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ import { StakeVerificationService } from './stake-verification.service' ;
2+ import { ConfigService } from '@nestjs/config' ;
3+
4+ const makeService = ( ) => {
5+ const cfg = { get : ( k : string ) => 'https://example.org' } as unknown as ConfigService ;
6+ const cache = { get : jest . fn ( ) , set : jest . fn ( ) , del : jest . fn ( ) } as any ;
7+ const svc = new StakeVerificationService ( cfg , cache ) ;
8+ // patch private query method
9+ return { svc, cache } ;
10+ } ;
11+
12+ describe ( 'StakeVerificationService' , ( ) => {
13+ it ( 'verifies eligible provider' , async ( ) => {
14+ const { svc } = makeService ( ) ;
15+ // @ts -ignore
16+ svc . queryStakeFromSoroban = jest . fn ( async ( ) => '2000' ) ;
17+ const res = await svc . verifyProviderStake ( { publicKey : 'GABC' } as any ) ;
18+ expect ( res . verified ) . toBe ( true ) ;
19+ expect ( res . stakeAmount ) . toBe ( '2000' ) ;
20+ } ) ;
21+
22+ it ( 'rejects ineligible provider' , async ( ) => {
23+ const { svc } = makeService ( ) ;
24+ // @ts -ignore
25+ svc . queryStakeFromSoroban = jest . fn ( async ( ) => '10' ) ;
26+ const res = await svc . verifyProviderStake ( { publicKey : 'GXYZ' } as any ) ;
27+ expect ( res . verified ) . toBe ( false ) ;
28+ } ) ;
29+ } ) ;
You can’t perform that action at this time.
0 commit comments