UNPKG

scorechain-sdk

Version:

SDK for the Scorechain API

56 lines (51 loc) 2.35 kB
import { ScorechainConnector } from "../../lib/scorechainConnector"; import { ScoringAnalysisType } from "../../types/scoringAnalysis"; import { randomUUID } from "crypto"; import { BlockchainEnum } from "../../types/common"; import { ScorechainError } from "../../types/errors/ScorchainError"; const connector = new ScorechainConnector(process.env["SCORECHAIN_API_KEY"] ?? "", false); jest.setTimeout(30000); describe("scorechainConnector", () => { test("getTransaction", async () => { const tx = await connector.getTransaction( "0x308b22a8e0e9e4e7d1b9fd1dfab74d7b37325b255e566f4d81edd457937c5e0c", BlockchainEnum.ETHEREUM ); expect(tx).toBeDefined(); expect(tx.hash).toBe("0x308b22a8e0e9e4e7d1b9fd1dfab74d7b37325b255e566f4d81edd457937c5e0c"); expect(tx.blockchain).toBe(BlockchainEnum.ETHEREUM); }); test("getTransaction which throw a ScorechainError", async () => { const tx = connector.getTransaction("0x308b22a8e0e9e4eb255e566f4d81edd457937c5e0c", BlockchainEnum.ETHEREUM); await expect(tx).rejects.toThrow(ScorechainError); }); test("getTransactionScoringAnalysis", async () => { const txScoring = await connector.getTransactionScoringAnalysis( "0x308b22a8e0e9e4e7d1b9fd1dfab74d7b37325b255e566f4d81edd457937c5e0c", BlockchainEnum.ETHEREUM, "MAIN", ScoringAnalysisType.INCOMING, 6 ); expect(txScoring).toBeDefined(); expect(txScoring.analysis).toBeDefined(); expect(txScoring.analysis.incoming).toBeDefined(); expect(txScoring.analysis.assigned).toBeDefined(); expect(txScoring.analysis.outgoing).toBeUndefined(); expect(txScoring.lowestScore).toBeGreaterThanOrEqual(1); expect(txScoring.lowestScore).toBeLessThanOrEqual(100); }); test("feedWithdrawal", async () => { const uuid = randomUUID(); const feedWithdrawal = await connector.feedWithdrawal( "31oSGBBNrpCiENH3XMZpiP6GTC4tad4bMy", BlockchainEnum.BITCOIN, 1500, "MAIN", uuid ); expect(feedWithdrawal).toBeDefined(); expect(feedWithdrawal.blockchain).toBe(BlockchainEnum.BITCOIN); expect(feedWithdrawal.identifier).toBe(uuid); }); });