Files
prime-sdk-node/tests/sdk.test.ts
Andrew Miller 2ffa63df41
All checks were successful
Build and Test / build (20.x) (push) Successful in 45s
Build and Test / build (18.x) (push) Successful in 48s
Build and Test / build (16.x) (push) Successful in 52s
add getInterchain: trace a transaction/block to validator blocks + interchain anchors
New transaction.getInterchain and block.getInterchain call the prime-node
/api/v1/{transaction,block}/{id}/interchain endpoints, returning an
InterchainTrace { blockId, validatorBlocks, interchainTransactions }. Adds
VerificationBlock / InterchainTransaction / InterchainTrace interfaces and
method-existence assertions.
2026-06-02 14:12:59 -04:00

94 lines
2.9 KiB
TypeScript

/**
* Tests for main SDK
*/
import { DragonchainSDK } from '../src/index';
describe('DragonchainSDK', () => {
const testConfig = {
publicId: 'test-public-id',
authKeyId: 'test-auth-key-id',
authKey: 'test-auth-key',
baseURL: 'https://test.dragonchain.com',
};
let sdk: DragonchainSDK;
beforeEach(() => {
sdk = new DragonchainSDK(
testConfig.publicId,
testConfig.authKeyId,
testConfig.authKey,
testConfig.baseURL
);
});
describe('initialization', () => {
it('should create SDK instance', () => {
expect(sdk).toBeDefined();
});
it('should initialize all client modules', () => {
expect(sdk.transaction).toBeDefined();
expect(sdk.transactionType).toBeDefined();
expect(sdk.contract).toBeDefined();
expect(sdk.block).toBeDefined();
expect(sdk.system).toBeDefined();
});
it('should provide access to underlying client', () => {
const client = sdk.getClient();
expect(client).toBeDefined();
});
});
describe('module methods', () => {
it('should have transaction module with correct methods', () => {
expect(typeof sdk.transaction.create).toBe('function');
expect(typeof sdk.transaction.createBulk).toBe('function');
expect(typeof sdk.transaction.get).toBe('function');
expect(typeof sdk.transaction.getInterchain).toBe('function');
expect(typeof sdk.transaction.list).toBe('function');
});
it('should have transactionType module with correct methods', () => {
expect(typeof sdk.transactionType.create).toBe('function');
expect(typeof sdk.transactionType.get).toBe('function');
expect(typeof sdk.transactionType.list).toBe('function');
expect(typeof sdk.transactionType.delete).toBe('function');
});
it('should have contract module with correct methods', () => {
expect(typeof sdk.contract.create).toBe('function');
expect(typeof sdk.contract.get).toBe('function');
expect(typeof sdk.contract.list).toBe('function');
expect(typeof sdk.contract.update).toBe('function');
expect(typeof sdk.contract.upload).toBe('function');
expect(typeof sdk.contract.delete).toBe('function');
});
it('should have block module with correct methods', () => {
expect(typeof sdk.block.get).toBe('function');
expect(typeof sdk.block.getInterchain).toBe('function');
});
it('should have system module with correct methods', () => {
expect(typeof sdk.system.health).toBe('function');
expect(typeof sdk.system.status).toBe('function');
});
});
describe('timeout configuration', () => {
it('should accept custom timeout', () => {
const customSdk = new DragonchainSDK(
testConfig.publicId,
testConfig.authKeyId,
testConfig.authKey,
testConfig.baseURL,
60000
);
expect(customSdk).toBeDefined();
});
});
});