|
1 | 1 | import { EMPTY_PORTFOLIO_STRATEGIES } from '../../lib' |
2 | 2 | import { |
| 3 | + LlmProcessOutput, |
3 | 4 | NetworkPortfolioLibResponse, |
4 | 5 | PortfolioLibToken, |
5 | | - Strategy, |
6 | 6 | StrategyRisk |
7 | 7 | } from '../../lib/types' |
8 | 8 | import { |
@@ -31,18 +31,24 @@ const mockedNetworkPortfolioResult: NetworkPortfolioLibResponse = { |
31 | 31 | } |
32 | 32 | ] |
33 | 33 | } |
34 | | -const mockedStrategies: Strategy[] = [ |
35 | | - { |
36 | | - actions: [ |
37 | | - { |
38 | | - description: 'Example USDC strategy description', |
39 | | - tokens: 'USDC, ETH' |
40 | | - } |
41 | | - ], |
42 | | - name: 'Example USDC strategy name', |
43 | | - risk: StrategyRisk.LOW |
44 | | - } |
45 | | -] |
| 34 | +const mockedLlmOutput: LlmProcessOutput = { |
| 35 | + llm: { |
| 36 | + provider: 'mock', |
| 37 | + model: 'mock' |
| 38 | + }, |
| 39 | + response: [ |
| 40 | + { |
| 41 | + actions: [ |
| 42 | + { |
| 43 | + description: 'Example USDC strategy description', |
| 44 | + tokens: 'USDC, ETH' |
| 45 | + } |
| 46 | + ], |
| 47 | + name: 'Example USDC strategy name', |
| 48 | + risk: StrategyRisk.LOW |
| 49 | + } |
| 50 | + ] |
| 51 | +} |
46 | 52 |
|
47 | 53 | jest.mock('ambire-common/dist/src/consts/networks', () => { |
48 | 54 | const actual = jest.requireActual('ambire-common/dist/src/consts/networks') |
@@ -99,30 +105,32 @@ describe('Portfolio unit tests', () => { |
99 | 105 | address: TEST_WALLET, |
100 | 106 | getPortfolio: getPortfolioVelcroV3, |
101 | 107 | makePrompt: simplePrompt, |
102 | | - llmProcessor: () => Promise.resolve(mockedStrategies) |
| 108 | + llmProcessor: () => Promise.resolve(mockedLlmOutput) |
103 | 109 | }) |
104 | 110 |
|
105 | 111 | expect(res).toHaveProperty('address') |
106 | 112 | expect(res).toHaveProperty('portfolio') |
107 | 113 | expect(res).toHaveProperty('strategies') |
108 | 114 | expect(res.address).toEqual(TEST_WALLET) |
109 | 115 | expect(res.portfolio).toHaveLength(1) |
110 | | - expect(res.strategies).toBe(mockedStrategies) |
| 116 | + expect(res.strategies).toHaveLength(1) |
| 117 | + expect(res.strategies[0]).toBe(mockedLlmOutput) |
111 | 118 | }) |
112 | 119 |
|
113 | 120 | test('should process address with empty portfolio and get hardcoded strategy for it', async () => { |
114 | 121 | const res = await processAddress({ |
115 | 122 | address: TEST_WALLET, |
116 | 123 | getPortfolio: () => Promise.resolve([]), |
117 | 124 | makePrompt: simplePrompt, |
118 | | - llmProcessor: () => Promise.resolve(mockedStrategies) |
| 125 | + llmProcessor: () => Promise.resolve(mockedLlmOutput) |
119 | 126 | }) |
120 | 127 |
|
121 | 128 | expect(res).toHaveProperty('address') |
122 | 129 | expect(res).toHaveProperty('portfolio') |
123 | 130 | expect(res).toHaveProperty('strategies') |
124 | 131 | expect(res.address).toEqual(TEST_WALLET) |
125 | 132 | expect(res.portfolio).toHaveLength(0) |
126 | | - expect(res.strategies).toBe(EMPTY_PORTFOLIO_STRATEGIES) |
| 133 | + expect(res.strategies).toHaveLength(1) |
| 134 | + expect(res.strategies[0].response).toBe(EMPTY_PORTFOLIO_STRATEGIES) |
127 | 135 | }) |
128 | 136 | }) |
0 commit comments