watcher-ts/packages/graph-node/test/utils/index.ts
prathamesh0 c79647548e Add more test cases for numeric host APIs (#66)
* Add test cases for bigInt host APIs

* Add test cases for bigDecimal fromString, plus and minus host APIs

* Add test cases for bigDecimal times and divideBy host APIs

* Throw an error on underflow or overflow in bigDecimal toString host API

* Avoid rounding of out of range bigDecimal values

* Use big number's byte size to set storage size of bigInt

* Add test cases for errors in bigDecimal host API
2021-12-28 16:08:05 +05:30

60 lines
1.2 KiB
TypeScript

//
// Copyright 2021 Vulcanize, Inc.
//
import { EventData } from '../../src/utils';
import { Database } from '../../src/database';
import { Indexer } from './indexer';
export const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000';
export const ZERO_HASH = '0x0000000000000000000000000000000000000000000000000000000000000000';
export const getDummyEventData = (): EventData => {
const block = {
blockHash: ZERO_HASH,
blockNumber: '0',
timestamp: '0',
parentHash: ZERO_HASH,
stateRoot: ZERO_HASH,
td: ZERO_HASH,
txRoot: ZERO_HASH,
receiptRoot: ZERO_HASH,
uncleHash: ZERO_HASH,
difficulty: '0',
gasLimit: '0',
gasUsed: '0',
author: ZERO_ADDRESS
};
const tx = {
hash: ZERO_HASH,
index: 0,
from: ZERO_ADDRESS,
to: ZERO_ADDRESS
};
return {
block,
tx,
inputs: [],
event: {},
eventIndex: 0
};
};
export const getDummyGraphData = (): any => {
return {
dataSource: {
address: ZERO_ADDRESS
}
};
};
export const getTestDatabase = (): Database => {
return new Database({ type: 'postgres' }, '');
};
export const getTestIndexer = (): Indexer => {
return new Indexer();
};