mirror of
https://github.com/cerc-io/watcher-ts
synced 2025-07-30 03:32:07 +00:00
Get endpoint URL from config in tests (#262)
This commit is contained in:
parent
d3971b5258
commit
08c0668ddb
@ -19,6 +19,7 @@
|
|||||||
[upstream.ethServer]
|
[upstream.ethServer]
|
||||||
gqlApiEndpoint = "http://127.0.0.1:8082/graphql"
|
gqlApiEndpoint = "http://127.0.0.1:8082/graphql"
|
||||||
gqlPostgraphileEndpoint = "http://127.0.0.1:5000/graphql"
|
gqlPostgraphileEndpoint = "http://127.0.0.1:5000/graphql"
|
||||||
|
rpcProviderEndpoint = "http://127.0.0.1:8545"
|
||||||
|
|
||||||
[upstream.cache]
|
[upstream.cache]
|
||||||
name = "requests"
|
name = "requests"
|
||||||
|
@ -43,7 +43,6 @@ import {
|
|||||||
} from '../test/utils';
|
} from '../test/utils';
|
||||||
|
|
||||||
const CONFIG_FILE = './environments/local.toml';
|
const CONFIG_FILE = './environments/local.toml';
|
||||||
const NETWORK_RPC_URL = 'http://localhost:8545';
|
|
||||||
|
|
||||||
describe('uni-info-watcher', () => {
|
describe('uni-info-watcher', () => {
|
||||||
let factory: Contract;
|
let factory: Contract;
|
||||||
@ -64,16 +63,12 @@ describe('uni-info-watcher', () => {
|
|||||||
let client: Client;
|
let client: Client;
|
||||||
|
|
||||||
before(async () => {
|
before(async () => {
|
||||||
const provider = new ethers.providers.JsonRpcProvider(NETWORK_RPC_URL);
|
|
||||||
signer = provider.getSigner();
|
|
||||||
recipient = await signer.getAddress();
|
|
||||||
|
|
||||||
config = await getConfig(CONFIG_FILE);
|
config = await getConfig(CONFIG_FILE);
|
||||||
|
|
||||||
const { upstream, server: { host, port } } = config;
|
const { upstream, server: { host, port } } = config;
|
||||||
const endpoint = `http://${host}:${port}/graphql`;
|
const endpoint = `http://${host}:${port}/graphql`;
|
||||||
|
|
||||||
let { uniWatcher: { gqlEndpoint, gqlSubscriptionEndpoint } } = upstream;
|
let { uniWatcher: { gqlEndpoint, gqlSubscriptionEndpoint }, ethServer: { rpcProviderEndpoint } } = upstream;
|
||||||
uniClient = new UniClient({
|
uniClient = new UniClient({
|
||||||
gqlEndpoint,
|
gqlEndpoint,
|
||||||
gqlSubscriptionEndpoint
|
gqlSubscriptionEndpoint
|
||||||
@ -85,6 +80,10 @@ describe('uni-info-watcher', () => {
|
|||||||
gqlEndpoint,
|
gqlEndpoint,
|
||||||
gqlSubscriptionEndpoint
|
gqlSubscriptionEndpoint
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const provider = new ethers.providers.JsonRpcProvider(rpcProviderEndpoint);
|
||||||
|
signer = provider.getSigner();
|
||||||
|
recipient = await signer.getAddress();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should have a Factory entity', async () => {
|
it('should have a Factory entity', async () => {
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
[upstream.ethServer]
|
[upstream.ethServer]
|
||||||
gqlApiEndpoint = "http://127.0.0.1:8082/graphql"
|
gqlApiEndpoint = "http://127.0.0.1:8082/graphql"
|
||||||
gqlPostgraphileEndpoint = "http://127.0.0.1:5000/graphql"
|
gqlPostgraphileEndpoint = "http://127.0.0.1:5000/graphql"
|
||||||
|
rpcProviderEndpoint = "http://127.0.0.1:8545"
|
||||||
|
|
||||||
[upstream.cache]
|
[upstream.cache]
|
||||||
name = "requests"
|
name = "requests"
|
||||||
|
@ -45,7 +45,6 @@ import {
|
|||||||
} from '../test/utils';
|
} from '../test/utils';
|
||||||
|
|
||||||
const CONFIG_FILE = './environments/local.toml';
|
const CONFIG_FILE = './environments/local.toml';
|
||||||
const NETWORK_RPC_URL = 'http://localhost:8545';
|
|
||||||
|
|
||||||
describe('uni-watcher', () => {
|
describe('uni-watcher', () => {
|
||||||
let factory: Contract;
|
let factory: Contract;
|
||||||
@ -77,9 +76,10 @@ describe('uni-watcher', () => {
|
|||||||
assert(host, 'Missing host.');
|
assert(host, 'Missing host.');
|
||||||
assert(port, 'Missing port.');
|
assert(port, 'Missing port.');
|
||||||
|
|
||||||
const { ethServer: { gqlApiEndpoint, gqlPostgraphileEndpoint }, cache: cacheConfig } = upstream;
|
const { ethServer: { gqlApiEndpoint, gqlPostgraphileEndpoint, rpcProviderEndpoint }, cache: cacheConfig } = upstream;
|
||||||
assert(gqlApiEndpoint, 'Missing upstream ethServer.gqlApiEndpoint.');
|
assert(gqlApiEndpoint, 'Missing upstream ethServer.gqlApiEndpoint.');
|
||||||
assert(gqlPostgraphileEndpoint, 'Missing upstream ethServer.gqlPostgraphileEndpoint.');
|
assert(gqlPostgraphileEndpoint, 'Missing upstream ethServer.gqlPostgraphileEndpoint.');
|
||||||
|
assert(rpcProviderEndpoint, 'Missing upstream ethServer.rpcProviderEndpoint.');
|
||||||
assert(cacheConfig, 'Missing dbConfig.');
|
assert(cacheConfig, 'Missing dbConfig.');
|
||||||
|
|
||||||
db = new Database(dbConfig);
|
db = new Database(dbConfig);
|
||||||
@ -105,7 +105,7 @@ describe('uni-watcher', () => {
|
|||||||
gqlSubscriptionEndpoint
|
gqlSubscriptionEndpoint
|
||||||
});
|
});
|
||||||
|
|
||||||
const provider = new ethers.providers.JsonRpcProvider(NETWORK_RPC_URL);
|
const provider = new ethers.providers.JsonRpcProvider(rpcProviderEndpoint);
|
||||||
signer = provider.getSigner();
|
signer = provider.getSigner();
|
||||||
recipient = await signer.getAddress();
|
recipient = await signer.getAddress();
|
||||||
});
|
});
|
||||||
|
@ -22,7 +22,6 @@ import { Database } from '../src/database';
|
|||||||
import { watchContract } from '../src/utils/index';
|
import { watchContract } from '../src/utils/index';
|
||||||
|
|
||||||
const CONFIG_FILE = './environments/local.toml';
|
const CONFIG_FILE = './environments/local.toml';
|
||||||
const NETWORK_RPC_URL = 'http://localhost:8545';
|
|
||||||
|
|
||||||
const deployFactoryContract = async (db: Database, signer: Signer): Promise<Contract> => {
|
const deployFactoryContract = async (db: Database, signer: Signer): Promise<Contract> => {
|
||||||
// Deploy factory from uniswap package.
|
// Deploy factory from uniswap package.
|
||||||
@ -53,10 +52,11 @@ const main = async () => {
|
|||||||
// Get config.
|
// Get config.
|
||||||
const config = await getConfig(CONFIG_FILE);
|
const config = await getConfig(CONFIG_FILE);
|
||||||
|
|
||||||
const { database: dbConfig, server: { host, port } } = config;
|
const { database: dbConfig, server: { host, port }, upstream: { ethServer: { rpcProviderEndpoint } } } = config;
|
||||||
assert(dbConfig, 'Missing dbConfig.');
|
assert(dbConfig, 'Missing dbConfig.');
|
||||||
assert(host, 'Missing host.');
|
assert(host, 'Missing host.');
|
||||||
assert(port, 'Missing port.');
|
assert(port, 'Missing port.');
|
||||||
|
assert(rpcProviderEndpoint, 'Missing rpcProviderEndpoint.');
|
||||||
|
|
||||||
// Initialize uniClient.
|
// Initialize uniClient.
|
||||||
const endpoint = `http://${host}:${port}/graphql`;
|
const endpoint = `http://${host}:${port}/graphql`;
|
||||||
@ -71,7 +71,7 @@ const main = async () => {
|
|||||||
const db = new Database(dbConfig);
|
const db = new Database(dbConfig);
|
||||||
await db.init();
|
await db.init();
|
||||||
|
|
||||||
const provider = new ethers.providers.JsonRpcProvider(NETWORK_RPC_URL);
|
const provider = new ethers.providers.JsonRpcProvider(rpcProviderEndpoint);
|
||||||
const signer = provider.getSigner();
|
const signer = provider.getSigner();
|
||||||
|
|
||||||
let factory: Contract;
|
let factory: Contract;
|
||||||
|
Loading…
Reference in New Issue
Block a user