@noves/noves-sdk
Version:
Noves Developer Kit
54 lines (47 loc) • 1.97 kB
text/typescript
/**
* 1.5.0 Release Test — Foresight API (regression)
*
* Validates the Foresight EVM API:
* - ForesightFactory usage
* - getChains()
* - describe() with a simple ETH transfer
*/
import { ForesightFactory, Foresight } from '../dist/index';
import { section, pass, fail, runTest, skip } from './helpers';
const API_KEY = process.env.NOVES_API_KEY!;
export async function testCoreForesight() {
section('CORE: Foresight API (Regression)');
// 1. ForesightFactory.evm
await runTest('ForesightFactory.evm()', async () => {
const foresight = ForesightFactory.evm(API_KEY);
if (!foresight) throw new Error('ForesightFactory.evm() returned null');
pass('ForesightFactory.evm()', 'Instance created');
});
// 2. Foresight getChains
await runTest('Foresight.getChains()', async () => {
const foresight = ForesightFactory.evm(API_KEY);
const chains = await foresight.getChains();
if (!chains) throw new Error('Foresight getChains() empty');
pass('Foresight.getChains()', `OK`);
});
// 3. Foresight describe — simple ETH transfer
await runTest('Foresight.describe(eth transfer)', async () => {
const foresight = ForesightFactory.evm(API_KEY);
const result = await foresight.describe('eth', {
from: '0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045',
to: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',
value: '0x0',
data: '0x'
});
if (!result) throw new Error('Foresight describe returned null');
pass('Foresight.describe()', `Result: ${JSON.stringify(result).substring(0, 120)}`);
});
// 4. Foresight direct class export
await runTest('Foresight: direct class export', async () => {
if (!Foresight) throw new Error('Foresight class not exported');
const foresight = new Foresight(API_KEY);
const chains = await foresight.getChains();
if (!chains) throw new Error('Direct Foresight failed');
pass('Foresight: direct class', 'new Foresight() works');
});
}