Skip to content

Commit c809398

Browse files
committed
test: looksrare-v2 test coverage
1 parent ebdebd9 commit c809398

File tree

2 files changed

+184
-0
lines changed

2 files changed

+184
-0
lines changed
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
const looksrareV2NormalListing = {
2+
quoteType: 1,
3+
globalNonce: "0",
4+
subsetNonce: "0",
5+
orderNonce: "0",
6+
strategyId: 0,
7+
collectionType: 0,
8+
collection: "0x5f04D47D698F79d76F85E835930170Ff4c4EBdB7",
9+
currency: "0x0000000000000000000000000000000000000000",
10+
signer: "0x000075B45Dff84C00Cf597d5C3E766108CeA0000",
11+
startTime: "1684302184",
12+
endTime: "1686893895",
13+
price: "100000000000000000",
14+
itemIds: ["99117"],
15+
amounts: ["1"],
16+
additionalParameters: "0x",
17+
};
18+
19+
const looksrareV2CollectionBid = {
20+
quoteType: 0,
21+
globalNonce: "0",
22+
subsetNonce: "0",
23+
orderNonce: "0",
24+
strategyId: 1,
25+
collectionType: 0,
26+
collection: "0xED5AF388653567Af2F388E6224dC7C4b3241C544",
27+
currency: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
28+
signer: "0x000075B45Dff84C00Cf597d5C3E766108CeA0000",
29+
startTime: "1684302184",
30+
endTime: "1686893895",
31+
price: "100000000000000000",
32+
itemIds: [],
33+
amounts: ["1"],
34+
additionalParameters: "0x",
35+
};
36+
37+
const looksrareV2Bid = {
38+
quoteType: 0,
39+
globalNonce: "0",
40+
subsetNonce: "0",
41+
orderNonce: "0",
42+
strategyId: 0,
43+
collectionType: 2,
44+
collection: "0x005AF388653567Af2F388E6224dC7C4b3241C500",
45+
currency: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
46+
signer: "0x000075B45Dff84C00Cf597d5C3E766108CeA0000",
47+
startTime: "1684302184",
48+
endTime: "1686893895",
49+
price: "100000000000000000",
50+
itemIds: ["1500"],
51+
amounts: ["10"],
52+
additionalParameters: "0x",
53+
};
54+
55+
Object.freeze(looksrareV2NormalListing);
56+
Object.freeze(looksrareV2CollectionBid);
57+
Object.freeze(looksrareV2Bid);
58+
59+
export { looksrareV2NormalListing, looksrareV2CollectionBid, looksrareV2Bid };
Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
import { LooksRareV2MakerOrder } from "../../../src/types/looksrare-v2";
2+
import { Domain } from "../../../src/types/visualizer";
3+
import visualize from "../../../src/visualizer";
4+
import looksrare from "../../../src/visualizer/looksrare-v2";
5+
import {
6+
looksrareV2Bid,
7+
looksrareV2CollectionBid,
8+
looksrareV2NormalListing,
9+
} from "./data";
10+
11+
describe("looksrare-v2", () => {
12+
const looksrareDomain: Domain = {
13+
verifyingContract: "0x0000000000E655fAe4d56241588680F86E3b2377",
14+
name: "LooksRareProtocol",
15+
version: "2",
16+
chainId: "1",
17+
};
18+
19+
it("should revert if domain is not recognized by SDK entry", async () => {
20+
await expect(
21+
visualize(looksrareV2NormalListing, { ...looksrareDomain, chainId: "11" })
22+
).rejects.toThrowError("Unrecognized/Unsupported EIP712Protocol Domain");
23+
});
24+
25+
it("should revert at looksrare module level if accessed directly with wrong domain", () => {
26+
expect(() => {
27+
looksrare.visualize(looksrareV2NormalListing, {
28+
...looksrareDomain,
29+
verifyingContract: "0x0",
30+
});
31+
}).toThrow("wrong looksrare-v2 domain");
32+
});
33+
34+
it("should throw for unknown strategy", async () => {
35+
await expect(
36+
visualize<LooksRareV2MakerOrder>(
37+
{ ...looksrareV2Bid, strategyId: 3 as any },
38+
looksrareDomain
39+
)
40+
).rejects.toThrowError("unknown looksrare-v2 strategy with ID: 3");
41+
});
42+
43+
it("should successfully visualize sell order", async () => {
44+
const result = await visualize<LooksRareV2MakerOrder>(
45+
looksrareV2NormalListing,
46+
looksrareDomain
47+
);
48+
49+
expect(result).toEqual({
50+
protocol: "LOOKSRARE_EXCHANGE_V2",
51+
assetsIn: [
52+
{
53+
address: "0x0000000000000000000000000000000000000000",
54+
type: "NATIVE",
55+
amounts: ["100000000000000000"],
56+
},
57+
],
58+
assetsOut: [
59+
{
60+
address: "0x5f04D47D698F79d76F85E835930170Ff4c4EBdB7",
61+
type: "ERC721",
62+
id: "99117",
63+
amounts: ["1"],
64+
},
65+
],
66+
approvals: [],
67+
liveness: { from: 1684302184000, to: 1686893895000 },
68+
});
69+
});
70+
71+
it("should successfully visualize collection bid", async () => {
72+
const result = await visualize<LooksRareV2MakerOrder>(
73+
looksrareV2CollectionBid,
74+
looksrareDomain
75+
);
76+
77+
expect(result).toEqual({
78+
protocol: "LOOKSRARE_EXCHANGE_V2",
79+
assetsIn: [
80+
{
81+
address: "0xED5AF388653567Af2F388E6224dC7C4b3241C544",
82+
type: "ERC721",
83+
amounts: ["1"],
84+
},
85+
],
86+
assetsOut: [
87+
{
88+
address: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
89+
type: "ERC20",
90+
amounts: ["100000000000000000"],
91+
},
92+
],
93+
approvals: [],
94+
liveness: { from: 1684302184000, to: 1686893895000 },
95+
});
96+
});
97+
98+
it("should successfully visualize an ER1155 bid order", async () => {
99+
const result = await visualize<LooksRareV2MakerOrder>(
100+
looksrareV2Bid,
101+
looksrareDomain
102+
);
103+
104+
expect(result).toEqual({
105+
protocol: "LOOKSRARE_EXCHANGE_V2",
106+
assetsIn: [
107+
{
108+
address: "0x005AF388653567Af2F388E6224dC7C4b3241C500",
109+
type: "ERC1155",
110+
id: "1500",
111+
amounts: ["10"],
112+
},
113+
],
114+
assetsOut: [
115+
{
116+
address: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
117+
type: "ERC20",
118+
amounts: ["100000000000000000"],
119+
},
120+
],
121+
approvals: [],
122+
liveness: { from: 1684302184000, to: 1686893895000 },
123+
});
124+
});
125+
});

0 commit comments

Comments
 (0)