Skip to content

Commit

Permalink
fix lints and improve test plna
Browse files Browse the repository at this point in the history
  • Loading branch information
nlordell authored and Nicholas Rodrigues Lordello committed May 4, 2020
1 parent 0fc9cb3 commit c745fa9
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 10 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"test-stablex": "yarn run test-js test/stablex/*",
"test-js": "truffle test",
"test-ts": "mocha -r ts-node/register 'test/models/**/*spec.ts'",
"test-streamed-orderbook": "TEST_STREAMED_ORDERBOOK_E2E=1 mocha -r ts-node/register test/models/streamed/index.spec.ts",
"coverage": "truffle run coverage --network coverage --file \"{build/common/,}test/*js\"",
"networks-extract": "CONF_FILE=$(pwd)'/migration_conf.js' node node_modules/@gnosis.pm/util-contracts/src/extract_network_info.js",
"networks-inject": "CONF_FILE=$(pwd)'/migration_conf.js' node node_modules/@gnosis.pm/util-contracts/src/inject_network_info.js",
Expand Down
12 changes: 5 additions & 7 deletions src/streamed/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,10 @@
* @packageDocumentation
*/

import assert from 'assert'
import Web3 from 'web3'
import { TransactionReceipt } from 'web3-core'
import { EventData } from 'web3-eth-contract'
import { BatchExchange, BatchExchangeArtifact } from '../..'
import { AccountState } from './state'
import Web3 from "web3"
import { TransactionReceipt } from "web3-core"
import { BatchExchange, BatchExchangeArtifact } from "../.."
import { AccountState } from "./state"

/**
* Configuration options for the streamed orderbook.
Expand Down Expand Up @@ -138,7 +136,7 @@ export class StreamedOrderbook {
this.options.logger?.debug(`fetching page ${fromBlock}-${toBlock}`)

const events = await this.contract.getPastEvents(
'allEvents',
"allEvents",
{ fromBlock, toBlock },
)

Expand Down
15 changes: 12 additions & 3 deletions test/models/streamed/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,24 @@ import { StreamedOrderbook } from "../../../src/streamed"
describe("Streamed Orderbook", () => {
describe("init", () => {
it("should successfully apply all events and match on-chain orderbook", async function() {
const { ETHEREUM_NODE_URL, ORDERBOOK_END_BLOCK, TEST_STREAMED_ORDERBOOK_E2E } = process.env
const {
ETHEREUM_NODE_URL,
INFURA_PROJECT_ID,
ORDERBOOK_END_BLOCK,
TEST_STREAMED_ORDERBOOK_E2E,
} = process.env
if (!TEST_STREAMED_ORDERBOOK_E2E) {
this.skip()
return
}

assert.isDefined(ETHEREUM_NODE_URL, "ETHEREUM_NODE_URL environment variable is required");
assert.isDefined(
ETHEREUM_NODE_URL || INFURA_PROJECT_ID,
"ETHEREUM_NODE_URL or INFURA_PROJECT_ID environment variable is required",
)
const url = ETHEREUM_NODE_URL || `https://mainnet.infura.io/v3/${INFURA_PROJECT_ID}`
const web3 = new Web3(url)

const web3 = new Web3(ETHEREUM_NODE_URL!)
await StreamedOrderbook.init(web3, {
endBlock: ORDERBOOK_END_BLOCK ? parseInt(ORDERBOOK_END_BLOCK) : undefined,
strict: true,
Expand Down

0 comments on commit c745fa9

Please sign in to comment.