Skip to content

Commit

Permalink
Concat emoji and name
Browse files Browse the repository at this point in the history
  • Loading branch information
xbtmatt committed Nov 28, 2024
1 parent 0a8f757 commit 89fb5d9
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/typescript/sdk/tests/e2e/queries/price-feed.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { EmojicoinClient } from "../../../src/client/emojicoin-client";
import {
type AnyNumberString,
compareBigInt,
joinEmojiNames,
maxBigInt,
type SymbolEmoji,
toSequenceNumberOptions,
Expand Down Expand Up @@ -34,12 +35,12 @@ describe("queries price_feed and returns accurate price feed data", () => {
// emoji, buy amount, second amount (percentage of output from buy)
// Note the percentage here doesn't indicate the delta percentage, since that's determined
// by the output average execution price, not the input amount.
[["🧘"], 10000n, -0.75],
[["🧘🏻"], 1000n, 0.9],
[["🧘🏼"], 1000n, 1],
[["🧘🏽"], 1000n, -0.05],
[["🧘🏾"], 1000n, -0.25],
[["🧘🏿"], 500n, 0.25],
[["⭐"], 10000n, -0.75],
[["🌟"], 1000n, 0.9],
[["πŸ›Έ"], 1000n, 1],
[["πŸͺ"], 1000n, -0.05],
[["🌠"], 1000n, -0.25],
[["β˜„οΈ"], 500n, 0.25],
];
const results = await Promise.all(
emojisAndInputAmounts.map(([emojis, buyAmount, percentOfOutput], i) =>
Expand Down Expand Up @@ -77,11 +78,13 @@ describe("queries price_feed and returns accurate price feed data", () => {
expect(priceFeedView.length).toBeLessThan(limit);

// Ensure it sorts by daily volume.
const marketSymbolsFromView = priceFeedView.map((v) => v.market.symbolEmojis);
const marketSymbolsFromView = priceFeedView.map(
(v) => `${v.market.symbolEmojis.join("")}-${joinEmojiNames(v.market.emojis)}`
);
const marketSymbolsSortedByDailyVolume = priceFeedView
.toSorted((a, b) => compareBigInt(a.dailyVolume, b.dailyVolume))
.reverse() // Sort by daily volume *descending*.
.map((v) => v.market.symbolEmojis);
.map((v) => `${v.market.symbolEmojis.join("")}-${joinEmojiNames(v.market.emojis)}`);
expect(marketSymbolsFromView).toEqual(marketSymbolsSortedByDailyVolume);

// Ensure the prices returned are expected.
Expand Down

0 comments on commit 89fb5d9

Please sign in to comment.