Skip to content

Commit 303385b

Browse files
authored
enable verbose property to return metadata for ws endpoint (#271)
* enable verbose property to return metadata for ws endpoint * remove console log * fix test cases failing * fix spelling errors * update callback and listener to use PriceInfo * isolate verbose flag to each client and add tests * isolate verbose flag from clients
1 parent bd90203 commit 303385b

File tree

8 files changed

+252
-101
lines changed

8 files changed

+252
-101
lines changed

third_party/pyth/p2w-sdk/js/package-lock.json

+7-7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

third_party/pyth/p2w-sdk/js/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
"dependencies": {
4242
"@certusone/wormhole-sdk": "0.2.1",
4343
"@improbable-eng/grpc-web-node-http-transport": "^0.14.1",
44-
"@pythnetwork/pyth-sdk-js": "^0.1.0"
44+
"@pythnetwork/pyth-sdk-js": "^0.3.0"
4545
},
4646
"bugs": {
4747
"url": "https://github.com/pyth-network/pyth-crosschain/issues"

third_party/pyth/price-service/package-lock.json

+9-9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

third_party/pyth/price-service/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
"@certusone/p2w-sdk": "file:../p2w-sdk/js",
2929
"@certusone/wormhole-sdk": "^0.1.4",
3030
"@certusone/wormhole-spydk": "^0.0.1",
31-
"@pythnetwork/pyth-sdk-js": "^0.1.0",
31+
"@pythnetwork/pyth-sdk-js": "^0.3.0",
3232
"@types/cors": "^2.8.12",
3333
"@types/express": "^4.17.13",
3434
"@types/morgan": "^1.9.3",

third_party/pyth/price-service/src/__tests__/rest.test.ts

+7-7
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ beforeAll(async () => {
6060
getLatestPriceInfo: (priceFeedId: string) => {
6161
return priceInfoMap.get(priceFeedId);
6262
},
63-
addUpdateListener: (_callback: (priceFeed: PriceFeed) => any) => {},
63+
addUpdateListener: (_callback: (priceInfo: PriceInfo) => any) => {},
6464
getPriceIds: () => new Set(),
6565
};
6666

@@ -72,20 +72,20 @@ beforeAll(async () => {
7272
describe("Latest Price Feed Endpoint", () => {
7373
test("When called with valid ids, returns correct price feed", async () => {
7474
const ids = [expandTo64Len("abcd"), expandTo64Len("3456")];
75-
const resp = await request(app).get("/latest_price_feeds").query({ ids });
75+
const resp = await request(app).get("/api/latest_price_feeds").query({ ids });
7676
expect(resp.status).toBe(StatusCodes.OK);
7777
expect(resp.body.length).toBe(2);
7878
expect(resp.body).toContainEqual(dummyPriceFeed(ids[0]).toJson());
7979
expect(resp.body).toContainEqual(dummyPriceFeed(ids[1]).toJson());
8080
});
8181

82-
test("When called with some non-existant ids within ids, returns error mentioning non-existant ids", async () => {
82+
test("When called with some non-existent ids within ids, returns error mentioning non-existent ids", async () => {
8383
const ids = [
8484
expandTo64Len("ab01"),
8585
expandTo64Len("3456"),
8686
expandTo64Len("effe"),
8787
];
88-
const resp = await request(app).get("/latest_price_feeds").query({ ids });
88+
const resp = await request(app).get("/api/latest_price_feeds").query({ ids });
8989
expect(resp.status).toBe(StatusCodes.BAD_REQUEST);
9090
expect(resp.body.message).toContain(ids[0]);
9191
expect(resp.body.message).not.toContain(ids[1]);
@@ -100,7 +100,7 @@ describe("Latest Vaa Bytes Endpoint", () => {
100100
expandTo64Len("ef01"),
101101
expandTo64Len("3456"),
102102
];
103-
const resp = await request(app).get("/latest_vaas").query({ ids });
103+
const resp = await request(app).get("/api/latest_vaas").query({ ids });
104104
expect(resp.status).toBe(StatusCodes.OK);
105105
expect(resp.body.length).toBe(2);
106106
expect(resp.body).toContain(
@@ -111,13 +111,13 @@ describe("Latest Vaa Bytes Endpoint", () => {
111111
);
112112
});
113113

114-
test("When called with some non-existant ids within ids, returns error mentioning non-existant ids", async () => {
114+
test("When called with some non-existent ids within ids, returns error mentioning non-existent ids", async () => {
115115
const ids = [
116116
expandTo64Len("ab01"),
117117
expandTo64Len("3456"),
118118
expandTo64Len("effe"),
119119
];
120-
const resp = await request(app).get("/latest_vaas").query({ ids });
120+
const resp = await request(app).get("/api/latest_vaas").query({ ids });
121121
expect(resp.status).toBe(StatusCodes.BAD_REQUEST);
122122
expect(resp.body.message).toContain(ids[0]);
123123
expect(resp.body.message).not.toContain(ids[1]);

0 commit comments

Comments
 (0)