forked from CoralSwap-Finance/coralswap-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-output.txt
More file actions
147 lines (128 loc) · 12 KB
/
Copy pathtest-output.txt
File metadata and controls
147 lines (128 loc) · 12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
> @coralswap/sdk@x.1.0 test
> jest flash-loan-module.test.ts
node.exe : FAIL tests/flash-loan-module.test.ts (9.208 s)
At line:1 char:1
+ & "C:\Program Files\nodejs/node.exe" "C:\Users\User\AppData\Roaming\n
...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (FAIL tests/flas...st.ts (9.
208 s):String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError
FlashLoanModule
calculateRepayment()
√ calculates repayment with 9 bps fee correctly (43 ms)
√ calculates repayment with larger amount and 9 bps fee (2 ms)
√ handles large amounts without overflow (1 ms)
√ returns principal unchanged when fee is zero (2 ms)
√ calculates repayment with 30 bps fee (3 ms)
√ handles minimum amounts correctly (2 ms)
estimateFee()
× returns fee based on flashFeeBps when fee > floor (3 ms)
× returns flashFeeFloor when calculated fee < floor (1 ms)
√ throws when config.locked is true (8 ms)
√ handles zero amount correctly (14 ms)
√ handles high fee bps correctly (3 ms)
isAvailable()
√ returns true when locked is false (2 ms)
√ returns false when locked is true (1 ms)
× returns false when config read throws (2 ms)
× returns false when pair does not exist (2 ms)
getMaxBorrowable()
√ returns reserve - 1% margin for token0 (2 ms)
√ returns reserve - 1% margin for token1 (1 ms)
√ handles zero reserves (1 ms)
√ handles very small reserves (1 ms)
√ handles large reserves (1 ms)
getConfig()
√ returns flash loan config from pair (2 ms)
√ propagates errors from pair client (3 ms)
execute()
√ throws when locked (4 ms)
√ throws when fee below floor (3 ms)
√ returns correct FlashLoanResult on success (1588 ms)
√ throws TransactionError when submission fails (11 ms)
√ handles transaction with no error message (3 ms)
√ builds flash loan operation with correct parameters (325 ms)
FlashLoanModule - Event Parsing
execute() with event parsing
√ includes decoded flash loan event in result on success (23 ms)
√ returns result without event if event parsing fails gracefully
(7 ms)
√ handles transaction with no flash loan events (8 ms)
√ extracts borrowedAmount and feePaid from decoded event (7 ms)
√ handles multiple events and finds flash loan event (6 ms)
√ returns result with event when transaction succeeds (7 ms)
● FlashLoanModule › estimateFee() › returns fee based on
flashFeeBps when fee > floor
FlashLoanError: Flash loan fee below protocol floor
[0m [90m 74 |[39m
[90m 75 |[39m [36mif[39m
([33m![39mvalidateFeeFloor(config[33m.[39mflashFeeBps[33m,[39m
feeFloorBps)) {
[31m[1m>[22m[39m[90m 76 |[39m [36mthrow[39m
[36mnew[39m [33mFlashLoanError[39m([32m"Flash loan fee below
protocol floor"[39m[33m,[39m {
[90m |[39m [31m[1m^[22m[39m
[90m 77 |[39m feeBps[33m:[39m
config[33m.[39mflashFeeBps[33m,[39m
[90m 78 |[39m feeFloor[33m:[39m
config[33m.[39mflashFeeFloor[33m,[39m
[90m 79 |[39m })[33m;[39m[0m
at FlashLoanModule.estimateFee (src/modules/flash-loan.ts:76:13)
at Object.<anonymous> (tests/flash-loan-module.test.ts:126:24)
● FlashLoanModule › estimateFee() › returns flashFeeFloor when
calculated fee < floor
FlashLoanError: Flash loan fee below protocol floor
[0m [90m 74 |[39m
[90m 75 |[39m [36mif[39m
([33m![39mvalidateFeeFloor(config[33m.[39mflashFeeBps[33m,[39m
feeFloorBps)) {
[31m[1m>[22m[39m[90m 76 |[39m [36mthrow[39m
[36mnew[39m [33mFlashLoanError[39m([32m"Flash loan fee below
protocol floor"[39m[33m,[39m {
[90m |[39m [31m[1m^[22m[39m
[90m 77 |[39m feeBps[33m:[39m
config[33m.[39mflashFeeBps[33m,[39m
[90m 78 |[39m feeFloor[33m:[39m
config[33m.[39mflashFeeFloor[33m,[39m
[90m 79 |[39m })[33m;[39m[0m
at FlashLoanModule.estimateFee (src/modules/flash-loan.ts:76:13)
at Object.<anonymous> (tests/flash-loan-module.test.ts:146:24)
● FlashLoanModule › isAvailable() › returns false when config
read throws
CoralSwapSDKError: Network error
[0m [90m 450 |[39m }
[90m 451 |[39m
[31m[1m>[22m[39m[90m 452 |[39m [36mreturn[39m
[36mnew[39m
[33mCoralSwapSDKError[39m([32m"UNKNOWN_ERROR"[39m[33m,[39m
message[33m,[39m {
[90m |[39m [31m[1m^[22m[39m
[90m 453 |[39m originalError[33m:[39m err[33m,[39m
[90m 454 |[39m })[33m;[39m
[90m 455 |[39m }[0m
at mapError (src/errors.ts:452:10)
at FlashLoanModule.isAvailable (src/modules/flash-loan.ts:226:35)
at Object.<anonymous> (tests/flash-loan-module.test.ts:249:25)
● FlashLoanModule › isAvailable() › returns false when pair does
not exist
CoralSwapSDKError: Contract not found
[0m [90m 450 |[39m }
[90m 451 |[39m
[31m[1m>[22m[39m[90m 452 |[39m [36mreturn[39m
[36mnew[39m
[33mCoralSwapSDKError[39m([32m"UNKNOWN_ERROR"[39m[33m,[39m
message[33m,[39m {
[90m |[39m [31m[1m^[22m[39m
[90m 453 |[39m originalError[33m:[39m err[33m,[39m
[90m 454 |[39m })[33m;[39m
[90m 455 |[39m }[0m
at mapError (src/errors.ts:452:10)
at FlashLoanModule.isAvailable (src/modules/flash-loan.ts:226:35)
at Object.<anonymous> (tests/flash-loan-module.test.ts:259:25)
Test Suites: 1 failed, 1 total
Tests: 4 failed, 30 passed, 34 total
Snapshots: 0 total
Time: 10.056 s
Ran all test suites matching /flash-loan-module.test.ts/i.