Skip to content

Commit

Permalink
update default ipfs gateways in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Rinse12 committed Nov 4, 2024
1 parent 7a277ab commit fd967f8
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 6 deletions.
11 changes: 10 additions & 1 deletion test/browser/plebbit.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,16 @@ describe("plebbit", () => {
it("Plebbit() has default plebbit options", async () => {
// RPC exception
const plebbit = await Plebbit();
expect(Object.keys(plebbit.clients.ipfsGateways).sort()).to.deep.equal(["https://dweb.link", "https://ipfs.io"].sort());
expect(Object.keys(plebbit.clients.ipfsGateways).sort()).to.deep.equal(
[
"https://ipfsgateway.xyz",
"https://ipfs.io",
"https://dweb.link",
"https://flk-ipfs.xyz",
"https://4everland.io",
"https://gateway.pinata.cloud"
].sort()
);
expect(Object.keys(plebbit.clients.pubsubClients)).to.deep.equal(["https://pubsubprovider.xyz/api/v0"]);

// no dataPath in brower
Expand Down
31 changes: 27 additions & 4 deletions test/node-and-browser/plebbit.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,16 @@ const subplebbitSigner = signers[0];
describe("Plebbit options", async () => {
it("Plebbit() uses correct default plebbit options", async () => {
const defaultPlebbit = await Plebbit();
expect(Object.keys(defaultPlebbit.clients.ipfsGateways).sort()).to.deep.equal(["https://dweb.link", "https://ipfs.io"].sort());
expect(Object.keys(defaultPlebbit.clients.ipfsGateways).sort()).to.deep.equal(
[
"https://ipfsgateway.xyz",
"https://ipfs.io",
"https://dweb.link",
"https://flk-ipfs.xyz",
"https://4everland.io",
"https://gateway.pinata.cloud"
].sort()
);
expect(Object.keys(defaultPlebbit.clients.pubsubClients)).to.deep.equal(["https://pubsubprovider.xyz/api/v0"]);
expect(defaultPlebbit.pubsubHttpClientsOptions).to.deep.equal([{ url: "https://pubsubprovider.xyz/api/v0" }]);
expect(defaultPlebbit.pubsubHttpClientsOptions.headers?.authorization).to.be.undefined;
Expand All @@ -43,7 +52,14 @@ describe("Plebbit options", async () => {
expect(testPlebbit.clients.ipfsClients[url]).to.exist;
expect(testPlebbit.clients.pubsubClients[url]).to.exist;
expect(testPlebbit.clients.ipfsClients[url]._client).to.deep.equal(testPlebbit.clients.pubsubClients[url]._client);
expect(Object.keys(testPlebbit.clients.ipfsGateways).sort()).to.deep.equal(["https://dweb.link", "https://ipfs.io"]);
expect(Object.keys(testPlebbit.clients.ipfsGateways).sort()).to.deep.equal([
"https://ipfsgateway.xyz",
"https://ipfs.io",
"https://dweb.link",
"https://flk-ipfs.xyz",
"https://4everland.io",
"https://gateway.pinata.cloud"
]);
expect(Object.keys(testPlebbit.clients.ipfsClients)).to.deep.equal([url]);

expect(Object.keys(testPlebbit.clients.pubsubClients)).to.deep.equal([url]);
Expand All @@ -55,7 +71,14 @@ describe("Plebbit options", async () => {
const url = "http://localhost:12323/api/v0"; // Should be offline
const plebbit = await Plebbit({ ipfsHttpClientsOptions: [url] });

expect(Object.keys(plebbit.clients.ipfsGateways).sort()).to.deep.equal(["https://dweb.link", "https://ipfs.io"]);
expect(Object.keys(plebbit.clients.ipfsGateways).sort()).to.deep.equal([
"https://ipfsgateway.xyz",
"https://ipfs.io",
"https://dweb.link",
"https://flk-ipfs.xyz",
"https://4everland.io",
"https://gateway.pinata.cloud"
]);
expect(Object.keys(plebbit.clients.pubsubClients)).to.deep.equal([url]);
expect(Object.keys(plebbit.clients.ipfsClients)).to.deep.equal([url]);

Expand Down Expand Up @@ -88,7 +111,7 @@ describe("Plebbit options", async () => {
plebbit.clients.ipfsClients[nodeForHttpRouter]._client.stop = () => {};
expect(plebbit.httpRoutersOptions).to.deep.equal(httpRouterUrls);

await new Promise((resolve) => setTimeout(resolve, 2000));
await new Promise((resolve) => setTimeout(resolve, 5000));

const ipfsClient = plebbit.clients.ipfsClients[nodeForHttpRouter]._client;
const configValueType = await ipfsClient.config.get("Routing.Type");
Expand Down
11 changes: 10 additions & 1 deletion test/node/plebbit.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,16 @@ import { itIfRpc, itSkipIfRpc, mockPlebbit } from "../../dist/node/test/test-uti
describe("await plebbit()", () => {
it("has default plebbit options", async () => {
const plebbit = await Plebbit();
expect(Object.keys(plebbit.clients.ipfsGateways).sort()).to.deep.equal(["https://dweb.link", "https://ipfs.io"].sort());
expect(Object.keys(plebbit.clients.ipfsGateways).sort()).to.deep.equal(
[
"https://ipfsgateway.xyz",
"https://ipfs.io",
"https://dweb.link",
"https://flk-ipfs.xyz",
"https://4everland.io",
"https://gateway.pinata.cloud"
].sort()
);
expect(Object.keys(plebbit.clients.pubsubClients)).to.deep.equal(["https://pubsubprovider.xyz/api/v0"]);
expect(plebbit.clients.ipfsClients).to.deep.equal({});
expect(plebbit.ipfsHttpClientsOptions).to.be.undefined;
Expand Down

0 comments on commit fd967f8

Please sign in to comment.