@@ -3,7 +3,11 @@ import { INestApplication } from "@nestjs/common";
3
3
import { Test } from "@nestjs/testing" ;
4
4
import { constants , ethers } from "ethers" ;
5
5
6
- import { DepositFixture , mockManyDepositEntities } from "../src/modules/deposit/adapter/db/deposit-fixture" ;
6
+ import {
7
+ DepositFixture ,
8
+ mockManyDepositEntities ,
9
+ mockDepositEntity ,
10
+ } from "../src/modules/deposit/adapter/db/deposit-fixture" ;
7
11
import { ValidationPipe } from "../src/validation.pipe" ;
8
12
import { AppModule } from "../src/app.module" ;
9
13
import { RunMode } from "../src/dynamic-module" ;
@@ -120,6 +124,58 @@ describe("GET /deposits", () => {
120
124
} ) ;
121
125
} ) ;
122
126
127
+ describe ( "GET /deposits/details" , ( ) => {
128
+ const depositorAddress = "0x9A8f92a830A5cB89a3816e3D267CB7791c16b04D" ;
129
+ const depositTxHash = "0x91616c035fe2b7432d1549b9a204e29fd7cf3f5d5d9170cd418e5cc7dcc4e3a0" ;
130
+ const sourceChainId = 1 ;
131
+
132
+ const FILLED_DEPOSIT = mockDepositEntity ( {
133
+ status : "filled" ,
134
+ depositorAddr : depositorAddress ,
135
+ sourceChainId,
136
+ depositTxHash,
137
+ amount : "10" ,
138
+ filled : "10" ,
139
+ } ) ;
140
+
141
+ beforeAll ( async ( ) => {
142
+ await app . get ( DepositFixture ) . insertManyDeposits ( [ FILLED_DEPOSIT ] ) ;
143
+ } ) ;
144
+
145
+ it ( "200 with for correct params" , async ( ) => {
146
+ const response = await request ( app . getHttpServer ( ) ) . get (
147
+ `/deposits/details?depositTxHash=${ depositTxHash } &originChainId=${ sourceChainId } ` ,
148
+ ) ;
149
+ expect ( response . status ) . toBe ( 200 ) ;
150
+ expect ( response . body . status ) . toBe ( "filled" ) ;
151
+ } ) ;
152
+
153
+ it ( "404 for non existent depositTxHash" , async ( ) => {
154
+ const response = await request ( app . getHttpServer ( ) ) . get (
155
+ `/deposits/details?depositTxHash=0x&originChainId=${ sourceChainId } ` ,
156
+ ) ;
157
+ expect ( response . status ) . toBe ( 404 ) ;
158
+ } ) ;
159
+
160
+ it ( "404 for non existent originChainId" , async ( ) => {
161
+ const response = await request ( app . getHttpServer ( ) ) . get (
162
+ `/deposits/details?depositTxHash=${ depositTxHash } &originChainId=10` ,
163
+ ) ;
164
+ expect ( response . status ) . toBe ( 404 ) ;
165
+ } ) ;
166
+
167
+ it ( "400 for invalid originChainId" , async ( ) => {
168
+ const response = await request ( app . getHttpServer ( ) ) . get (
169
+ `/deposits/details?depositTxHash=${ depositTxHash } &originChainId=invalid` ,
170
+ ) ;
171
+ expect ( response . status ) . toBe ( 400 ) ;
172
+ } ) ;
173
+
174
+ afterAll ( async ( ) => {
175
+ await app . get ( DepositFixture ) . deleteAllDeposits ( ) ;
176
+ } ) ;
177
+ } ) ;
178
+
123
179
describe ( "GET /etl/referral-deposits" , ( ) => {
124
180
const date = "2022-01-01" ;
125
181
0 commit comments