From 585b1e39eb40fb0475483fffb0de3d11dee42ca0 Mon Sep 17 00:00:00 2001 From: aryan Date: Wed, 25 Dec 2024 05:13:48 +0530 Subject: [PATCH] fix: stale files --- package.json | 1 - test/domain_methods.test.ts | 146 ------------------------------------ 2 files changed, 147 deletions(-) delete mode 100644 test/domain_methods.test.ts diff --git a/package.json b/package.json index 0cfe2495..9c16fd6d 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,6 @@ "build": "tsc", "docs": "typedoc src --out docs", "test": "ts-node test/index.ts", - "test:domain": "ts-node test/domain_methods.test.ts", "generate": "ts-node src/utils/keypair.ts" }, "engines": { diff --git a/test/domain_methods.test.ts b/test/domain_methods.test.ts deleted file mode 100644 index 2485ed73..00000000 --- a/test/domain_methods.test.ts +++ /dev/null @@ -1,146 +0,0 @@ - -import { SolanaAgentKit } from "../src"; -import { PublicKey } from "@solana/web3.js"; -import * as dotenv from "dotenv"; -import { expect } from "chai"; -import { before, describe, it } from "node:test"; -import { TldParser } from "@onsol/tldparser"; - -dotenv.config(); - -describe("Solana Domain Methods Tests", () => { - let agent: SolanaAgentKit; - - before(() => { - // Initialize the agent before running tests - if ( - !process.env.SOLANA_PRIVATE_KEY || - !process.env.RPC_URL || - !process.env.OPENAI_API_KEY - ) { - throw new Error("Required environment variables are not set"); - } - - agent = new SolanaAgentKit( - process.env.SOLANA_PRIVATE_KEY, - process.env.RPC_URL, - process.env.OPENAI_API_KEY - ); - }); - - describe("resolveAllDomains", () => { - it("should resolve a valid domain to a public key", async () => { - const testDomain = "hero.sol"; - const result = await agent.resolveAllDomains(testDomain); - expect(result).to.be.instanceof(PublicKey); - }); - it("should perform fetching of an owner an nft domain", async () => { - const parser = new TldParser(agent.connection); - const domanTld = "miester.sol"; - const ownerReceived = await parser.getOwnerFromDomainTld(domanTld); - const owner = new PublicKey( - "2EGGxj2qbNAJNgLCPKca8sxZYetyTjnoRspTPjzN2D67" - ); - expect(ownerReceived).to.be(owner.toString()); - }); - it("should return null for non-existent domain", async () => { - const nonExistentDomain = "nonexistent123456789.sol"; - const result = await agent.resolveAllDomains(nonExistentDomain); - expect(result).to.be.null; - }); - - it("should handle invalid domain format", async () => { - const invalidDomain = ""; - try { - await agent.resolveAllDomains(invalidDomain); - expect.fail("Should have thrown an error"); - } catch (error) { - expect(error).to.be.instanceof(Error); - } - }); - }); - - describe("getOwnedAllDomains", () => { - it("should return array of domains for an owner", async () => { - const owner = new PublicKey( - "2EGGxj2qbNAJNgLCPKca8sxZYetyTjnoRspTPjzN2D67" - ); - const domains = await agent.getOwnedAllDomains(owner); - expect(domains).to.be.an("array").that.includes("miester.sol"); - domains.forEach((domain) => { - expect(domain).to.be.a("string"); - }); - }); - it("should return array of domains for an owner", async () => { - const owner = new PublicKey(agent.wallet_address); - const domains = await agent.getOwnedAllDomains(owner); - expect(domains).to.be.an("array"); - domains.forEach((domain) => { - expect(domain).to.be.a("string"); - }); - }); - - it("should handle owner with no domains", async () => { - // Create a new random public key that likely owns no domains - const emptyOwner = PublicKey.unique(); - const domains = await agent.getOwnedAllDomains(emptyOwner); - expect(domains).to.be.an("array"); - expect(domains).to.have.lengthOf(0); - }); - }); - - describe("getOwnedDomainsForTLD", () => { - it("should return domains for specific TLD", async () => { - const tld = "sol"; - const domains = await agent.getOwnedDomainsForTLD(tld); - expect(domains).to.be.an("array"); - domains.forEach((domain) => { - console.log(`these are the domains ${domain.domain}`) - }); - }); - - it("should return empty array for non-existent TLD", async () => { - const nonExistentTLD = "nonexistent"; - const domains = await agent.getOwnedDomainsForTLD(nonExistentTLD); - expect(domains).to.be.an("array"); - expect(domains).to.have.lengthOf(0); - }); - }); - - describe("getAllDomainsTLDs", () => { - it("should return array of TLDs", async () => { - const tlds = await agent.getAllDomainsTLDs(); - expect(tlds).to.be.an("array"); - }); - }); - - describe("getAllRegisteredAllDomains", () => { - it("should return array of all registered domains", async () => { - const domains = await agent.getAllRegisteredAllDomains(); - expect(domains).to.be.an("array"); - domains.forEach((domain) => { - expect(domain).to.be.a("string"); - expect(domain).to.include("."); - }); - }); - }); - - describe("getMainAllDomainsDomain", () => { - it("should return main domain or null for an owner", async () => { - const owner = new PublicKey( - "2EGGxj2qbNAJNgLCPKca8sxZYetyTjnoRspTPjzN2D67" - ); - const mainDomain = await agent.getMainAllDomainsDomain(owner); - expect(mainDomain).to.satisfy((domain: string | null) => { - return domain === null || typeof domain === "string"; - }); - }); - - it("should return null for address without main domain", async () => { - const emptyOwner = PublicKey.unique(); - const mainDomain = await agent.getMainAllDomainsDomain(emptyOwner); - expect(mainDomain).to.be.null; - }); - }); -}); -